From 5b342926fa0b176ced2ae760bb59c378bc8c041e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Thu, 10 Jan 2019 16:57:05 +0100 Subject: [PATCH] [MV] - move onchange method to contract_product module [RMV] - Remove useless check --- contract/models/abstract_contract_line.py | 20 -------------------- contract/models/contract.py | 13 +------------ 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/contract/models/abstract_contract_line.py b/contract/models/abstract_contract_line.py index 92dc584b..b4ab198f 100644 --- a/contract/models/abstract_contract_line.py +++ b/contract/models/abstract_contract_line.py @@ -205,23 +205,3 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel): vals['price_unit'] = product.price self.update(vals) return {'domain': domain} - - @api.onchange('product_id') - def _onchange_product_id_recurring_info(self): - for rec in self: - rec.date_start = fields.Date.today() - if rec.product_id.is_contract: - rec.recurring_rule_type = rec.product_id.recurring_rule_type - rec.recurring_invoicing_type = ( - rec.product_id.recurring_invoicing_type - ) - rec.recurring_interval = rec.product_id.recurring_interval - rec.is_auto_renew = rec.product_id.is_auto_renew - rec.auto_renew_interval = rec.product_id.auto_renew_interval - rec.auto_renew_rule_type = rec.product_id.auto_renew_rule_type - rec.termination_notice_interval = ( - rec.product_id.termination_notice_interval - ) - rec.termination_notice_rule_type = ( - rec.product_id.termination_notice_rule_type - ) diff --git a/contract/models/contract.py b/contract/models/contract.py index 63d02038..393e121e 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -157,7 +157,7 @@ class AccountAnalyticAccount(models.Model): for contract in self.filtered('recurring_invoices'): if not contract.partner_id: raise ValidationError( - _("You must supply a customer for the contract '%s'") + _("You must supply a partner for the contract '%s'") % contract.name ) @@ -180,17 +180,6 @@ class AccountAnalyticAccount(models.Model): @api.multi def _prepare_invoice(self, date_invoice, journal=None): self.ensure_one() - if not self.partner_id: - if self.contract_type == 'purchase': - raise ValidationError( - _("You must first select a Supplier for Contract %s!") - % self.name - ) - else: - raise ValidationError( - _("You must first select a Customer for Contract %s!") - % self.name - ) if not journal: journal = ( self.journal_id