[IMP] event_sale: make product_uom readonly on so lines
Specifications -------------- Updating the uom of Sales Order Lines related to an event (selling event tickets) should be avoided because it doesn't have any sense and wouldn't work correctly if changed. Note: As the product_uom field is already readonly according to the SO state, introduce a new field on the 'sale' application to handle the different behaviors server side instead of multiplicating the view overrides. task-2178371 Closes #44818 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Yannick Tivisse
parent
a1e87bbf23
commit
b657463d56
@@ -65,6 +65,12 @@ class SaleOrderLine(models.Model):
|
||||
help="Choose an event ticket and it will automatically create a registration for this event ticket.")
|
||||
event_ok = fields.Boolean(related='product_id.event_ok', readonly=True)
|
||||
|
||||
@api.depends('state', 'event_id')
|
||||
def _compute_product_uom_readonly(self):
|
||||
event_lines = self.filtered(lambda line: line.event_id)
|
||||
event_lines.update({'product_uom_readonly': True})
|
||||
super(SaleOrderLine, self - event_lines)._compute_product_uom_readonly()
|
||||
|
||||
def _update_registrations(self, confirm=True, cancel_to_draft=False, registration_data=None, mark_as_paid=False):
|
||||
""" Create or update registrations linked to a sales order line. A sale
|
||||
order line has a product_uom_qty attribute that will be the number of
|
||||
|
||||
@@ -1231,6 +1231,7 @@ class SaleOrderLine(models.Model):
|
||||
product_uom_qty = fields.Float(string='Quantity', digits='Product Unit of Measure', required=True, default=1.0)
|
||||
product_uom = fields.Many2one('uom.uom', string='Unit of Measure', domain="[('category_id', '=', product_uom_category_id)]")
|
||||
product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id', readonly=True)
|
||||
product_uom_readonly = fields.Boolean(compute='_compute_product_uom_readonly')
|
||||
product_custom_attribute_value_ids = fields.One2many('product.attribute.custom.value', 'sale_order_line_id', string="Custom Values")
|
||||
|
||||
# M2M holding the values of product.attribute with create_variant field set to 'no_variant'
|
||||
@@ -1282,6 +1283,11 @@ class SaleOrderLine(models.Model):
|
||||
('line_section', "Section"),
|
||||
('line_note', "Note")], default=False, help="Technical field for UX purpose.")
|
||||
|
||||
@api.depends('state')
|
||||
def _compute_product_uom_readonly(self):
|
||||
for line in self:
|
||||
line.product_uom_readonly = line.state in ['sale', 'done', 'cancel']
|
||||
|
||||
@api.depends('state', 'is_expense')
|
||||
def _compute_qty_delivered_method(self):
|
||||
""" Sale module compute delivered qty for product [('type', 'in', ['consu']), ('service_type', '=', 'manual')]
|
||||
|
||||
@@ -372,6 +372,7 @@
|
||||
<field name="price_total" invisible="1"/>
|
||||
<field name="price_tax" invisible="1"/>
|
||||
<field name="price_subtotal" invisible="1"/>
|
||||
<field name="product_uom_readonly" invisible="1"/>
|
||||
<label for="product_uom_qty"/>
|
||||
<div class="o_row" name="ordered_qty">
|
||||
<field
|
||||
@@ -383,7 +384,7 @@
|
||||
groups="uom.group_uom"
|
||||
class="oe_no_button"
|
||||
attrs="{
|
||||
'readonly': [('state', 'in', ('sale', 'done', 'cancel'))],
|
||||
'readonly': [('product_uom_readonly', '=', True)],
|
||||
'required': [('display_type', '=', False)],
|
||||
}"
|
||||
/>
|
||||
@@ -523,12 +524,13 @@
|
||||
optional="show"
|
||||
/>
|
||||
<field name="qty_to_invoice" invisible="1"/>
|
||||
<field name="product_uom_readonly" invisible="1"/>
|
||||
<field
|
||||
name="product_uom"
|
||||
force_save="1"
|
||||
string="UoM"
|
||||
attrs="{
|
||||
'readonly': [('state', 'in', ('sale','done', 'cancel'))],
|
||||
'readonly': [('product_uom_readonly', '=', True)],
|
||||
'required': [('display_type', '=', False)],
|
||||
}"
|
||||
context="{'company_id': parent.company_id}"
|
||||
|
||||
Reference in New Issue
Block a user