Browse Source

[MV] - move onchange method to contract_product module

[RMV] - Remove useless check
13.0-mig-contract
sbejaoui 6 years ago
committed by Administrator
parent
commit
5b342926fa
  1. 20
      contract/models/abstract_contract_line.py
  2. 13
      contract/models/contract.py

20
contract/models/abstract_contract_line.py

@ -205,23 +205,3 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
vals['price_unit'] = product.price vals['price_unit'] = product.price
self.update(vals) self.update(vals)
return {'domain': domain} 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
)

13
contract/models/contract.py

@ -157,7 +157,7 @@ class AccountAnalyticAccount(models.Model):
for contract in self.filtered('recurring_invoices'): for contract in self.filtered('recurring_invoices'):
if not contract.partner_id: if not contract.partner_id:
raise ValidationError( raise ValidationError(
_("You must supply a customer for the contract '%s'")
_("You must supply a partner for the contract '%s'")
% contract.name % contract.name
) )
@ -180,17 +180,6 @@ class AccountAnalyticAccount(models.Model):
@api.multi @api.multi
def _prepare_invoice(self, date_invoice, journal=None): def _prepare_invoice(self, date_invoice, journal=None):
self.ensure_one() 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: if not journal:
journal = ( journal = (
self.journal_id self.journal_id

Loading…
Cancel
Save