[FIX] product: Correct ID retrieval in contact price list calculation when changing province
How to reproduce the error:
1. Go to Contacts.
2. Select a Contact of Type Company:
Find and select a contact that is a company type and to which a
price list has already been set up previously.
In case no price list has been set previously, set the price list
and save the contact.
3. Edit the contact and modify the address state without the need to
save the changes.
4. View the PriceList:
After changing the province, look at the price list field. You can
verify that the price list has become blank immediately after making
the change in state, without the need to save the changes.
Current behaviour: the price list is deleted when the state of the address is changed.
Expected behaviour: keep the previously set price list.
Explanation:
The code was incorrectly using "p.id" instead of "p._origin.id" to get
the contact ID. This resulted in a non-existent key being retrieved and
caused the loss of the price list in the contact when changing the province.
The fix adjusts the code to correctly use "p._origin.id", ensuring correct
retrieval of the ID and avoiding unwanted changes to the price list.
Example of data obtained by debugging:
- Edited user: Deco Addict
- Data obtained in "res": res {53: product.pricelist(1,)}
- Data retrieved in "p.id": (p.id) > NewId_53
- Data retrieved at "p._origin.id": (p._origin.id) > 53
TT47536
closes odoo/odoo#153326
X-original-commit: 570715ecc6c9b105a2edaed23a68f557e5cf1987
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
committed by
Victor Feyens
parent
3d8be5aa4c
commit
b3ce733937
@@ -22,7 +22,7 @@ class ResPartner(models.Model):
|
||||
def _compute_product_pricelist(self):
|
||||
res = self.env['product.pricelist']._get_partner_pricelist_multi(self.ids)
|
||||
for partner in self:
|
||||
partner.property_product_pricelist = res.get(partner.id)
|
||||
partner.property_product_pricelist = res.get(partner._origin.id)
|
||||
|
||||
def _inverse_product_pricelist(self):
|
||||
for partner in self:
|
||||
|
||||
Reference in New Issue
Block a user