product_sale_price_from_pricelist: add filter for products that need to update sale price

This commit is contained in:
Luis 2025-09-17 12:06:27 +02:00
parent a24b4392d6
commit 93ccb20a17
2 changed files with 19 additions and 3 deletions

View file

@ -46,6 +46,18 @@ class ProductTemplate(models.Model):
company_dependent=True,
)
price_differs = fields.Boolean(
string="Price Differs", compute="_compute_price_differs", store=True
)
@api.depends("list_price", "list_price_theoritical")
def _compute_price_differs(self):
for product in self:
product.price_differs = (
product.list_price != product.list_price_theoritical
and product.last_purchase_price_compute_type != "manual_update"
)
def _compute_theoritical_price(self):
pricelist_obj = self.env["product.pricelist"]
pricelist_id = (
@ -89,7 +101,9 @@ class ProductTemplate(models.Model):
template.write(
{
"list_price_theoritical": price_with_taxes,
"last_purchase_price_updated": True,
"last_purchase_price_updated": (
price_with_taxes != template.list_price
),
}
)
else:

View file

@ -60,8 +60,10 @@
<filter string="To update sales price"
name="products_updated_filter"
domain="[('last_purchase_price_updated', '=', True), ('last_purchase_price_compute_type', '!=', 'manual_update')]"
help="Products that have recently changed their cost price and have not updated their selling price."
icon="terp-project"
/>
<filter string="Different Theoritical Price"
name="products_diff_theoritical_filter"
domain="[('price_differs', '=', True)]"
/>
</xpath>
</field>