diff --git a/intrastat_product/__openerp__.py b/intrastat_product/__openerp__.py index 77209d7..917ca49 100644 --- a/intrastat_product/__openerp__.py +++ b/intrastat_product/__openerp__.py @@ -24,7 +24,7 @@ { 'name': 'Intrastat Product', - 'version': '1.4', + 'version': '8.0.1.4.0', 'category': 'Intrastat', 'license': 'AGPL-3', 'summary': 'Base module for Intrastat Product', diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index 7631959..a6789a1 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -181,13 +181,13 @@ class IntrastatProductDeclaration(models.Model): compute='_check_validity', string='Valid') - @api.one + @api.model @api.constrains('year') def _check_year(self): - s = str(self.year) - if len(s) != 4 or s[0] != '2': - raise ValidationError( - _("Invalid Year !")) + for this in self: + s = str(this.year) + if len(s) != 4 or s[0] != '2': + raise ValidationError(_("Invalid Year !")) _sql_constraints = [ ('date_uniq', @@ -197,29 +197,32 @@ class IntrastatProductDeclaration(models.Model): "or change the revision number of this one."), ] - @api.one + @api.multi @api.depends('company_id') def _compute_company_country_code(self): - if self.company_id: - self.company_country_code = \ - self.company_id.country_id.code.lower() + for this in self: + if this.company_id: + this.company_country_code = \ + this.company_id.country_id.code.lower() - @api.one + @api.multi @api.depends('year', 'month') def _compute_year_month(self): - if self.year and self.month: - self.year_month = '-'.join( - [str(self.year), format(self.month, '02')]) + for this in self: + if this.year and this.month: + this.year_month = '-'.join( + [str(this.year), format(this.month, '02')]) - @api.one + @api.multi @api.depends('month') def _check_validity(self): """ TO DO: logic based upon computation lines """ - self.valid = True + for this in self: + this.valid = True - @api.one - @api.returns('self', lambda value: value.id) + @api.multi def copy(self, default=None): + self.ensure_one() default = default or {} default['revision'] = self.revision + 1 return super(IntrastatProductDeclaration, self).copy(default) @@ -812,11 +815,12 @@ 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.one + @api.multi @api.depends('transport_id') def _check_validity(self): """ TO DO: logic based upon fields """ - self.valid = True + for this in self: + this.valid = True @api.onchange('product_id') def _onchange_product(self): diff --git a/intrastat_product/models/intrastat_transaction.py b/intrastat_product/models/intrastat_transaction.py index bf04d32..ea9002e 100644 --- a/intrastat_product/models/intrastat_transaction.py +++ b/intrastat_product/models/intrastat_transaction.py @@ -41,15 +41,16 @@ class IntrastatTransaction(models.Model): default=lambda self: self.env['res.company']._company_default_get( 'intrastat.transaction')) - @api.one + @api.multi @api.depends('code', 'description') def _compute_display_name(self): - display_name = self.code - if self.description: - display_name += ' ' + self.description - self.display_name = len(display_name) > 55 \ - and display_name[:55] + '...' \ - or display_name + for this in self: + display_name = this.code + if this.description: + display_name += ' ' + this.description + this.display_name = len(display_name) > 55 \ + and display_name[:55] + '...' \ + or display_name _sql_constraints = [( 'intrastat_transaction_code_unique', diff --git a/intrastat_product/models/intrastat_transport_mode.py b/intrastat_product/models/intrastat_transport_mode.py index 1850497..484c84d 100644 --- a/intrastat_product/models/intrastat_transport_mode.py +++ b/intrastat_product/models/intrastat_transport_mode.py @@ -38,10 +38,11 @@ class IntrastatTransportMode(models.Model): name = fields.Char(string='Name', required=True, translate=True) description = fields.Char(string='Description', translate=True) - @api.one + @api.multi @api.depends('name', 'code') def _display_name(self): - self.display_name = '%s. %s' % (self.code, self.name) + for this in self: + this.display_name = '%s. %s' % (this.code, this.name) _sql_constraints = [( 'intrastat_transport_code_unique', diff --git a/intrastat_product/models/res_company.py b/intrastat_product/models/res_company.py index ccf15d2..2995486 100644 --- a/intrastat_product/models/res_company.py +++ b/intrastat_product/models/res_company.py @@ -78,14 +78,15 @@ class ResCompany(models.Model): ('standard', 'Standard'), ('extended', 'Extended')] - @api.one + @api.multi @api.depends('intrastat_arrivals', 'intrastat_dispatches') def _compute_intrastat(self): - if self.intrastat_arrivals == 'exempt' \ - and self.intrastat_dispatches == 'exempt': - self.intrastat = 'exempt' - elif self.intrastat_arrivals == 'extended' \ - or self.intrastat_dispatches == 'extended': - self.intrastat = 'extended' - else: - self.intrastat = 'standard' + for this in self: + if this.intrastat_arrivals == 'exempt' \ + and this.intrastat_dispatches == 'exempt': + this.intrastat = 'exempt' + elif this.intrastat_arrivals == 'extended' \ + or this.intrastat_dispatches == 'extended': + this.intrastat = 'extended' + else: + this.intrastat = 'standard'