[FIX] repair: handle uom without view exposure
Previous fix https://github.com/odoo/odoo/commit/72dff43a4da277b002966f5fd4045b7f9a3855ad re-exposed uoms in the view even if the setting is not active, but we prefer to avoid this if possible. In order to do this we ensure that the uom is set even if it is not visible in the view. Most of these are already handled by compute methods, but except for `repair.fee` so we only add in a guarantee for that model. Note that the write case is included in cases when: - the uoms were previously activated and set => deactivated again - demo data has different uoms set and uoms setting is not active X-original-commit: 7e64ebb3d8d3f3d3749304a325eb073777b129dc Part-of: odoo/odoo#104900
This commit is contained in:
@@ -816,7 +816,10 @@ class RepairFee(models.Model):
|
||||
domain="[('type', '=', 'service'), '|', ('company_id', '=', company_id), ('company_id', '=', False)]")
|
||||
product_uom_qty = fields.Float('Quantity', digits='Product Unit of Measure', required=True, default=1.0)
|
||||
price_unit = fields.Float('Unit Price', required=True, digits='Product Price')
|
||||
product_uom = fields.Many2one('uom.uom', 'Product Unit of Measure', required=True, domain="[('category_id', '=', product_uom_category_id)]")
|
||||
product_uom = fields.Many2one(
|
||||
'uom.uom', 'Product Unit of Measure',
|
||||
compute='_compute_product_uom', store=True, readonly=False, precompute=True,
|
||||
required=True, domain="[('category_id', '=', product_uom_category_id)]")
|
||||
product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id')
|
||||
price_subtotal = fields.Float('Subtotal', compute='_compute_price_total_and_subtotal', store=True, digits=0)
|
||||
price_total = fields.Float('Total', compute='_compute_price_total_and_subtotal', store=True, digits=0)
|
||||
@@ -833,6 +836,11 @@ class RepairFee(models.Model):
|
||||
fee.price_subtotal = taxes['total_excluded']
|
||||
fee.price_total = taxes['total_included']
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_product_uom(self):
|
||||
for fee in self:
|
||||
fee.product_uom = fee.product_id.uom_id
|
||||
|
||||
@api.onchange('repair_id', 'product_id', 'product_uom_qty')
|
||||
def onchange_product_id(self):
|
||||
""" On change of product it sets product quantity, tax account, name,
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
<label for="product_qty"/>
|
||||
<div class="o_row">
|
||||
<field name="product_qty" attrs="{'readonly':[('tracking', '=', 'serial')]}"/>
|
||||
<field name="product_uom" invisible="1" groups="!uom.group_uom"/>
|
||||
<field name="product_uom" groups="uom.group_uom"/>
|
||||
</div>
|
||||
<field name="partner_id" widget="res_partner_many2one" attrs="{'required':[('invoice_method','!=','none')]}" context="{'res_partner_search_mode': 'customer', 'show_vat': True}"/>
|
||||
@@ -119,7 +118,6 @@
|
||||
<label for="product_uom_qty"/>
|
||||
<div class="o_row">
|
||||
<field name="product_uom_qty"/>
|
||||
<field name="product_uom" invisible="1" groups="!uom.group_uom"/>
|
||||
<field name="product_uom" groups="uom.group_uom"/>
|
||||
</div>
|
||||
<field name="price_unit"/>
|
||||
@@ -150,7 +148,6 @@
|
||||
<field name="location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations" optional="show"/>
|
||||
<field name="location_dest_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations" optional="show"/>
|
||||
<field name="product_uom_qty" string="Quantity"/>
|
||||
<field name="product_uom" invisible="1" groups="!uom.group_uom"/>
|
||||
<field name="product_uom" string="UoM" groups="uom.group_uom" optional="show"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="tax_id" widget="many2many_tags" optional="show"/>
|
||||
@@ -182,7 +179,6 @@
|
||||
<label for="product_uom_qty"/>
|
||||
<div class="o_row">
|
||||
<field name="product_uom_qty" string="Quantity"/>
|
||||
<field name="product_uom" invisible="1" groups="!uom.group_uom"/>
|
||||
<field name="product_uom" groups="uom.group_uom"/>
|
||||
</div>
|
||||
<field name="price_unit"/>
|
||||
@@ -197,7 +193,6 @@
|
||||
<field name='name' optional="show"/>
|
||||
<field name="product_uom_qty" string="Quantity"/>
|
||||
<field name="product_uom_category_id" invisible="1"/>
|
||||
<field name="product_uom" invisible="1" groups="!uom.group_uom"/>
|
||||
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom" optional="show"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="tax_id" widget="many2many_tags" optional="show"/>
|
||||
|
||||
Reference in New Issue
Block a user