Browse Source

[ADD] - Add more value for auto_renew_rule_type

[REF] - refactoring for compute_first_date_end

[RMV] - remove auto_renew_rule_type option monthlylastday

[IMP] - rename manual_renew_needed label

[IMP] - use get_product_multiline_description_sale to get contract line description
pull/207/head
sbejaoui 6 years ago
parent
commit
75fa034db1
  1. 2
      contract/__manifest__.py
  2. 14
      contract/models/abstract_contract_line.py
  3. 30
      contract/models/contract_line.py
  4. 5
      contract/tests/test_contract.py
  5. 2
      contract/wizards/contract_line_wizard.xml

2
contract/__manifest__.py

@ -18,7 +18,7 @@
"ACSONE SA/NV, " "ACSONE SA/NV, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
'website': 'https://github.com/oca/contract', 'website': 'https://github.com/oca/contract',
'depends': ['base', 'account', 'analytic'],
'depends': ['base', 'account', 'analytic', 'product'],
"external_dependencies": {"python": ["dateutil"]}, "external_dependencies": {"python": ["dateutil"]},
'data': [ 'data': [
'wizards/contract_line_wizard.xml', 'wizards/contract_line_wizard.xml',

14
contract/models/abstract_contract_line.py

@ -90,7 +90,12 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
help="Renew every (Days/Week/Month/Year)", help="Renew every (Days/Week/Month/Year)",
) )
auto_renew_rule_type = fields.Selection( auto_renew_rule_type = fields.Selection(
[('monthly', 'Month(s)'), ('yearly', 'Year(s)')],
[
('daily', 'Day(s)'),
('weekly', 'Week(s)'),
('monthly', 'Month(s)'),
('yearly', 'Year(s)'),
],
default='yearly', default='yearly',
string='Renewal type', string='Renewal type',
help="Specify Interval for automatic renewal.", help="Specify Interval for automatic renewal.",
@ -196,12 +201,7 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
pricelist=self.contract_id.pricelist_id.id, pricelist=self.contract_id.pricelist_id.id,
uom=self.uom_id.id, uom=self.uom_id.id,
) )
name = product.name_get()[0][1]
if product.description_sale:
name += '\n' + product.description_sale
vals['name'] = name
vals['name'] = self.product_id.get_product_multiline_description_sale()
vals['price_unit'] = product.price vals['price_unit'] = product.price
self.update(vals) self.update(vals)
return {'domain': domain} return {'domain': domain}

30
contract/models/contract_line.py

@ -365,6 +365,18 @@ class AccountAnalyticInvoiceLine(models.Model):
recurring_rule_type, recurring_interval recurring_rule_type, recurring_interval
) )
@api.model
def compute_first_date_end(
self, date_start, auto_renew_rule_type, auto_renew_interval
):
return (
date_start
+ self.get_relative_delta(
auto_renew_rule_type, auto_renew_interval
)
- relativedelta(days=1)
)
@api.onchange( @api.onchange(
'date_start', 'date_start',
'is_auto_renew', 'is_auto_renew',
@ -376,12 +388,10 @@ class AccountAnalyticInvoiceLine(models.Model):
auto_renew""" auto_renew"""
for rec in self.filtered('is_auto_renew'): for rec in self.filtered('is_auto_renew'):
if rec.date_start: if rec.date_start:
rec.date_end = (
self.date_start
+ self.get_relative_delta(
rec.auto_renew_rule_type, rec.auto_renew_interval
)
- relativedelta(days=1)
rec.date_end = self.compute_first_date_end(
rec.date_start,
rec.auto_renew_rule_type,
rec.auto_renew_interval,
) )
@api.onchange( @api.onchange(
@ -986,12 +996,8 @@ class AccountAnalyticInvoiceLine(models.Model):
def _get_renewal_dates(self): def _get_renewal_dates(self):
self.ensure_one() self.ensure_one()
date_start = self.date_end + relativedelta(days=1) date_start = self.date_end + relativedelta(days=1)
date_end = (
date_start
+ self.get_relative_delta(
self.auto_renew_rule_type, self.auto_renew_interval
)
- relativedelta(days=1)
date_end = self.compute_first_date_end(
date_start, self.auto_renew_rule_type, self.auto_renew_interval
) )
return date_start, date_end return date_start, date_end

5
contract/tests/test_contract.py

@ -494,10 +494,7 @@ class TestContract(TestContractBase):
line.product_id.description_sale = 'Test' line.product_id.description_sale = 'Test'
line._onchange_product_id() line._onchange_product_id()
self.assertEqual( self.assertEqual(
line.name,
'\n'.join(
[line.product_id.name, line.product_id.description_sale]
),
line.name, line.product_id.get_product_multiline_description_sale()
) )
def test_contract_count(self): def test_contract_count(self):

2
contract/wizards/contract_line_wizard.xml

@ -12,7 +12,7 @@
<group> <group>
<field name="contract_line_id" invisible="True"/> <field name="contract_line_id" invisible="True"/>
<field string="Stop Date" name="date_end" required="True"/> <field string="Stop Date" name="date_end" required="True"/>
<field string="Is a suspension" name="manual_renew_needed"/>
<field string="Is suspension without end date" name="manual_renew_needed"/>
</group> </group>
<footer> <footer>
<button name="stop" <button name="stop"

Loading…
Cancel
Save