From 170db9e03da89fb1ffd284ccef778af6ca677879 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Wed, 5 Jul 2017 11:10:59 +0200 Subject: [PATCH] purchase: order field must be changed only in invoice draft state --- addons/purchase/models/account_invoice.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 31c1c948d5c..c1c62f32da6 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -8,8 +8,12 @@ from odoo.tools.float_utils import float_compare class AccountInvoice(models.Model): _inherit = 'account.invoice' - purchase_id = fields.Many2one('purchase.order', string='Add Purchase Order', - help='Encoding help. When selected, the associated purchase order lines are added to the vendor bill. Several PO can be selected.') + purchase_id = fields.Many2one( + comodel_name='purchase.order', + string='Add Purchase Order', + readonly=True, states={'draft': [('readonly', False)]}, + help='Encoding help. When selected, the associated purchase order lines are added to the vendor bill. Several PO can be selected.' + ) @api.onchange('state', 'partner_id', 'invoice_line_ids') def _onchange_allowed_purchase_ids(self):