Add constraint
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
class ProductTemplate(orm.Model):
|
class ProductTemplate(orm.Model):
|
||||||
@@ -24,6 +25,28 @@ class ProductTemplate(orm.Model):
|
|||||||
'intrastat_type': 'product',
|
'intrastat_type': 'product',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _check_intrastat_product(self, cr, uid, ids):
|
||||||
|
for pt in self.browse(cr, uid, ids):
|
||||||
|
if pt.intrastat_type == 'product' and pt.type == 'service':
|
||||||
|
raise orm.except_orm(
|
||||||
|
_("Error"),
|
||||||
|
_("On the product %s, you cannot set Product Type to "
|
||||||
|
"'Service' and Intrastat Type to 'Product'.") % pt.name)
|
||||||
|
if pt.intrastat_type == 'service' and pt.type == 'product':
|
||||||
|
raise orm.except_orm(
|
||||||
|
_("Error"),
|
||||||
|
_("On the product %s, you cannot set Intrastat Type to "
|
||||||
|
"'Service' and Product Type to 'Stockable product' "
|
||||||
|
"(but you can set Product Type to 'Consumable' or "
|
||||||
|
"'Service').") % pt.name)
|
||||||
|
return True
|
||||||
|
|
||||||
|
_constraints = [(
|
||||||
|
_check_intrastat_product,
|
||||||
|
'error msg in raise',
|
||||||
|
['type', 'intrastat_type'],
|
||||||
|
)]
|
||||||
|
|
||||||
|
|
||||||
class ReportIntrastatCommon(orm.Model):
|
class ReportIntrastatCommon(orm.Model):
|
||||||
_inherit = "report.intrastat.common"
|
_inherit = "report.intrastat.common"
|
||||||
|
|||||||
Reference in New Issue
Block a user