Skip to content
Permalink
Browse files

[FIX] repair: price and UoM

- Activate multiple UoM
- Create a Repair Order
- Add a repair line ('Parts') of type 'Add', change the UoM
  => the unit price is not modified
- Add a repair fee ('Operations'), change the UoM
  => the unit price is not modified

The UoM is never taken into account.

opw-1953752
  • Loading branch information...
nim-odoo committed Mar 26, 2019
1 parent f5e9906 commit 391475ad333bb66d4b67109224a35c58bc71fec4
Showing with 24 additions and 13 deletions.
  1. +24 −13 addons/repair/models/repair.py
@@ -598,18 +598,24 @@ def onchange_product_id(self):
'title': _('No pricelist found.'),
'message':
_('You have to select a pricelist in the Repair form !\n Please set one before choosing a product.')}
else:
price = pricelist.get_product_price(self.product_id, self.product_uom_qty, partner)
if price is False:
warning = {
'title': _('No valid pricelist line found.'),
'message':
_("Couldn't find a pricelist line matching this product and quantity.\nYou have to change either the product, the quantity or the pricelist.")}
else:
self.price_unit = price
if warning:
return {'warning': warning}

@api.onchange('product_uom')
def _onchange_product_uom(self):
partner = self.repair_id.partner_id
pricelist = self.repair_id.pricelist_id
if pricelist and self.product_id and self.type != 'remove':
price = pricelist.get_product_price(self.product_id, self.product_uom_qty, partner, uom_id=self.product_uom.id)
if price is False:
warning = {
'title': _('No valid pricelist line found.'),
'message':
_("Couldn't find a pricelist line matching this product and quantity.\nYou have to change either the product, the quantity or the pricelist.")}
return {'warning': warning}
else:
self.price_unit = price


class RepairFee(models.Model):
_name = 'repair.fee'
@@ -658,14 +664,19 @@ def onchange_product_id(self):
'title': _('No pricelist found.'),
'message':
_('You have to select a pricelist in the Repair form !\n Please set one before choosing a product.')}
else:
price = pricelist.get_product_price(self.product_id, self.product_uom_qty, partner)
return {'warning': warning}

@api.onchange('product_uom')
def _onchange_product_uom(self):
partner = self.repair_id.partner_id
pricelist = self.repair_id.pricelist_id
if pricelist and self.product_id:
price = pricelist.get_product_price(self.product_id, self.product_uom_qty, partner, uom_id=self.product_uom.id)
if price is False:
warning = {
'title': _('No valid pricelist line found.'),
'message':
_("Couldn't find a pricelist line matching this product and quantity.\nYou have to change either the product, the quantity or the pricelist.")}
return {'warning': warning}
else:
self.price_unit = price
if warning:
return {'warning': warning}

0 comments on commit 391475a

Please sign in to comment.
You can’t perform that action at this time.