diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py
index f50f146..a9e92b0 100644
--- a/intrastat_base/__openerp__.py
+++ b/intrastat_base/__openerp__.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
diff --git a/intrastat_base/demo/intrastat_demo.xml b/intrastat_base/demo/intrastat_demo.xml
index 953d92b..422afa8 100644
--- a/intrastat_base/demo/intrastat_demo.xml
+++ b/intrastat_base/demo/intrastat_demo.xml
@@ -18,7 +18,7 @@
True
-
+
BE0443167858
True
diff --git a/intrastat_base/models/__init__.py b/intrastat_base/models/__init__.py
index 18530f9..a571f6a 100644
--- a/intrastat_base/models/__init__.py
+++ b/intrastat_base/models/__init__.py
@@ -1,24 +1,4 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Report intrastat base module for Odoo
-# Copyright (C) 2011-2014 Akretion (http://www.akretion.com)
-# @author Alexis de Lattre
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
from . import res_country
from . import product_template
diff --git a/intrastat_base/models/account_tax.py b/intrastat_base/models/account_tax.py
index 197e51d..e11db59 100644
--- a/intrastat_base/models/account_tax.py
+++ b/intrastat_base/models/account_tax.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
diff --git a/intrastat_base/models/intrastat_common.py b/intrastat_base/models/intrastat_common.py
index ae892c0..3d44b7c 100644
--- a/intrastat_base/models/intrastat_common.py
+++ b/intrastat_base/models/intrastat_common.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
@@ -21,8 +21,7 @@
##############################################################################
from openerp import models, fields, api, tools, _
-from openerp.exceptions import Warning, ValidationError
-from dateutil.relativedelta import relativedelta
+from openerp.exceptions import Warning as UserError
import logging
logger = logging.getLogger(__name__)
@@ -36,7 +35,7 @@ class IntrastatCommon(models.AbstractModel):
@api.one
@api.depends('declaration_line_ids.amount_company_currency')
def _compute_numbers(self):
- total_amount = 0.0
+ total_amount = 0 # it is an integer
num_lines = 0
for line in self.declaration_line_ids:
total_amount += line.amount_company_currency
@@ -44,34 +43,18 @@ class IntrastatCommon(models.AbstractModel):
self.num_decl_lines = num_lines
self.total_amount = total_amount
- @api.one
- @api.depends('start_date')
- def _compute_dates(self):
- start_date_dt = fields.Date.from_string(self.start_date)
- self.end_date = fields.Date.to_string(
- start_date_dt + relativedelta(day=31))
- self.year_month = start_date_dt.strftime('%Y-%m')
-
- @api.one
- def _check_start_date(self):
- '''Check that the start date is the first day of the month'''
- datetime_to_check = fields.Date.from_string(self.start_date)
- if datetime_to_check.day != 1:
- raise ValidationError(
- _('The start date must be the first day of the month'))
-
@api.one
def _check_generate_lines(self):
"""Check wether all requirements are met for generating lines."""
if not self.company_id:
- raise Warning(_("Company not yet set on intrastat report."))
+ raise UserError(_("Company not yet set on intrastat report."))
company_obj = self.company_id
if not company_obj.country_id:
- raise Warning(
+ raise UserError(
_("The country is not set on the company '%s'.")
% company_obj.name)
if company_obj.currency_id.name != 'EUR':
- raise Warning(
+ raise UserError(
_("The company currency must be 'EUR', but is currently '%s'.")
% company_obj.currency_id.name)
return True
@@ -79,7 +62,7 @@ class IntrastatCommon(models.AbstractModel):
@api.one
def _check_generate_xml(self):
if not self.company_id.partner_id.vat:
- raise Warning(
+ raise UserError(
_("The VAT number is not set for the partner '%s'.")
% self.company_id.partner_id.name)
return True
@@ -102,7 +85,7 @@ class IntrastatCommon(models.AbstractModel):
"The XML file is invalid against the XML Schema Definition")
logger.warning(xml_string)
logger.warning(e)
- raise Warning(
+ raise UserError(
_("The generated XML file is not valid against the official "
"XML Schema Definition. The generated XML file and the "
"full error have been written in the server logs. "
@@ -181,7 +164,7 @@ class IntrastatCommon(models.AbstractModel):
def unlink(self):
for intrastat in self:
if intrastat.state == 'done':
- raise Warning(
+ raise UserError(
_('Cannot delete the declaration %s '
'because it is in Done state') % self.year_month)
return super(IntrastatCommon, self).unlink()
diff --git a/intrastat_base/models/product_template.py b/intrastat_base/models/product_template.py
index 5373cb3..30132bc 100644
--- a/intrastat_base/models/product_template.py
+++ b/intrastat_base/models/product_template.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
@@ -27,12 +27,6 @@ from openerp.exceptions import ValidationError
class ProductTemplate(models.Model):
_inherit = "product.template"
- exclude_from_intrastat = fields.Boolean(
- string='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(
string='Is accessory cost',
help="Activate this option for shipping costs, packaging "
diff --git a/intrastat_base/models/res_company.py b/intrastat_base/models/res_company.py
index 2206c76..1175d76 100644
--- a/intrastat_base/models/res_company.py
+++ b/intrastat_base/models/res_company.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
diff --git a/intrastat_base/models/res_country.py b/intrastat_base/models/res_country.py
index 7a34e77..8703f10 100644
--- a/intrastat_base/models/res_country.py
+++ b/intrastat_base/models/res_country.py
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat base module for Odoo
diff --git a/intrastat_base/views/account_tax.xml b/intrastat_base/views/account_tax.xml
index 5defe29..1e91bb5 100644
--- a/intrastat_base/views/account_tax.xml
+++ b/intrastat_base/views/account_tax.xml
@@ -1,7 +1,7 @@
@@ -16,7 +16,8 @@
-
+
+
diff --git a/intrastat_base/views/intrastat.xml b/intrastat_base/views/intrastat.xml
index 7b4cdf7..73762d0 100644
--- a/intrastat_base/views/intrastat.xml
+++ b/intrastat_base/views/intrastat.xml
@@ -11,7 +11,7 @@
diff --git a/intrastat_base/views/product_template.xml b/intrastat_base/views/product_template.xml
index dc61ca5..1f4f73f 100644
--- a/intrastat_base/views/product_template.xml
+++ b/intrastat_base/views/product_template.xml
@@ -16,9 +16,9 @@
-
+ attrs="{'invisible': [('type', '!=', 'service')]}"
+ invisible="1"/>