Skip to content

Commit

Permalink
[FIX] some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomacr committed Jun 14, 2018
1 parent 890fec5 commit dcc9e07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ProductReplenishmentCostRule(models.Model):
'Test Product',
compute=lambda x: x,
inverse=lambda x: x,
help="This field it's only for testing"
help="Technical field: This field it's only for testing",
)

demo_cost = fields.Float('Cost', compute=lambda x: x)
Expand Down Expand Up @@ -118,8 +118,10 @@ def compute_rule(self, cost, product=None):
pass

values[line.name] = error or value
line.value = error or str(value)
line.error = error
line.update({
'value': error or str(value),
'error': error,
})
if line.add_to_cost:
cost = cost + value

Expand All @@ -134,5 +136,7 @@ def _onchange_product_id(self):
""" On change to show dynamic results. """
if self.product_id:
cost = self.product_id.replenishment_base_cost_on_currency
self.demo_cost = cost
self.demo_result = self.compute_rule(cost, self.product_id)
self.update({
'demo_cost': cost,
'demo_result': self.compute_rule(cost, self.product_id),
})
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ class ProductReplenishmentCostRuleItem(models.Model):
)

# no-op for testing and calculating rule
value = fields.Char(compute=lambda x: x)
error = fields.Char(compute=lambda x: x)
value = fields.Char(
compute=lambda x: x,
help="Technical fields: This field it's only for testing",
)
error = fields.Char(
compute=lambda x: x,
help="Technical fields: This field it's only for testing",
)
4 changes: 1 addition & 3 deletions product_replenishment_cost/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def _default_replenishment_base_cost_currency_id(self):

replenishment_base_cost_on_currency = fields.Float(
compute='_compute_replenishment_cost',
string='Replenishment Base Cost on Currency',
digits=dp.get_precision('Product Price'),
)

Expand Down Expand Up @@ -121,7 +120,7 @@ def _update_cost_from_replenishment_cost(self):
# para que solo se haga el commit por cron
if commit_transaction:
cr.commit() # pylint: disable=invalid-commit
_logger.info('Finish updating cost of run %s' % run)
_logger.info('Finish updating cost of run %s', run)

return True

Expand All @@ -142,7 +141,6 @@ def update_replenishment_cost_last_update(self):
'replenishment_base_cost_currency_id.rate_ids.rate',
# and this if we change de date (name field)
'replenishment_base_cost_currency_id.rate_ids.name',
'replenishment_base_cost_on_currency',
# rule items
'replenishment_cost_rule_id.item_ids.sequence',
'replenishment_cost_rule_id.item_ids.percentage_amount',
Expand Down

0 comments on commit dcc9e07

Please sign in to comment.