[MIG] l10n_be_intrastat : Migrated to new API.

This commit is contained in:
Rohan Patel
2016-07-07 15:27:25 +02:00
committed by Yannick Tivisse
parent c85732dd57
commit 320ff7250b
12 changed files with 154 additions and 228 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import models
import wizard
+1 -3
View File
@@ -1,9 +1,8 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Belgian Intrastat Declaration',
'version': '1.0',
'category': 'Localization',
'description': """
Generates Intrastat XML report for declaration
@@ -20,5 +19,4 @@ Based on invoices.
'views/l10n_be_intrastat_view.xml',
'wizard/l10n_be_intrastat_declaration_view.xml',
],
'installable': True,
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_region_1" model="l10n_be_intrastat.region">
<field name="code">1</field>
@@ -20,4 +20,4 @@
<field name="description">Includes 19 districts</field>
</record>
</data>
</openerp>
</odoo>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_transaction_1" model="l10n_be_intrastat.transaction">
<field name="code">1</field>
@@ -38,4 +38,4 @@
<field name="description">Other transactions which cannot be classified under other codes</field>
</record>
</data>
</openerp>
</odoo>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">
<record id="l10n_be_intrastat.intrastat_trmode_1" model="l10n_be_intrastat.transport_mode">
<field name="code">1</field>
@@ -34,4 +34,4 @@
<field name="name">Own propulsion (imported or exported means of transport crossing the border under their own power, e.g. aircraft, lorries, boats, etc.)</field>
</record>
</data>
</openerp>
</odoo>
+1 -1
View File
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import l10n_be_intrastat
@@ -1,144 +1,139 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import fields, models, api
from odoo import api, fields, models
class account_invoice_line(models.Model):
class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
intrastat_transaction_id = fields.Many2one('l10n_be_intrastat.transaction', 'Intrastat Transaction Type',
intrastat_transaction_id = fields.Many2one('l10n_be_intrastat.transaction', string='Intrastat Transaction Type',
help="Intrastat nature of transaction")
class account_invoice(models.Model):
class AccountInvoice(models.Model):
_inherit = "account.invoice"
incoterm_id = fields.Many2one('stock.incoterms', 'Incoterm',
incoterm_id = fields.Many2one('stock.incoterms', string='Incoterm',
help="International Commercial Terms are a series of predefined commercial terms "
"used in international transactions.")
transport_mode_id = fields.Many2one('l10n_be_intrastat.transport_mode', 'Intrastat Transport Mode')
intrastat_country_id = fields.Many2one('res.country', 'Intrastat Country',
transport_mode_id = fields.Many2one('l10n_be_intrastat.transport_mode', string='Intrastat Transport Mode')
intrastat_country_id = fields.Many2one('res.country', string='Intrastat Country',
help='Intrastat country, delivery for sales, origin for purchases',
domain=[('intrastat', '=', True)])
class intrastat_region(models.Model):
class IntrastatRegion(models.Model):
_name = 'l10n_be_intrastat.region'
code = fields.Char('Code', required=True)
country_id = fields.Many2one('res.country', 'Country')
name = fields.Char('Name', translate=True)
description = fields.Char('Description')
code = fields.Char(required=True)
country_id = fields.Many2one('res.country', string='Country')
name = fields.Char(translate=True)
description = fields.Char()
_sql_constraints = [
('l10n_be_intrastat_regioncodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class intrastat_transaction(models.Model):
class IntrastatTransaction(models.Model):
_name = 'l10n_be_intrastat.transaction'
_rec_name = 'code'
code = fields.Char('Code', required=True, readonly=True)
description = fields.Text('Description', readonly=True)
code = fields.Char(required=True, readonly=True)
description = fields.Text(readonly=True)
_sql_constraints = [
('l10n_be_intrastat_trcodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class intrastat_transport_mode(models.Model):
class IntrastatTransportMode(models.Model):
_name = 'l10n_be_intrastat.transport_mode'
code = fields.Char('Code', required=True, readonly=True)
name = fields.Char('Description', readonly=True)
code = fields.Char(required=True, readonly=True)
name = fields.Char(string='Description', readonly=True)
_sql_constraints = [
('l10n_be_intrastat_trmodecodeunique', 'UNIQUE (code)', 'Code must be unique.'),
]
class product_category(models.Model):
_name = "product.category"
class ProductCategory(models.Model):
_inherit = "product.category"
intrastat_id = fields.Many2one('report.intrastat.code', 'Intrastat Code')
intrastat_id = fields.Many2one('report.intrastat.code', string='Intrastat Code')
@api.multi
def get_intrastat_recursively(self):
""" Recursively search in categories to find an intrastat code id
"""
res = None
if self.intrastat_id:
res = self.intrastat_id.id
elif self.parent_id:
res = self.parent_id.get_intrastat_recursively()
else:
res = None
return res
class product_product(models.Model):
_name = "product.product"
class ProductProduct(models.Model):
_inherit = "product.product"
@api.multi
def get_intrastat_recursively(self):
""" Recursively search in categories to find an intrastat code id
"""
res = None
if self.intrastat_id:
res = self.intrastat_id.id
elif self.categ_id:
res = self.categ_id.get_intrastat_recursively()
else:
res = None
return res
class purchase_order(models.Model):
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
def _prepare_invoice(self):
"""
copy incoterm from purchase order to invoice
"""
invoice = super(purchase_order, self)._prepare_invoice()
invoice = super(PurchaseOrder, self)._prepare_invoice()
if self.incoterm_id:
invoice['incoterm_id'] = self.incoterm_id.id
#Try to determine products origin
if self.partner_id.country_id:
#It comes from vendor
invoice['intrastat_country_id'] = self.partner_id.country_id.id
return invoice
class report_intrastat_code(models.Model):
class ReportIntrastatCode(models.Model):
_inherit = "report.intrastat.code"
description = fields.Text('Description', translate=True)
description = fields.Text(string='Description', translate=True)
class res_company(models.Model):
class ResCompany(models.Model):
_inherit = "res.company"
region_id = fields.Many2one('l10n_be_intrastat.region', 'Intrastat region')
region_id = fields.Many2one('l10n_be_intrastat.region', string='Intrastat region')
transport_mode_id = fields.Many2one('l10n_be_intrastat.transport_mode',
'Default transport mode')
incoterm_id = fields.Many2one('stock.incoterms', 'Default incoterm for Intrastat',
string='Default transport mode')
incoterm_id = fields.Many2one('stock.incoterms', string='Default incoterm for Intrastat',
help="International Commercial Terms are a series of "
"predefined commercial terms used in international "
"transactions.")
class sale_order(models.Model):
class SaleOrder(models.Model):
_inherit = "sale.order"
def _prepare_invoice(self):
"""
copy incoterm from sale order to invoice
"""
invoice = super(sale_order, self)._prepare_invoice()
invoice = super(SaleOrder, self)._prepare_invoice()
if self.incoterm:
invoice['incoterm_id'] = self.incoterm.id
# Guess products destination
@@ -151,14 +146,14 @@ class sale_order(models.Model):
return invoice
class stock_warehouse(models.Model):
class StockWarehouse(models.Model):
_inherit = "stock.warehouse"
region_id = fields.Many2one('l10n_be_intrastat.region', 'Intrastat region')
region_id = fields.Many2one('l10n_be_intrastat.region', string='Intrastat region')
def get_regionid_from_locationid(self, location):
location_ids = location.search([('parent_left', '<=', location.parent_left), ('parent_right', '>=', location.parent_right)])
warehouses = self.search([('lot_stock_id', 'in', location_ids.ids), ('region_id', '!=', False)])
if warehouses and warehouses[0]:
return warehouses[0].region_id.id
warehouses = self.search([('lot_stock_id', 'in', location_ids.ids), ('region_id', '!=', False)], limit=1)
if warehouses:
return warehouses.region_id.id
return None
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="intrastat_extended" model="res.groups">
<field name="name">Intrastat extended</field>
</record>
</data>
</openerp>
</odoo>
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<!-- Customer Invoice Form -->
<record id="l10n_be_intrastat_xml_decl_cust_invoice_view" model="ir.ui.view">
<field name="name">l10n_be_intrastat_xml.custinvoice_form</field>
@@ -140,6 +139,4 @@
</field>
</record>
</data>
</openerp>
</odoo>
+1 -1
View File
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import xml_decl
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="view_intrastat_declaration_xml" model="ir.ui.view">
<field name="name">Intrastat XML Declaration</field>
<field name="model">l10n_be_intrastat_xml.xml_decl</field>
@@ -54,6 +52,4 @@
action="action_intrastat_xml_declaration"
id="l10n_be_intrastat_xml_declaration"
groups="account.group_account_manager"/>
</data>
</openerp>
</odoo>
+99 -156
View File
@@ -1,97 +1,68 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base64
import xml.etree.ElementTree as ET
from collections import namedtuple
from datetime import datetime
from openerp import exceptions, SUPERUSER_ID, tools
from openerp.osv import fields, osv
from openerp.tools.translate import _
from odoo import api, exceptions, fields, models, _
INTRASTAT_XMLNS = 'http://www.onegate.eu/2010-01-01'
class xml_decl(osv.TransientModel):
class XmlDeclaration(models.TransientModel):
"""
Intrastat XML Declaration
"""
_name = "l10n_be_intrastat_xml.xml_decl"
_description = 'Intrastat XML Declaration'
def _get_company_id(self, cr, uid, context=None):
return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
def _default_get_month(self):
return fields.Date.from_string(fields.Date.context_today(self)).strftime('%m')
def _get_def_monthyear(self, cr, uid, context=None):
td = datetime.strptime(fields.date.context_today(self, cr, uid, context=context),
tools.DEFAULT_SERVER_DATE_FORMAT).date()
return td.strftime('%Y'), td.strftime('%m')
def _default_get_year(self):
return fields.Date.from_string(fields.Date.context_today(self)).strftime('%Y')
def _get_def_month(self, cr, uid, context=None):
return self._get_def_monthyear(cr, uid, context=context)[1]
name = fields.Char(string='File Name', default='intrastat.xml')
month = fields.Selection([('01', 'January'), ('02', 'February'), ('03', 'March'),
('04', 'April'), ('05', 'May'), ('06', 'June'), ('07', 'July'),
('08', 'August'), ('09', 'September'), ('10', 'October'),
('11', 'November'), ('12', 'December')], string='Month', required=True, default=_default_get_month)
year = fields.Char(size=4, required=True, default=_default_get_year)
company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id)
arrivals = fields.Selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
required=True, default='be-standard')
dispatches = fields.Selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
required=True, default='be-standard')
file_save = fields.Binary(string='Intrastat Report File', readonly=True)
state = fields.Selection([('draft', 'Draft'), ('download', 'Download')], default='draft')
def _get_def_year(self, cr, uid, context=None):
return self._get_def_monthyear(cr, uid, context=context)[0]
_columns = {
'name': fields.char('File Name'),
'month': fields.selection([('01','January'), ('02','February'), ('03','March'),
('04','April'), ('05','May'), ('06','June'), ('07','July'),
('08','August'), ('09','September'), ('10','October'),
('11','November'), ('12','December')], 'Month', required=True),
'year': fields.char('Year', size=4, required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'arrivals': fields.selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
'Arrivals', required=True),
'dispatches': fields.selection([('be-exempt', 'Exempt'),
('be-standard', 'Standard'),
('be-extended', 'Extended')],
'Dispatches', required=True),
'file_save': fields.binary('Intrastat Report File', readonly=True),
'state': fields.selection([('draft', 'Draft'), ('download', 'Download')], string="State"),
}
_defaults = {
'arrivals': 'be-standard',
'dispatches': 'be-standard',
'name': 'intrastat.xml',
'company_id': _get_company_id,
'month': _get_def_month,
'year': _get_def_year,
'state': 'draft',
}
def _company_warning(self, cr, uid, translated_msg, context=None):
@api.model
def _company_warning(self, translated_msg):
""" Raise a error with custom message, asking user to configure company settings """
xmlid_mod = self.pool['ir.model.data']
action_id = xmlid_mod.xmlid_to_res_id(cr, uid, 'base.action_res_company_form')
raise exceptions.RedirectWarning(
translated_msg, action_id, _('Go to company configuration screen'))
translated_msg, self.env.ref('base.action_res_company_form').id, _('Go to company configuration screen'))
def create_xml(self, cr, uid, ids, context=None):
@api.multi
def create_xml(self):
"""Creates xml that is to be exported and sent to estate for partner vat intra.
:return: Value for next action.
:rtype: dict
"""
decl_datas = self.browse(cr, uid, ids[0])
company = decl_datas.company_id
self.ensure_one()
company = self.company_id
if not (company.partner_id and company.partner_id.country_id and
company.partner_id.country_id.id):
self._company_warning(
cr, uid,
_('The country of your company is not set, '
'please make sure to configure it first.'),
context=context)
kbo = company.company_registry
if not kbo:
self._company_warning(
cr, uid,
_('The registry number of your company is not set, '
'please make sure to configure it first.'),
context=context)
if len(decl_datas.year) != 4:
self._company_warning(_('The country of your company is not set, '
'please make sure to configure it first.'))
if not company.company_registry:
self._company_warning(_('The registry number of your company is not set, '
'please make sure to configure it first.'))
if len(self.year) != 4:
raise exceptions.Warning(_('Year must be 4 digits number (YYYY)'))
#Create root declaration
@@ -101,51 +72,40 @@ class xml_decl(osv.TransientModel):
#Add Administration elements
admin = ET.SubElement(decl, 'Administration')
fromtag = ET.SubElement(admin, 'From')
fromtag.text = kbo
fromtag.text = company.company_registry
fromtag.set('declarerType', 'KBO')
ET.SubElement(admin, 'To').text = "NBB"
ET.SubElement(admin, 'Domain').text = "SXX"
if decl_datas.arrivals == 'be-standard':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=False, extendedmode=False, context=context))
elif decl_datas.arrivals == 'be-extended':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=False, extendedmode=True, context=context))
if decl_datas.dispatches == 'be-standard':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=True, extendedmode=False, context=context))
elif decl_datas.dispatches == 'be-extended':
decl.append(self._get_lines(cr, SUPERUSER_ID, ids, decl_datas, company,
dispatchmode=True, extendedmode=True, context=context))
if self.arrivals == 'be-standard':
decl.append(self.sudo()._get_lines(dispatchmode=False, extendedmode=False))
elif self.arrivals == 'be-extended':
decl.append(self.sudo()._get_lines(dispatchmode=False, extendedmode=True))
if self.dispatches == 'be-standard':
decl.append(self.sudo()._get_lines(dispatchmode=True, extendedmode=False))
elif self.dispatches == 'be-extended':
decl.append(self.sudo()._get_lines(dispatchmode=True, extendedmode=True))
#Get xml string with declaration
data_file = ET.tostring(decl, encoding='UTF-8', method='xml')
#change state of the wizard
self.write(cr, uid, ids,
{'name': 'intrastat_%s%s.xml' % (decl_datas.year, decl_datas.month),
self.write({'name': 'intrastat_%s%s.xml' % (self.year, self.month),
'file_save': base64.encodestring(data_file),
'state': 'download'},
context=context)
'state': 'download'})
return {
'name': _('Save'),
'context': context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'l10n_be_intrastat_xml.xml_decl',
'type': 'ir.actions.act_window',
'target': 'new',
'res_id': ids[0],
'res_id': self.id,
}
def _get_lines(self, cr, uid, ids, decl_datas, company, dispatchmode=False,
extendedmode=False, context=None):
intrastatcode_mod = self.pool['report.intrastat.code']
invoiceline_mod = self.pool['account.invoice.line']
product_mod = self.pool['product.product']
region_mod = self.pool['l10n_be_intrastat.region']
warehouse_mod = self.pool['stock.warehouse'].browse(cr, uid, [], context=context)
location_mod = warehouse_mod.env['stock.location']
@api.multi
def _get_lines(self, dispatchmode=False, extendedmode=False):
company = self.company_id
IntrastatRegion = self.env['l10n_be_intrastat.region']
if dispatchmode:
mode1 = 'out_invoice'
@@ -161,7 +121,7 @@ class xml_decl(osv.TransientModel):
decl.set('code', 'EX%sS' % declcode)
else:
decl.set('code', 'EX%sE' % declcode)
decl.set('date', '%s-%s' % (decl_datas.year, decl_datas.month))
decl.set('date', '%s-%s' % (self.year, self.month))
datas = ET.SubElement(decl, 'Data')
if not extendedmode:
datas.set('form', 'EXF%sS' % declcode)
@@ -173,37 +133,37 @@ class xml_decl(osv.TransientModel):
'EXGO', 'EXTPC', 'EXDELTRM'])
entries = {}
sqlreq = """
select
query = """
SELECT
inv_line.id
from
FROM
account_invoice_line inv_line
join account_invoice inv on inv_line.invoice_id=inv.id
left join res_country on res_country.id = inv.intrastat_country_id
left join res_partner on res_partner.id = inv.partner_id
left join res_country countrypartner on countrypartner.id = res_partner.country_id
join product_product on inv_line.product_id=product_product.id
join product_template on product_product.product_tmpl_id=product_template.id
where
inv.state in ('open','paid')
and inv.company_id=%s
and not product_template.type='service'
and (res_country.intrastat=true or (inv.intrastat_country_id is null
and countrypartner.intrastat=true))
and ((res_country.code is not null and not res_country.code=%s)
or (res_country.code is null and countrypartner.code is not null
and not countrypartner.code=%s))
and inv.type in (%s, %s)
and to_char(inv.date_invoice, 'YYYY')=%s
and to_char(inv.date_invoice, 'MM')=%s
JOIN account_invoice inv ON inv_line.invoice_id=inv.id
LEFT JOIN res_country ON res_country.id = inv.intrastat_country_id
LEFT JOIN res_partner ON res_partner.id = inv.partner_id
LEFT JOIN res_country countrypartner ON countrypartner.id = res_partner.country_id
JOIN product_product ON inv_line.product_id=product_product.id
JOIN product_template ON product_product.product_tmpl_id=product_template.id
WHERE
inv.state IN ('open','paid')
AND inv.company_id=%s
AND not product_template.type='service'
AND (res_country.intrastat=true OR (inv.intrastat_country_id is NULL
AND countrypartner.intrastat=true))
AND ((res_country.code IS NOT NULL AND not res_country.code=%s)
OR (res_country.code is NULL AND countrypartner.code IS NOT NULL
AND not countrypartner.code=%s))
AND inv.type IN (%s, %s)
AND to_char(inv.date_invoice, 'YYYY')=%s
AND to_char(inv.date_invoice, 'MM')=%s
"""
cr.execute(sqlreq, (company.id, company.partner_id.country_id.code,
self.env.cr.execute(query, (company.id, company.partner_id.country_id.code,
company.partner_id.country_id.code, mode1, mode2,
decl_datas.year, decl_datas.month))
lines = cr.fetchall()
self.year, self.month))
lines = self.env.cr.fetchall()
invoicelines_ids = [rec[0] for rec in lines]
invoicelines = invoiceline_mod.browse(cr, uid, invoicelines_ids, context=context)
invoicelines = self.env['account.invoice.line'].browse(invoicelines_ids)
for inv_line in invoicelines:
#Check type of transaction
@@ -227,45 +187,34 @@ class xml_decl(osv.TransientModel):
exreg = None
if inv_line.invoice_id.type in ('in_invoice', 'in_refund'):
#comes from purchase
POL = self.pool['purchase.order.line']
poline_ids = POL.search(
cr, uid, [('invoice_lines', 'in', inv_line.id)], context=context)
if poline_ids:
purchaseorder = POL.browse(cr, uid, poline_ids[0], context=context).order_id
location = location_mod.browse(purchaseorder._get_destination_location())
region_id = warehouse_mod.get_regionid_from_locationid(location)
po_lines = self.env['purchase.order.line'].search([('invoice_lines', 'in', inv_line.id)], limit=1)
if po_lines:
location = self.env['stock.location'].browse(po_lines.order_id._get_destination_location())
region_id = self.env['stock.warehouse'].get_regionid_from_locationid(location)
if region_id:
exreg = region_mod.browse(cr, uid, region_id).code
exreg = IntrastatRegion.browse(region_id).code
elif inv_line.invoice_id.type in ('out_invoice', 'out_refund'):
#comes from sales
soline_ids = self.pool['sale.order.line'].search(
cr, uid, [('invoice_lines', 'in', inv_line.id)], context=context)
if soline_ids:
saleorder = self.pool['sale.order.line'].browse(
cr, uid, soline_ids[0], context=context).order_id
so_lines = self.env['sale.order.line'].search([('invoice_lines', 'in', inv_line.id)], limit=1)
if so_lines:
saleorder = so_lines.order_id
if saleorder and saleorder.warehouse_id and saleorder.warehouse_id.region_id:
exreg = region_mod.browse(
cr, uid, saleorder.warehouse_id.region_id.id, context=context).code
exreg = IntrastatRegion.browse(saleorder.warehouse_id.region_id.id).code
if not exreg:
if company.region_id:
exreg = company.region_id.code
else:
self._company_warning(
cr, uid,
_('The Intrastat Region of the selected company is not set, '
'please make sure to configure it first.'),
context=context)
self._company_warning(_('The Intrastat Region of the selected company is not set, '
'please make sure to configure it first.'))
#Check commodity codes
intrastat_id = product_mod.get_intrastat_recursively(
cr, uid, inv_line.product_id.id, context=context)
intrastat_id = inv_line.product_id.get_intrastat_recursively()
if intrastat_id:
exgo = intrastatcode_mod.browse(cr, uid, intrastat_id, context=context).name
exgo = self.env['report.intrastat.code'].browse(intrastat_id).name
else:
raise exceptions.Warning(
_('Product "%s" has no intrastat code, please configure it') %
inv_line.product_id.display_name)
_('Product "%s" has no intrastat code, please configure it') % inv_line.product_id.display_name)
#In extended mode, 2 more fields required
if extendedmode:
@@ -275,11 +224,8 @@ class xml_decl(osv.TransientModel):
elif company.transport_mode_id:
extpc = company.transport_mode_id.code
else:
self._company_warning(
cr, uid,
_('The default Intrastat transport mode of your company '
'is not set, please make sure to configure it first.'),
context=context)
self._company_warning(_('The default Intrastat transport mode of your company '
'is not set, please make sure to configure it first.'))
#Check incoterm
if inv_line.invoice_id.incoterm_id:
@@ -287,11 +233,8 @@ class xml_decl(osv.TransientModel):
elif company.incoterm_id:
exdeltrm = company.incoterm_id.code
else:
self._company_warning(
cr, uid,
_('The default Incoterm of your company is not set, '
'please make sure to configure it first.'),
context=context)
self._company_warning(_('The default Incoterm of your company is not set, '
'please make sure to configure it first.'))
else:
extpc = ""
exdeltrm = ""
@@ -305,7 +248,7 @@ class xml_decl(osv.TransientModel):
else:
amount = 0
weight = (inv_line.product_id.weight or 0.0) * \
self.pool.get('product.uom')._compute_qty(cr, uid, inv_line.uom_id.id, inv_line.quantity, inv_line.product_id.uom_id.id)
self.env['product.uom']._compute_qty(inv_line.uom_id.id, inv_line.quantity, inv_line.product_id.uom_id.id)
if not inv_line.product_id.uom_id.category_id:
supply_units = inv_line.quantity
else: