Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] product_replenishment_cost: refactor for performance purposes #715

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions product_replenishment_cost/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ class ProductTemplate(models.Model):
supplier_currency_id = fields.Many2one(
'res.currency',
compute='_compute_supplier_data',
compute_sudo=True,
)
supplier_price = fields.Float(
string='Supplier Price',
compute='_compute_supplier_data',
compute_sudo=True,
digits='Product Price',
)
standard_price = fields.Float(
string='Accounting Cost',
)
replenishment_cost = fields.Float(
compute='_compute_replenishment_cost',
compute_sudo=True,
# TODO, activamos store como estaba??
store=False,
digits='Product Price',
Expand Down Expand Up @@ -59,6 +62,7 @@ class ProductTemplate(models.Model):
)
replenishment_base_cost_on_currency = fields.Float(
compute='_compute_replenishment_cost',
compute_sudo=True, #chequear
help='Replenishment cost on replenishment base cost currency',
digits='Product Price',
)
Expand Down Expand Up @@ -184,17 +188,20 @@ def _compute_replenishment_cost_last_update(self):
'supplier_currency_id',
'replenishment_cost_type',
'replenishment_base_cost',
# beccause field is not stored anymore we only keep currency and
# rule
# 'replenishment_base_cost_currency_id',
# # because of being stored
'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',
# rule items
'replenishment_cost_rule_id.item_ids.sequence',
'replenishment_cost_rule_id.item_ids.percentage_amount',
'replenishment_cost_rule_id.item_ids.fixed_amount',
'replenishment_base_cost_currency_id',
'replenishment_cost_rule_id',
# 45640 depends en replenishment cost
# # beccause field is not stored anymore we only keep currency and
# # rule
# # 'replenishment_base_cost_currency_id',
# # # because of being stored
# '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',
# # rule items
# 'replenishment_cost_rule_id.item_ids.sequence',
# 'replenishment_cost_rule_id.item_ids.percentage_amount',
# 'replenishment_cost_rule_id.item_ids.fixed_amount',
)
@api.depends_context('company')
def _compute_replenishment_cost(self):
Expand Down