[FIX] purchase: "product_type" related field on po line

Issue:
Currently, since "product_type" is not set readonly, it is triggering write() of product.product
model when saving a PO having PO line with product_id. And it is failing by throwing access error
for users belonging to purchase "User" group users due to the fact that write() is permissible to
purchase "Manager" group users only.

Solution:
Made the "product_type" related field readonly since it is used in purchase order views domain
with lone purpose to set "received_qty" field non-editable when order line product is of type
stockable/consumable.

task id 1818787
This commit is contained in:
Kinjal Mehta
2018-04-16 16:00:46 +02:00
committed by Simon Lejeune
parent cc583a4ab2
commit 026be48ccb
+1 -1
View File
@@ -647,7 +647,7 @@ class PurchaseOrderLine(models.Model):
product_image = fields.Binary(
'Product Image', related="product_id.image",
help="Non-stored related field to allow portal user to see the image of the product he has ordered")
product_type = fields.Selection(related='product_id.type')
product_type = fields.Selection(related='product_id.type', readonly=True)
move_ids = fields.One2many('stock.move', 'purchase_line_id', string='Reservation', readonly=True, ondelete='set null', copy=False)
price_unit = fields.Float(string='Unit Price', required=True, digits=dp.get_precision('Product Price'))