mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[IMP] intrastat_base: A lot of imps:
* Add product_origin_country_id on declaration/computation lines Copy incoterms and destination country from SO to invoice when invoicing from SO We need weight even when supplementary units is used Small cleanups and enhancements * Add support for accessory costs Add default values for intrastat transaction on company Code cleanup * If rounded weight is 0, put 1 Take into account the taxes for B2C Small code cleanup * Remove field exclude_from_intrastat Re-organise view of intrastat.product.declaration * Add option intrastat_accessory_costs on company Set more fields as invisible (localisation should put them visible if they need it) Fix handling of suppl. units when hs_code is empty on invoice line (but set on product) Small usability enhancements * Warning -> UserError * Inspired by the PR https://github.com/akretion/account-financial-reporting/pull/8 of Luc de Meyer * total_amount is a sum of integers, so it should be an integer Add transport mode in computation tree view * Demo VAT number should be on EU customers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat base module for Odoo
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<field name="supplier">True</field>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_5" model="res.partner"> <!-- Ecole de Commerce de Liege -->
|
||||
<record id="base.res_partner_24" model="res.partner"> <!-- OpenCorp -->
|
||||
<field name="vat">BE0443167858</field>
|
||||
<field name="supplier">True</field>
|
||||
</record>
|
||||
|
||||
@@ -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 <alexis.delattre@akretion.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_country
|
||||
from . import product_template
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat base module for Odoo
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat base module for Odoo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat base module for Odoo
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2011-2014 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2011-2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
@@ -16,7 +16,8 @@
|
||||
<field name="inherit_id" ref="account.view_tax_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="active" position="after">
|
||||
<field name="exclude_from_intrastat_if_present" />
|
||||
<!-- Will be set visible in the localisation modules that need it -->
|
||||
<field name="exclude_from_intrastat_if_present" invisible="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<!-- Menu entries for Intrastat -->
|
||||
<menuitem id="menu_intrastat_base_root"
|
||||
name="Intrastat Reporting"
|
||||
name="Intrastat"
|
||||
parent="account.menu_finance_legal_statement"/>
|
||||
<menuitem id="menu_intrastat_config_root" name="Intrastat"
|
||||
parent="account.menu_finance_configuration" sequence="50"/>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<group name="properties" position="after">
|
||||
<group string="Intrastat Properties" name="intrastat">
|
||||
<field name="exclude_from_intrastat" />
|
||||
<field name="is_accessory_cost"
|
||||
attrs="{'invisible': [('type', '!=', 'service')]}"/>
|
||||
attrs="{'invisible': [('type', '!=', 'service')]}"
|
||||
invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user