Skip to content

Commit

Permalink
[FIX] shopinvader_sale_configurator_option: Fix bug on shopinvader pr…
Browse files Browse the repository at this point in the history
…ice computation when using pricelist discount policy without_discount
  • Loading branch information
paradoxxxzero committed Jan 13, 2022
1 parent 7686ca6 commit a870f61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion shopinvader_sale_configurator_option/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ def _compute_shopinvader_price(self):
{
"backend_id": backend.id,
"lang_id": backend.lang_ids[0].id,
"record_id": record.id,
}
)

# Since shopinvader.variant.record_id is a Many2one inherited from
# product.product, its field is marked as delegate.
# As delegate fields get a NewId when the record is created
# (https://github.com/odoo/odoo/blob/15.0/odoo/fields.py#L2783-L2785)
# we need to disable the delegation otherwise the price computation
# will fail in case of pricelist because it considers the record.id
# to be an int:
# https://github.com/odoo/odoo/blob/15.0/addons/product/models/product_pricelist.py#L94 # noqa

old_delegate = shopinvader_variant._fields["record_id"].delegate
shopinvader_variant._fields["record_id"].delegate = False
shopinvader_variant["record_id"] = record.id
shopinvader_variant._fields["record_id"].delegate = old_delegate

record.shopinvader_price = shopinvader_variant.price

0 comments on commit a870f61

Please sign in to comment.