From 350ff8cfc33b9415f7698725cdcf450b0194a2e0 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 4 Nov 2015 16:49:42 +0100 Subject: [PATCH] [FIX] sale_stock: make related field `product_tmpl_id` on `sale.order.line` readonly This prevents an access right error when saving a sales order after changing its delivery method. The latter updates sale order lines by an onchange, which causes the unexpected update on the field. --- addons/sale_stock/sale_stock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 0ad7d95a6f1..5bc73ebdce9 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -92,7 +92,7 @@ class SaleOrderLine(models.Model): product_packaging = fields.Many2one('product.packaging', string='Packaging', default=False) route_id = fields.Many2one('stock.location.route', string='Route', domain=[('sale_selectable', '=', True)]) - product_tmpl_id = fields.Many2one('product.template', related='product_id.product_tmpl_id', string='Product Template') + product_tmpl_id = fields.Many2one('product.template', related='product_id.product_tmpl_id', string='Product Template', readonly=True) @api.multi @api.depends('product_id') @@ -119,7 +119,6 @@ class SaleOrderLine(models.Model): self.product_packaging = False return {} precision = self.env['decimal.precision'].precision_get('Product Unit of Measure') - self.product_tmpl_id = self.product_id.product_tmpl_id if self.product_id.type == 'product': product = self.product_id.with_context( lang=self.order_id.partner_id.lang,