mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[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
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
62e1a7fd79
commit
0af00f2d6d
@@ -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',
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<group>
|
||||
<field name="contract_line_id" invisible="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>
|
||||
<footer>
|
||||
<button name="stop"
|
||||
|
||||
Reference in New Issue
Block a user