Skip to content

Commit

Permalink
[IMP] rep cost: no write on constraints
Browse files Browse the repository at this point in the history
use new stored computed fields
  • Loading branch information
jjscarafia committed Dec 31, 2020
1 parent a5fd5d8 commit 5c73543
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion product_replenishment_cost/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Replenishment Cost',
'version': '13.0.1.5.0',
'version': '13.0.1.6.0',
'author': "ADHOC SA, Camptocamp,GRAP,Odoo Community Association (OCA)",
'license': 'AGPL-3',
'category': 'Products',
Expand Down
10 changes: 5 additions & 5 deletions product_replenishment_cost/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ProductTemplate(models.Model):
)
replenishment_cost_last_update = fields.Datetime(
tracking=True,
compute='_compute_replenishment_cost_last_update',
store=True,
)
replenishment_base_cost = fields.Float(
digits='Product Price',
Expand Down Expand Up @@ -131,14 +133,12 @@ def _update_cost_from_replenishment_cost(self):
product.standard_price = replenishment_cost
return True

@api.constrains(
@api.depends(
'replenishment_base_cost',
'replenishment_base_cost_currency_id',
)
def update_replenishment_cost_last_update(self):
# con el tracking_disable nos ahorramos doble mensaje
self.with_context(tracking_disable=True).write(
{'replenishment_cost_last_update': fields.Datetime.now()})
def _compute_replenishment_cost_last_update(self):
self.replenishment_cost_last_update = fields.Datetime.now()

# TODO ver si necesitamos borrar estos depends o no, por ahora
# no parecen afectar performance y sirvern para que la interfaz haga
Expand Down

0 comments on commit 5c73543

Please sign in to comment.