[FIX][IMP] purchase: set purchase_warn as non required
When reinitializing modules it is impossible to create partners if purchase is installed because purchase_warn field has a required column but no default value if the module does not depend from purchase. Use case is trying to run test_mail tests with purchase installed. As this field is not business critical it is now not required. As there is a default value behavior should not change for users. See also71181a0e39,dd47abdcc3and06a02ae4c2.
This commit is contained in:
@@ -261,7 +261,7 @@ class PurchaseOrder(models.Model):
|
||||
if partner.purchase_warn == 'no-message' and partner.parent_id:
|
||||
partner = partner.parent_id
|
||||
|
||||
if partner.purchase_warn != 'no-message':
|
||||
if partner.purchase_warn and partner.purchase_warn != 'no-message':
|
||||
# Block if partner only has warning but parent company is blocked
|
||||
if partner.purchase_warn != 'block' and partner.parent_id and partner.parent_id.purchase_warn == 'block':
|
||||
partner = partner.parent_id
|
||||
|
||||
@@ -26,5 +26,5 @@ class res_partner(models.Model):
|
||||
help="This currency will be used, instead of the default one, for purchases from the current partner")
|
||||
purchase_order_count = fields.Integer(compute='_purchase_invoice_count', string='Purchase Order Count')
|
||||
supplier_invoice_count = fields.Integer(compute='_purchase_invoice_count', string='# Vendor Bills')
|
||||
purchase_warn = fields.Selection(WARNING_MESSAGE, 'Purchase Order', help=WARNING_HELP, required=True, default="no-message")
|
||||
purchase_warn = fields.Selection(WARNING_MESSAGE, 'Purchase Order', help=WARNING_HELP, default="no-message")
|
||||
purchase_warn_msg = fields.Text('Message for Purchase Order')
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<separator string="Warning on the Purchase Order" colspan="4"/>
|
||||
<field name="purchase_warn" nolabel="1" />
|
||||
<field name="purchase_warn_msg" colspan="3" nolabel="1"
|
||||
attrs="{'required':[('purchase_warn','!=','no-message')],'readonly':[('purchase_warn','=','no-message')]}"/>
|
||||
attrs="{'required':[('purchase_warn', '!=', False), ('purchase_warn','!=','no-message')],'readonly':[('purchase_warn','=','no-message')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user