change behaviour of property_product_pricelist (constraint)
parent
e8422d089f
commit
c25a9ea2cc
|
|
@ -80,7 +80,7 @@ class Partner(models.Model):
|
|||
|
||||
# make pricelist searchable (store=True) --> code copied from: \ext\odoo\addons\product\models\res_partner.py!
|
||||
property_product_pricelist = fields.Many2one(
|
||||
'product.pricelist', 'Sale Pricelist', compute='_compute_product_pricelist', store=True, required=True, default=1,
|
||||
'product.pricelist', 'Sale Pricelist', compute='_compute_product_pricelist', store=True, default=1,
|
||||
inverse="_inverse_product_pricelist", company_dependent=False, # NOT A REAL PROPERTY
|
||||
help="This pricelist will be used, instead of the default one, for sales to the current partner")
|
||||
|
||||
|
|
@ -89,6 +89,14 @@ class Partner(models.Model):
|
|||
('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein')
|
||||
]
|
||||
|
||||
@api.multi
|
||||
@api.constrains('property_product_pricelist')
|
||||
def _check_property_product_pricelist(self):
|
||||
for record in self:
|
||||
if not record.parent_id.id and not record.property_product_pricelist:
|
||||
# Here we have to set partner_id.property_product_pricelist if it es empty and a parent_id is existing - else we rise an error
|
||||
raise ValidationError(_("Ungültige Preisliste!"))
|
||||
|
||||
@api.multi
|
||||
def _get_warn_date(self):
|
||||
for record in self:
|
||||
|
|
|
|||
Loading…
Reference in New Issue