From 9fe090148e11080a4f5183e31269247afd003408 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 5 Jun 2012 15:04:00 +0200 Subject: [PATCH] Add option "is_accessory_cost" on product.template : If the invoice has is_accessory_cost services but no regular product -> DES If the invoice has is_accessory_cost services and regular product -> added to the cost of products in DEB Now allows "pricelist for statistical value" which is not in EUR (the currency conversion will be made from the pricelist currency to EUR) Usability improvements : - Order for DEB and DES tree view : "the more recent at the top" - distinction between "Information to declare" and "Additionnal information" in intrastat lines --- intrastat_base/intrastat_demo.xml | 2 +- intrastat_base/product.py | 15 ++++++++++++++- intrastat_base/product_view.xml | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) 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 @@ + + +