diff --git a/contract/__manifest__.py b/contract/__manifest__.py
index 955f8b1e..ce97ace1 100644
--- a/contract/__manifest__.py
+++ b/contract/__manifest__.py
@@ -18,7 +18,7 @@
"ACSONE SA/NV, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/oca/contract',
- 'depends': ['base', 'account', 'analytic'],
+ 'depends': ['base', 'account', 'analytic', 'product'],
"external_dependencies": {"python": ["dateutil"]},
'data': [
'wizards/contract_line_wizard.xml',
diff --git a/contract/models/abstract_contract_line.py b/contract/models/abstract_contract_line.py
index fce1fde2..9d171ca6 100644
--- a/contract/models/abstract_contract_line.py
+++ b/contract/models/abstract_contract_line.py
@@ -90,7 +90,12 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
help="Renew every (Days/Week/Month/Year)",
)
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',
string='Renewal type',
help="Specify Interval for automatic renewal.",
@@ -196,12 +201,7 @@ class AccountAbstractAnalyticContractLine(models.AbstractModel):
pricelist=self.contract_id.pricelist_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
self.update(vals)
return {'domain': domain}
diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py
index ba61c5db..13f92357 100644
--- a/contract/models/contract_line.py
+++ b/contract/models/contract_line.py
@@ -365,6 +365,18 @@ class AccountAnalyticInvoiceLine(models.Model):
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(
'date_start',
'is_auto_renew',
@@ -376,12 +388,10 @@ class AccountAnalyticInvoiceLine(models.Model):
auto_renew"""
for rec in self.filtered('is_auto_renew'):
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(
@@ -986,12 +996,8 @@ class AccountAnalyticInvoiceLine(models.Model):
def _get_renewal_dates(self):
self.ensure_one()
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
diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py
index c407c46f..989512af 100644
--- a/contract/tests/test_contract.py
+++ b/contract/tests/test_contract.py
@@ -494,10 +494,7 @@ class TestContract(TestContractBase):
line.product_id.description_sale = 'Test'
line._onchange_product_id()
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):
diff --git a/contract/wizards/contract_line_wizard.xml b/contract/wizards/contract_line_wizard.xml
index 0898230c..98ca67c9 100644
--- a/contract/wizards/contract_line_wizard.xml
+++ b/contract/wizards/contract_line_wizard.xml
@@ -12,7 +12,7 @@
-
+