mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
If rounded weight is 0, put 1
Take into account the taxes for B2C Small code cleanup
This commit is contained in:
@@ -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
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.exceptions import RedirectWarning, ValidationError, Warning
|
||||
from openerp.exceptions import RedirectWarning, ValidationError
|
||||
from openerp.exceptions import Warning as UserError
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from datetime import datetime, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
@@ -447,16 +448,39 @@ class IntrastatProductDeclaration(models.Model):
|
||||
|
||||
continue
|
||||
|
||||
intrastat = inv_line.hs_code_id
|
||||
if not intrastat:
|
||||
continue
|
||||
if not inv_line.quantity:
|
||||
continue
|
||||
if not inv_line.price_subtotal:
|
||||
continue
|
||||
|
||||
partner_country = self._get_partner_country(inv_line)
|
||||
if not partner_country:
|
||||
continue
|
||||
|
||||
if any([
|
||||
tax.exclude_from_intrastat_if_present
|
||||
for tax in inv_line.invoice_line_tax_id]):
|
||||
continue
|
||||
|
||||
if inv_line.hs_code_id:
|
||||
intrastat = inv_line.hs_code_id
|
||||
elif (
|
||||
inv_line.product_id and
|
||||
inv_line.product_id.type in ('product', 'consu')):
|
||||
intrastat = inv_line.product_id.product_tmpl_id.\
|
||||
get_hs_code_recursively()
|
||||
if not intrastat:
|
||||
note = "\n" + _(
|
||||
'Missing H.S. code on product %s (%s). '
|
||||
'This product is present in invoice %s.') % (
|
||||
inv_line.product_id.name,
|
||||
inv_line.product_id.default_code,
|
||||
inv_line.invoice_id.number)
|
||||
self._note += note
|
||||
|
||||
if not intrastat:
|
||||
continue
|
||||
|
||||
intrastat_transaction = \
|
||||
self._get_intrastat_transaction(inv_line)
|
||||
|
||||
@@ -610,8 +634,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
xml_string, '%s_%s' % (self.type, self.revision))
|
||||
return self._open_attach_view(attach_id)
|
||||
else:
|
||||
raise Warning(
|
||||
_("Programming Error."),
|
||||
raise UserError(
|
||||
_("No XML File has been generated."))
|
||||
|
||||
@api.multi
|
||||
@@ -823,6 +846,8 @@ class IntrastatProductDeclarationLine(models.Model):
|
||||
# round, otherwise odoo with truncate (6.7 -> 6... instead of 7 !)
|
||||
for field in fields_to_sum:
|
||||
vals[field] = int(round(vals[field]))
|
||||
if not vals['weight']:
|
||||
vals['weight'] = 1
|
||||
vals['amount_company_currency'] = int(round(
|
||||
vals['amount_company_currency']))
|
||||
return vals
|
||||
|
||||
@@ -37,9 +37,9 @@ class StockLocation(models.Model):
|
||||
@api.multi
|
||||
def get_intrastat_region(self):
|
||||
self.ensure_one()
|
||||
locations = location.search(
|
||||
[('parent_left', '<=', location.parent_left),
|
||||
('parent_right', '>=', location.parent_right)])
|
||||
locations = self.search(
|
||||
[('parent_left', '<=', self.parent_left),
|
||||
('parent_right', '>=', self.parent_right)])
|
||||
warehouses = self.search(
|
||||
[('lot_stock_id', 'in', [x.id for x in locations]),
|
||||
('region_id', '!=', False)])
|
||||
|
||||
Reference in New Issue
Block a user