diff --git a/intrastat_base/intrastat_demo.xml b/intrastat_base/intrastat_demo.xml
index 7965c6d..d83640e 100644
--- a/intrastat_base/intrastat_demo.xml
+++ b/intrastat_base/intrastat_demo.xml
@@ -50,7 +50,7 @@
service
30
- False
+ True
diff --git a/intrastat_base/product.py b/intrastat_base/product.py
index 38cbcb7..0f29a02 100644
--- a/intrastat_base/product.py
+++ b/intrastat_base/product.py
@@ -2,7 +2,7 @@
##############################################################################
#
# Report intrastat base module for OpenERP
-# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved
+# Copyright (C) 2010-2012 Akretion (http://www.akretion.com/) All Rights Reserved
# @author Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
@@ -21,16 +21,29 @@
##############################################################################
from osv import osv, fields
+from tools.translate import _
class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'exclude_from_intrastat': fields.boolean('Exclude from Intrastat reports', help="If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason."),
+ 'is_accessory_cost' : fields.boolean('Is accessory cost?', help='Activate this option for shipping costs, packaging costs and all services related to the sale of product. This option is used for Intrastat reports.'),
}
_default = {
'exclude_from_intrastat': lambda *a: False,
}
+
+ def _check_accessory_cost(self, cr, uid, ids):
+ for product in self.browse(cr, uid, ids):
+ if product.is_accessory_cost and product.type != 'service':
+ raise osv.except_osv(_('Error :'), _("The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'" % (product.name, product.type)))
+ return True
+
+ _constraints = [
+ (_check_accessory_cost, "Error msg is in raise", ['is_accessory_cost', 'type'])
+ ]
+
product_template()
diff --git a/intrastat_base/product_view.xml b/intrastat_base/product_view.xml
index cd7aefd..28b026e 100644
--- a/intrastat_base/product_view.xml
+++ b/intrastat_base/product_view.xml
@@ -22,6 +22,9 @@
+
+
+
@@ -39,6 +42,9 @@
+
+
+