diff --git a/intrastat_product/__manifest__.py b/intrastat_product/__manifest__.py index b02e9fe..1c8572c 100644 --- a/intrastat_product/__manifest__.py +++ b/intrastat_product/__manifest__.py @@ -7,7 +7,7 @@ { 'name': 'Intrastat Product', - 'version': '11.0.1.2.0', + 'version': '12.0.1.0.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat Product', @@ -17,10 +17,10 @@ 'intrastat_base', 'product_harmonized_system', 'sale_stock', - 'purchase', + 'purchase_stock', 'report_xlsx_helper', ], - 'excludes': ['report_intrastat'], + 'excludes': ['account_intrastat'], 'data': [ 'views/hs_code.xml', 'views/intrastat_region.xml', @@ -38,5 +38,5 @@ 'data/intrastat_unit.xml', ], 'demo': ['demo/intrastat_demo.xml'], - 'installable': False, + 'installable': True, } diff --git a/intrastat_product/data/intrastat_unit.xml b/intrastat_product/data/intrastat_unit.xml index 9f80880..6d54164 100644 --- a/intrastat_product/data/intrastat_unit.xml +++ b/intrastat_product/data/intrastat_unit.xml @@ -18,7 +18,7 @@ g Gram - + gi F/S @@ -71,7 +71,7 @@ l Litre - + 1000 l @@ -84,7 +84,7 @@ m Metre - + m2 @@ -105,7 +105,7 @@ items Number of items - + 100 items diff --git a/intrastat_product/demo/intrastat_demo.xml b/intrastat_product/demo/intrastat_demo.xml index cbb584d..9cf9552 100644 --- a/intrastat_product/demo/intrastat_demo.xml +++ b/intrastat_product/demo/intrastat_demo.xml @@ -18,7 +18,7 @@ extended extended - + diff --git a/intrastat_product/models/account_invoice.py b/intrastat_product/models/account_invoice.py index ac3b4ff..fae95be 100644 --- a/intrastat_product/models/account_invoice.py +++ b/intrastat_product/models/account_invoice.py @@ -1,4 +1,4 @@ -# Copyright 2011-2017 Akretion (http://www.akretion.com) +# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2009-2018 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer @@ -9,8 +9,6 @@ from odoo import api, fields, models class AccountInvoice(models.Model): _inherit = 'account.invoice' - # in v10, the sale_stock module defines an incoterms_id - # Odoo v8 name: incoterm_id intrastat_transaction_id = fields.Many2one( comodel_name='intrastat.transaction', string='Intrastat Transaction Type', @@ -29,7 +27,7 @@ class AccountInvoice(models.Model): "arrivals.") intrastat_country = fields.Boolean( compute='_compute_intrastat_country', string='Intrastat Country', - store=True, readonly=True, compute_sudo=True) + store=True, compute_sudo=True) src_dest_region_id = fields.Many2one( comodel_name='intrastat.region', string='Origin/Destination Region', @@ -39,9 +37,8 @@ class AccountInvoice(models.Model): ondelete='restrict') intrastat = fields.Char( string='Intrastat Declaration', - related='company_id.intrastat', readonly=True, compute_sudo=True) + related='company_id.intrastat') - @api.multi @api.depends('partner_shipping_id.country_id', 'partner_id.country_id') def _compute_intrastat_country(self): for inv in self: @@ -55,7 +52,7 @@ class AccountInvoice(models.Model): @api.model def _default_src_dest_region_id(self): rco = self.env['res.company'] - company = rco._company_default_get('account.invoice') + company = rco._company_default_get() return company.intrastat_region_id diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index 2aa296f..6c1130d 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -1,4 +1,4 @@ -# Copyright 2011-2017 Akretion (http://www.akretion.com) +# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2009-2018 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer @@ -27,35 +27,24 @@ class IntrastatProductDeclaration(models.Model): ] @api.model - def _default_year(self): - if datetime.now().month == 1: - year = datetime.now().year - 1 - else: - year = datetime.now().year - return str(year) - - @api.model - def _default_month(self): - if datetime.now().month == 1: - return 12 - else: - return datetime.now().month - 1 - - @api.model - def _default_action(self): - return 'replace' + def default_get(self, fields_list): + res = super(IntrastatProductDeclaration, self).default_get(fields_list) + decl_date = fields.Date.context_today(self) - relativedelta(months=1) + res.update({ + 'year': str(decl_date.year), + 'month': decl_date.month, + }) + return res company_id = fields.Many2one( comodel_name='res.company', string='Company', readonly=True, - default=lambda self: self.env['res.company']._company_default_get( - 'intrastat.product.declaration')) + default=lambda self: self.env['res.company']._company_default_get()) company_country_code = fields.Char( compute='_compute_company_country_code', string='Company Country Code', readonly=True, store=True, help="Used in views and methods of localization modules.") year = fields.Char( string='Year', required=True, - default=lambda self: self._default_year(), states={'done': [('readonly', True)]}) month = fields.Selection([ (1, '01'), @@ -71,7 +60,6 @@ class IntrastatProductDeclaration(models.Model): (11, '11'), (12, '12') ], string='Month', required=True, - default=lambda self: self._default_month(), states={'done': [('readonly', True)]}) year_month = fields.Char( compute='_compute_year_month', string='Period', readonly=True, @@ -84,7 +72,7 @@ class IntrastatProductDeclaration(models.Model): action = fields.Selection( selection='_get_action', string='Action', required=True, - default=lambda self: self._default_action(), + default='replace', states={'done': [('readonly', True)]}, track_visibility='onchange') revision = fields.Integer( @@ -107,8 +95,7 @@ class IntrastatProductDeclaration(models.Model): compute='_compute_numbers', string='Total Fiscal Amount', store=True, help="Total fiscal amount in company currency of the declaration.") currency_id = fields.Many2one( - 'res.currency', related='company_id.currency_id', readonly=True, - string='Currency') + 'res.currency', related='company_id.currency_id', string='Currency') state = fields.Selection( selection=[('draft', 'Draft'), ('done', 'Done')], @@ -152,7 +139,6 @@ class IntrastatProductDeclaration(models.Model): ('append', 'Append'), ('nihil', 'Nihil')] - @api.multi @api.depends('company_id') def _compute_company_country_code(self): for this in self: @@ -163,7 +149,6 @@ class IntrastatProductDeclaration(models.Model): this.company_country_code = \ this.company_id.country_id.code.lower() - @api.multi @api.depends('year', 'month') def _compute_year_month(self): for this in self: @@ -171,7 +156,6 @@ class IntrastatProductDeclaration(models.Model): this.year_month = '-'.join( [this.year, format(this.month, '02')]) - @api.multi @api.depends('month') def _compute_check_validity(self): """ TO DO: logic based upon computation lines """ @@ -196,7 +180,6 @@ class IntrastatProductDeclaration(models.Model): self.company_id.intrastat_dispatches == 'extended' \ and 'extended' or 'standard' - @api.multi def copy(self, default=None): self.ensure_one() default = default or {} @@ -322,10 +305,9 @@ class IntrastatProductDeclaration(models.Model): def _get_amount(self, inv_line): invoice = inv_line.invoice_id - amount = invoice.currency_id.with_context( - date=invoice.date_invoice).compute( - inv_line.price_subtotal, - self.company_id.currency_id) + amount = invoice.currency_id._convert( + inv_line.price_subtotal, self.company_id.currency_id, + self.company_id, invoice.date_invoice) return amount def _get_region(self, inv_line): @@ -379,7 +361,10 @@ class IntrastatProductDeclaration(models.Model): return transport def _get_incoterm(self, inv_line): - incoterm = inv_line.invoice_id.incoterms_id \ + # WARNING for v12: there are 2 incoterm fields on account.invoice + # cf https://github.com/odoo/odoo/issues/31641 + # the field to use is 'incoterm_id' defined in the 'account' module + incoterm = inv_line.invoice_id.incoterm_id \ or self.company_id.intrastat_incoterm_id if not incoterm: msg = _( @@ -441,7 +426,7 @@ class IntrastatProductDeclaration(models.Model): domain = [ ('date_invoice', '>=', start_date), ('date_invoice', '<=', end_date), - ('state', 'in', ['open', 'paid']), + ('state', 'in', ['open', 'in_payment', 'paid']), ('intrastat_country', '=', True), ('company_id', '=', self.company_id.id)] return domain @@ -479,10 +464,11 @@ class IntrastatProductDeclaration(models.Model): accessory_costs and inv_line.product_id and inv_line.product_id.is_accessory_cost): - acost = invoice.currency_id.with_context( - date=invoice.date_invoice).compute( - inv_line.price_subtotal, - self.company_id.currency_id) + acost = invoice.currency_id._convert( + inv_line.price_subtotal, + self.company_id.currency_id, + self.company_id, + invoice.date_invoice) total_inv_accessory_costs_cc += acost continue @@ -599,14 +585,13 @@ class IntrastatProductDeclaration(models.Model): def _get_uom_refs(self, ref): uom_refs = { - 'weight_uom_categ': self.env.ref('product.product_uom_categ_kgm'), - 'kg_uom': self.env.ref('product.product_uom_kgm'), - 'pce_uom_categ': self.env.ref('product.product_uom_categ_unit'), - 'pce_uom': self.env.ref('product.product_uom_unit') + 'weight_uom_categ': self.env.ref('uom.product_uom_categ_kgm'), + 'kg_uom': self.env.ref('uom.product_uom_kgm'), + 'pce_uom_categ': self.env.ref('uom.product_uom_categ_unit'), + 'pce_uom': self.env.ref('uom.product_uom_unit') } return uom_refs[ref] - @api.multi def action_gather(self): self.ensure_one() self.message_post(body=_("Generate Lines from Invoices")) @@ -716,7 +701,6 @@ class IntrastatProductDeclaration(models.Model): vals['amount_company_currency'])) return vals - @api.multi def generate_declaration(self): """ generate declaration lines """ self.ensure_one() @@ -740,7 +724,6 @@ class IntrastatProductDeclaration(models.Model): cl.write({'declaration_line_id': declaration_line.id}) return True - @api.multi def generate_xml(self): """ generate the INTRASTAT Declaration XML file """ self.ensure_one() @@ -756,7 +739,6 @@ class IntrastatProductDeclaration(models.Model): raise UserError( _("No XML File has been generated.")) - @api.multi def create_xls(self): if self.env.context.get('computation_lines'): report_file = 'instrastat_transactions' @@ -802,11 +784,9 @@ class IntrastatProductDeclaration(models.Model): """ return {} - @api.multi def done(self): self.write({'state': 'done'}) - @api.multi def back2draft(self): self.write({'state': 'draft'}) @@ -819,20 +799,11 @@ class IntrastatProductComputationLine(models.Model): 'intrastat.product.declaration', string='Intrastat Product Declaration', ondelete='cascade', readonly=True) - company_id = fields.Many2one( - 'res.company', related='parent_id.company_id', - string="Company", readonly=True) + company_id = fields.Many2one(related='parent_id.company_id') company_currency_id = fields.Many2one( - 'res.currency', related='company_id.currency_id', - string="Company currency", readonly=True) - type = fields.Selection( - related='parent_id.type', - string='Type', - readonly=True) - reporting_level = fields.Selection( - related='parent_id.reporting_level', - string='Reporting Level', - readonly=True) + related='company_id.currency_id', string="Company currency") + type = fields.Selection(related='parent_id.type') + reporting_level = fields.Selection(related='parent_id.reporting_level') valid = fields.Boolean( compute='_compute_check_validity', string='Valid') @@ -840,7 +811,7 @@ class IntrastatProductComputationLine(models.Model): 'account.invoice.line', string='Invoice Line', readonly=True) invoice_id = fields.Many2one( 'account.invoice', related='invoice_line_id.invoice_id', - string='Invoice', readonly=True) + string='Invoice') declaration_line_id = fields.Many2one( 'intrastat.product.declaration.line', string='Declaration Line', readonly=True) @@ -849,14 +820,12 @@ class IntrastatProductComputationLine(models.Model): help="Country of Origin/Destination", domain=[('intrastat', '=', True)]) product_id = fields.Many2one( - 'product.product', related='invoice_line_id.product_id', - string='Product', readonly=True) + 'product.product', related='invoice_line_id.product_id') hs_code_id = fields.Many2one( 'hs.code', string='Intrastat Code') intrastat_unit_id = fields.Many2one( 'intrastat.unit', related='hs_code_id.intrastat_unit_id', - string='Suppl. Unit', readonly=True, - help="Intrastat Supplementary Unit") + string='Suppl. Unit', help="Intrastat Supplementary Unit") weight = fields.Float( string='Weight', digits=dp.get_precision('Stock Weight'), help="Net weight in Kg") @@ -883,7 +852,7 @@ class IntrastatProductComputationLine(models.Model): 'intrastat.region', string='Intrastat Region') # extended declaration incoterm_id = fields.Many2one( - 'stock.incoterms', string='Incoterm') + 'account.incoterms', string='Incoterm') transport_id = fields.Many2one( 'intrastat.transport_mode', string='Transport Mode') @@ -891,13 +860,15 @@ class IntrastatProductComputationLine(models.Model): 'res.country', string='Country of Origin of the Product', help="Country of origin of the product i.e. product 'made in ____'") - @api.multi @api.depends('transport_id') def _compute_check_validity(self): """ TO DO: logic based upon fields """ for this in self: this.valid = True + # TODO: product_id is a readonly related field 'invoice_line_id.product_id' + # so the onchange is non-sense. Either we convert product_id to a regular + # field or we keep it a related field and we remove this onchange @api.onchange('product_id') def _onchange_product(self): self.weight = 0.0 @@ -920,20 +891,11 @@ class IntrastatProductDeclarationLine(models.Model): 'intrastat.product.declaration', string='Intrastat Product Declaration', ondelete='cascade', readonly=True) - company_id = fields.Many2one( - 'res.company', related='parent_id.company_id', - string="Company", readonly=True) + company_id = fields.Many2one(related='parent_id.company_id') company_currency_id = fields.Many2one( - 'res.currency', related='company_id.currency_id', - string="Company currency", readonly=True) - type = fields.Selection( - related='parent_id.type', - string='Type', - readonly=True) - reporting_level = fields.Selection( - related='parent_id.reporting_level', - string='Reporting Level', - readonly=True) + related='company_id.currency_id', string="Company currency") + type = fields.Selection(related='parent_id.type') + reporting_level = fields.Selection(related='parent_id.reporting_level') computation_line_ids = fields.One2many( 'intrastat.product.computation.line', 'declaration_line_id', string='Computation Lines', readonly=True) @@ -946,8 +908,7 @@ class IntrastatProductDeclarationLine(models.Model): string='Intrastat Code') intrastat_unit_id = fields.Many2one( 'intrastat.unit', related='hs_code_id.intrastat_unit_id', - string='Suppl. Unit', readonly=True, - help="Intrastat Supplementary Unit") + string='Suppl. Unit', help="Intrastat Supplementary Unit") weight = fields.Integer( string='Weight', help="Net weight in Kg") suppl_unit_qty = fields.Integer( @@ -965,7 +926,7 @@ class IntrastatProductDeclarationLine(models.Model): 'intrastat.region', string='Intrastat Region') # extended declaration incoterm_id = fields.Many2one( - 'stock.incoterms', string='Incoterm') + 'account.incoterms', string='Incoterm') transport_id = fields.Many2one( 'intrastat.transport_mode', string='Transport Mode') diff --git a/intrastat_product/models/intrastat_region.py b/intrastat_product/models/intrastat_region.py index 1b05544..d320faa 100644 --- a/intrastat_product/models/intrastat_region.py +++ b/intrastat_product/models/intrastat_region.py @@ -20,5 +20,4 @@ class IntrastatRegion(models.Model): description = fields.Char(string='Description') company_id = fields.Many2one( comodel_name='res.company', string='Company', - default=lambda self: self.env['res.company']._company_default_get( - 'intrastat.region')) + default=lambda self: self.env['res.company']._company_default_get()) diff --git a/intrastat_product/models/intrastat_transaction.py b/intrastat_product/models/intrastat_transaction.py index e420663..5a63ba3 100644 --- a/intrastat_product/models/intrastat_transaction.py +++ b/intrastat_product/models/intrastat_transaction.py @@ -1,4 +1,4 @@ -# Copyright 2011-2017 Akretion (http://www.akretion.com) +# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2009-2018 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer @@ -10,7 +10,6 @@ class IntrastatTransaction(models.Model): _name = 'intrastat.transaction' _description = "Intrastat Transaction" _order = 'code' - _rec_name = 'display_name' _sql_constraints = [( 'intrastat_transaction_code_unique', 'UNIQUE(code, company_id)', @@ -18,21 +17,17 @@ class IntrastatTransaction(models.Model): code = fields.Char(string='Code', required=True) description = fields.Text(string='Description') - display_name = fields.Char( - compute='_compute_display_name_field', string="Display Name", - readonly=True, store=True) company_id = fields.Many2one( comodel_name='res.company', string='Company', - default=lambda self: self.env['res.company']._company_default_get( - 'intrastat.transaction')) + default=lambda self: self.env['res.company']._company_default_get()) - @api.multi @api.depends('code', 'description') - def _compute_display_name_field(self): + def name_get(self): + res = [] for this in self: - display_name = this.code + name = this.code if this.description: - display_name += ' ' + this.description - this.display_name = len(display_name) > 55 \ - and display_name[:55] + '...' \ - or display_name + name += ' ' + this.description + name = len(name) > 55 and name[:55] + '...' or name + res.append((this.id, this.name)) + return res diff --git a/intrastat_product/models/intrastat_transport_mode.py b/intrastat_product/models/intrastat_transport_mode.py index 2d34655..ec28a23 100644 --- a/intrastat_product/models/intrastat_transport_mode.py +++ b/intrastat_product/models/intrastat_transport_mode.py @@ -9,22 +9,20 @@ from odoo import api, fields, models class IntrastatTransportMode(models.Model): _name = 'intrastat.transport_mode' _description = "Intrastat Transport Mode" - _rec_name = 'display_name' _order = 'code' _sql_constraints = [( 'intrastat_transport_code_unique', 'UNIQUE(code)', 'Code must be unique.')] - display_name = fields.Char( - string='Display Name', compute='_compute_display_name', store=True, - readonly=True) code = fields.Char(string='Code', required=True) name = fields.Char(string='Name', required=True, translate=True) description = fields.Char(string='Description', translate=True) - @api.multi @api.depends('name', 'code') - def _compute_display_name(self): - for this in self: - this.display_name = '%s. %s' % (this.code, this.name) + def name_get(self): + res = [] + for mode in self: + name = '%s. %s' % (mode.code, mode.name) + res.append((mode.id, name)) + return res diff --git a/intrastat_product/models/intrastat_unit.py b/intrastat_product/models/intrastat_unit.py index 1b74614..7b08140 100644 --- a/intrastat_product/models/intrastat_unit.py +++ b/intrastat_product/models/intrastat_unit.py @@ -13,7 +13,7 @@ class IntrastatUnit(models.Model): name = fields.Char(string='Name', required=True) description = fields.Char(string='Description', required=True) uom_id = fields.Many2one( - comodel_name='product.uom', string='Regular UoM', + comodel_name='uom.uom', string='Regular UoM', help="Select the regular Unit of Measure of Odoo that corresponds " "to this Intrastat Supplementary Unit.") active = fields.Boolean(default=True) diff --git a/intrastat_product/models/res_company.py b/intrastat_product/models/res_company.py index 7b53221..4a8bad1 100644 --- a/intrastat_product/models/res_company.py +++ b/intrastat_product/models/res_company.py @@ -10,7 +10,7 @@ class ResCompany(models.Model): _inherit = 'res.company' intrastat_incoterm_id = fields.Many2one( - comodel_name='stock.incoterms', + comodel_name='account.incoterms', string='Default Incoterm for Intrastat', help="International Commercial Terms are a series of " "predefined commercial terms used in international " @@ -59,7 +59,6 @@ class ResCompany(models.Model): ('standard', 'Standard'), ('extended', 'Extended')] - @api.multi @api.depends('intrastat_arrivals', 'intrastat_dispatches') def _compute_intrastat(self): for this in self: diff --git a/intrastat_product/models/res_config_settings.py b/intrastat_product/models/res_config_settings.py index 37931e6..abe3b86 100644 --- a/intrastat_product/models/res_config_settings.py +++ b/intrastat_product/models/res_config_settings.py @@ -9,27 +9,25 @@ class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' intrastat_incoterm_id = fields.Many2one( - related='company_id.intrastat_incoterm_id') + related='company_id.intrastat_incoterm_id', readonly=False) intrastat_arrivals = fields.Selection( - related='company_id.intrastat_arrivals') + related='company_id.intrastat_arrivals', readonly=False) intrastat_dispatches = fields.Selection( - related='company_id.intrastat_dispatches') - intrastat = fields.Char(related='company_id.intrastat', readonly=True) + related='company_id.intrastat_dispatches', readonly=False) + intrastat = fields.Char(related='company_id.intrastat') intrastat_transport_id = fields.Many2one( - related='company_id.intrastat_transport_id') + related='company_id.intrastat_transport_id', readonly=False) intrastat_region_id = fields.Many2one( - related='company_id.intrastat_region_id') + related='company_id.intrastat_region_id', readonly=False) intrastat_transaction_out_invoice = fields.Many2one( - related='company_id.intrastat_transaction_out_invoice') + related='company_id.intrastat_transaction_out_invoice', readonly=False) intrastat_transaction_out_refund = fields.Many2one( - related='company_id.intrastat_transaction_out_refund') + related='company_id.intrastat_transaction_out_refund', readonly=False) intrastat_transaction_in_invoice = fields.Many2one( - related='company_id.intrastat_transaction_in_invoice') + related='company_id.intrastat_transaction_in_invoice', readonly=False) intrastat_transaction_in_refund = fields.Many2one( - related='company_id.intrastat_transaction_in_refund') + related='company_id.intrastat_transaction_in_refund', readonly=False) intrastat_accessory_costs = fields.Boolean( - related='company_id.intrastat_accessory_costs') - country_id = fields.Many2one( - related='company_id.country_id', readonly=True) - country_code = fields.Char( - related='company_id.country_id.code', readonly=True) + related='company_id.intrastat_accessory_costs', readonly=False) + country_id = fields.Many2one(related='company_id.country_id') + country_code = fields.Char(related='company_id.country_id.code') diff --git a/intrastat_product/models/sale_order.py b/intrastat_product/models/sale_order.py index c0a5ea4..443174a 100644 --- a/intrastat_product/models/sale_order.py +++ b/intrastat_product/models/sale_order.py @@ -1,7 +1,8 @@ -# Copyright 2010-2017 Akretion (http://www.akretion.com) +# Copyright 2010-2019 Akretion France (http://www.akretion.com) # @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import fields, models class SaleOrder(models.Model): @@ -12,9 +13,8 @@ class SaleOrder(models.Model): help="This information is used in Intrastat reports") intrastat = fields.Selection( string='Intrastat Declaration', - related='company_id.intrastat_dispatches', readonly=True) + related='company_id.intrastat_dispatches') - @api.multi def _prepare_invoice(self): '''Copy destination country to invoice''' vals = super(SaleOrder, self)._prepare_invoice() diff --git a/intrastat_product/models/stock_warehouse.py b/intrastat_product/models/stock_warehouse.py index d39cba9..cd7e683 100644 --- a/intrastat_product/models/stock_warehouse.py +++ b/intrastat_product/models/stock_warehouse.py @@ -2,7 +2,7 @@ # @author Alexis de Lattre # @author Luc de Meyer -from odoo import api, fields, models +from odoo import fields, models class StockWarehouse(models.Model): @@ -15,14 +15,11 @@ class StockWarehouse(models.Model): class StockLocation(models.Model): _inherit = 'stock.location' - @api.multi def get_intrastat_region(self): self.ensure_one() - locations = self.search( - [('parent_left', '<=', self.parent_left), - ('parent_right', '>=', self.parent_right)]) + locations = self.search([('id', 'parent_of', self.id)]) warehouses = self.env['stock.warehouse'].search([ - ('lot_stock_id', 'in', [x.id for x in locations]), + ('lot_stock_id', 'in', locations.ids), ('region_id', '!=', False)]) if warehouses: return warehouses[0].region_id diff --git a/intrastat_product/readme/CONTRIBUTORS.rst b/intrastat_product/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..51e1656 --- /dev/null +++ b/intrastat_product/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Alexis de Lattre, Akretion +* Luc De Meyer, Noviat diff --git a/intrastat_product/readme/DESCRIPTION.rst b/intrastat_product/readme/DESCRIPTION.rst new file mode 100644 index 0000000..1e413dc --- /dev/null +++ b/intrastat_product/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +This module contains common objects and fields for the Intrastat Product reporting. + +It should be used in combination with country-specific Intrastat Product reporting modules +such as: + +- *l10n_fr_intrastat_product*: + the module for the *Déclaration d'Echange de Biens* (DEB) for France +- *l10n_be_intrastat_product*: + the module for the Intrastat Product Declaration for Belgium + +These country-specific modules can be found in the OCA localization for those countries. diff --git a/intrastat_product/readme/INSTALL.rst b/intrastat_product/readme/INSTALL.rst new file mode 100644 index 0000000..5b11a6a --- /dev/null +++ b/intrastat_product/readme/INSTALL.rst @@ -0,0 +1 @@ +This module is NOT compatible with the *account_intrastat* module from Odoo Enterprise. diff --git a/intrastat_product/readme/USAGE.rst b/intrastat_product/readme/USAGE.rst new file mode 100644 index 0000000..11bac9d --- /dev/null +++ b/intrastat_product/readme/USAGE.rst @@ -0,0 +1,34 @@ +This module is used in combination with the country-specific +localization module(s). + +Coding guidelines for localization module: +------------------------------------------ + +We recommend to start by copying an existing module, e.g. l10n_be_intrastat_product +and adapt the code for the specific needs of your country. + +* Declaration Object + + Create a new class as follows: + + .. code-block:: python + + class L10nCcIntrastatProductDeclaration(models.Model): + _name = 'l10n.cc.intrastat.product.declaration' + _description = "Intrastat Product Declaration for YourCountry" + _inherit = ['intrastat.product.declaration', 'mail.thread'] + + whereby cc = your country code + +* Computation & Declaration Lines + + Create also new objects inheriting from the Computation and Declaration Line Objects + so that you can add methods or customise the methods from the base modules (make a PR when + the customization or new method is required for multiple countries). + + Adapt also the parent_id fields of the newly created objects + (cf. l10n_be_intrastat_product as example). + +* XML Files: Menu, Action, Views + + Cf. l10n_be_istrastat_product as example, replace "be" by your Country Code. diff --git a/intrastat_product/views/intrastat_product_declaration.xml b/intrastat_product/views/intrastat_product_declaration.xml index 76a5083..985b291 100644 --- a/intrastat_product/views/intrastat_product_declaration.xml +++ b/intrastat_product/views/intrastat_product_declaration.xml @@ -120,7 +120,7 @@ intrastat.product.declaration.graph intrastat.product.declaration - + @@ -128,6 +128,19 @@ + + intrastat.product.declaration.pivot + intrastat.product.declaration + + + + + + + + + + @@ -150,9 +163,8 @@