purchase_order_product_recommendation_supermarket: make prevous period data optional
This commit is contained in:
parent
b153fdc7af
commit
3a35955d24
2 changed files with 53 additions and 32 deletions
|
|
@ -20,6 +20,11 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
|
|||
default=False,
|
||||
help="If enabled, days when the product stock was 0 or less will not be considered in the daily sales calculation.",
|
||||
)
|
||||
include_previous_period = fields.Boolean(
|
||||
string="Include previous period stats",
|
||||
default=True,
|
||||
help="If disabled, the previous period (same number of days immediately preceding) is NOT queried. This saves a read_group on stock move lines and skips zero-stock day analysis for that window.",
|
||||
)
|
||||
total_days = fields.Integer(
|
||||
string="Total days",
|
||||
compute="_compute_total_days",
|
||||
|
|
@ -193,6 +198,7 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
|
|||
if len(found_scrapped):
|
||||
res["units_scrapped"] = found_scrapped[0]["qty_done"]
|
||||
|
||||
if self.include_previous_period:
|
||||
days = self._get_total_days()
|
||||
prev_date_end = self.date_begin - timedelta(days=1)
|
||||
prev_date_begin = self.date_begin - timedelta(days=days)
|
||||
|
|
@ -273,6 +279,10 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
|
|||
class PurchaseOrderRecommendationLine(models.TransientModel):
|
||||
_inherit = "purchase.order.recommendation.line"
|
||||
|
||||
include_previous_period = fields.Boolean(
|
||||
related="wizard_id.include_previous_period", store=False, readonly=True
|
||||
)
|
||||
|
||||
packaging_id = fields.Many2one(
|
||||
comodel_name="product.packaging",
|
||||
string="Packaging",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<field name="show_all_products" position="after">
|
||||
<field name="order_by_packages" />
|
||||
<field name="ignore_zero_stock_days" />
|
||||
<field name="include_previous_period" />
|
||||
<field name="last_order_total_amount" widget="monetary" options="{'currency_field': 'currency_id'}" />
|
||||
<field name="order_total_amount" widget="monetary" options="{'currency_field': 'currency_id'}" />
|
||||
<field name="currency_id" invisible="1"/>
|
||||
|
|
@ -32,6 +33,15 @@
|
|||
<field name="product_id" position="attributes">
|
||||
<attribute name="optional">hide</attribute>
|
||||
</field>
|
||||
<field name="price_unit" position="attributes">
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
<field name="units_available" position="attributes">
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
<field name="units_avg_delivered" position="attributes">
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
<field name="product_name" position="attributes">
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
|
|
@ -39,8 +49,9 @@
|
|||
<field name="units_scrapped" string="Qty scrapped" optional="hide" />
|
||||
<field name="stock_duration" string="Stock Duration" optional="hide" />
|
||||
<field name="days_without_stock" optional="hide" />
|
||||
<field name="units_delivered_prev" string="Prev Period" optional="hide" />
|
||||
<field name="units_avg_delivered_prev" string="Avg Prev Period" optional="hide" />
|
||||
<field name="include_previous_period" invisible="1"/>
|
||||
<field name="units_delivered_prev" string="Prev Period" optional="hide" attrs="{'invisible': [('include_previous_period','=',False)]}" />
|
||||
<field name="units_avg_delivered_prev" string="Avg Prev Period" optional="hide" attrs="{'invisible': [('include_previous_period','=',False)]}" />
|
||||
<field name="packaging_id" optional="show" />
|
||||
<field name="packaging_contained_qty" string="Packaging Contained Qty" optional="hide" />
|
||||
<field name="subtotal_amount" string="Subtotal Amount" optional="hide" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue