Browse Source

[FIX] - compute recurring_next_date for contract

[IMP] - get contract line default data onchange product_id
13.0-mig-contract
sbejaoui 6 years ago
committed by Administrator
parent
commit
587fb7c3ff
  1. 21
      contract/models/abstract_contract_line.py
  2. 4
      contract/models/contract.py
  3. 3
      contract/views/contract_line.xml

21
contract/models/abstract_contract_line.py

@ -79,6 +79,7 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
help="Repeat every (Days/Week/Month/Year)", help="Repeat every (Days/Week/Month/Year)",
required=True, required=True,
) )
date_start = fields.Date(string='Date Start')
recurring_next_date = fields.Date(string='Date of Next Invoice') recurring_next_date = fields.Date(string='Date of Next Invoice')
is_canceled = fields.Boolean(string="Canceled", default=False) is_canceled = fields.Boolean(string="Canceled", default=False)
@ -204,3 +205,23 @@ 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
)

4
contract/models/contract.py

@ -60,9 +60,9 @@ class AccountAnalyticAccount(models.Model):
def _compute_recurring_next_date(self): def _compute_recurring_next_date(self):
for contract in self: for contract in self:
recurring_next_date = contract.recurring_invoice_line_ids.filtered( recurring_next_date = contract.recurring_invoice_line_ids.filtered(
'create_invoice_visibility'
'recurring_next_date'
).mapped('recurring_next_date') ).mapped('recurring_next_date')
if recurring_next_date and all(recurring_next_date):
if recurring_next_date:
contract.recurring_next_date = min(recurring_next_date) contract.recurring_next_date = min(recurring_next_date)
@api.depends('recurring_invoice_line_ids.create_invoice_visibility') @api.depends('recurring_invoice_line_ids.create_invoice_visibility')

3
contract/views/contract_line.xml

@ -99,8 +99,7 @@
<field name="date_start" required="1"/> <field name="date_start" required="1"/>
<field name="date_end"/> <field name="date_end"/>
<field name="recurring_next_date" <field name="recurring_next_date"
required="1"
attrs="{'invisible': [('create_invoice_visibility', '=', False)]}"/>
required="1"/>
<field name="last_date_invoiced" <field name="last_date_invoiced"
groups="base.group_no_one"/> groups="base.group_no_one"/>
<field name="create_invoice_visibility" <field name="create_invoice_visibility"

Loading…
Cancel
Save