Browse Source

[12.0] [IMP] product_contract

Add recurring interval to product and sale lines in order to allow intervals other than 1
pull/450/head
brian10048 5 years ago
parent
commit
051395275a
  1. 2
      product_contract/models/contract_line.py
  2. 6
      product_contract/models/product_template.py
  3. 21
      product_contract/models/sale_order_line.py
  4. 8
      product_contract/views/product_template.xml
  5. 8
      product_contract/views/sale_order.xml

2
product_contract/models/contract_line.py

@ -44,7 +44,7 @@ class ContractLine(models.Model):
rec.recurring_invoicing_type = (
rec.product_id.recurring_invoicing_type
)
rec.recurring_interval = 1
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.default_qty
rec.auto_renew_rule_type = rec._get_auto_renew_rule_type()

6
product_contract/models/product_template.py

@ -26,6 +26,12 @@ class ProductTemplate(models.Model):
string='Invoice Every',
help="Specify Interval for automatic invoice generation.",
)
recurring_interval = fields.Integer(
default=1,
string='Invoice Every',
help="Invoice every (Days/Week/Month/Year)",
required=True,
)
recurring_invoicing_type = fields.Selection(
[('pre-paid', 'Pre-paid'), ('post-paid', 'Post-paid')],
default='pre-paid',

21
product_contract/models/sale_order_line.py

@ -34,6 +34,12 @@ class SaleOrderLine(models.Model):
string='Invoice Every',
copy=False,
)
recurring_interval = fields.Integer(
default=1,
string='Invoice Every',
help="Invoice every (Days/Week/Month/Year)",
required=True,
)
recurring_invoicing_type = fields.Selection(
[('pre-paid', 'Pre-paid'), ('post-paid', 'Post-paid')],
default='pre-paid',
@ -75,12 +81,17 @@ class SaleOrderLine(models.Model):
rec.date_start
+ contract_line_model.get_relative_delta(
rec._get_auto_renew_rule_type(),
int(rec.product_uom_qty),
int(rec.product_uom_qty*rec.recurring_interval),
)
- relativedelta(days=1)
)
@api.onchange('date_start', 'product_uom_qty', 'recurring_rule_type')
@api.onchange(
'date_start',
'product_uom_qty',
'recurring_rule_type',
'recurring_interval'
)
def onchange_date_start(self):
contract_line_model = self.env['contract.line']
for rec in self.filtered('product_id.is_contract'):
@ -91,7 +102,7 @@ class SaleOrderLine(models.Model):
rec.date_start
+ contract_line_model.get_relative_delta(
rec._get_auto_renew_rule_type(),
int(rec.product_uom_qty),
int(rec.product_uom_qty*rec.recurring_interval),
)
- relativedelta(days=1)
)
@ -112,7 +123,7 @@ class SaleOrderLine(models.Model):
self.date_start or fields.Date.today(),
self.recurring_invoicing_type,
self.recurring_rule_type,
1,
self.recurring_interval,
)
termination_notice_interval = (
self.product_id.termination_notice_interval
@ -143,7 +154,7 @@ class SaleOrderLine(models.Model):
'date_end': self.date_end,
'date_start': self.date_start or fields.Date.today(),
'recurring_next_date': recurring_next_date,
'recurring_interval': 1,
'recurring_interval': self.recurring_interval,
'recurring_invoicing_type': self.recurring_invoicing_type,
'recurring_rule_type': self.recurring_rule_type,
'is_auto_renew': self.product_id.is_auto_renew,

8
product_contract/views/product_template.xml

@ -29,7 +29,13 @@
</group>
<group name="recurrence_info">
<group>
<field name="recurring_rule_type"/>
<label for="recurring_interval"/>
<div>
<field name="recurring_interval"
class="oe_inline" nolabel="1"/>
<field name="recurring_rule_type"
class="oe_inline" nolabel="1"/>
</div>
</group>
<group>
<field name="default_qty"/>

8
product_contract/views/sale_order.xml

@ -55,7 +55,13 @@
attrs="{'invisible': [('is_contract', '=', False)]}"/>
<group attrs="{'invisible': [('is_contract', '=', False)]}">
<field name="recurring_rule_type"/>
<label for="recurring_interval"/>
<div>
<field name="recurring_interval"
class="oe_inline" nolabel="1"/>
<field name="recurring_rule_type"
class="oe_inline" nolabel="1"/>
</div>
</group>
<group attrs="{'invisible': [('is_contract', '=', False)]}">
<field name="recurring_invoicing_type"/>

Loading…
Cancel
Save