mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -12,6 +12,7 @@
|
||||
"depends": ["base", "contract", "queue_job"],
|
||||
"data": [
|
||||
"security/contract_line_forecast_period.xml",
|
||||
"views/res_config_settings.xml",
|
||||
"views/contract_line_forecast_period.xml",
|
||||
"views/contract.xml",
|
||||
],
|
||||
|
||||
@@ -2,3 +2,4 @@ from . import contract
|
||||
from . import contract_line
|
||||
from . import contract_line_forecast_period
|
||||
from . import res_company
|
||||
from . import res_config_settings
|
||||
|
||||
@@ -37,6 +37,7 @@ class ContractContract(models.Model):
|
||||
]
|
||||
):
|
||||
for rec in self:
|
||||
if rec.company_id.enable_contract_forecast:
|
||||
for contract_line in rec.contract_line_ids:
|
||||
contract_line.with_delay()._generate_forecast_periods()
|
||||
return res
|
||||
|
||||
@@ -52,6 +52,8 @@ class ContractLine(models.Model):
|
||||
@api.multi
|
||||
def _get_generate_forecast_periods_criteria(self, period_date_end):
|
||||
self.ensure_one()
|
||||
if not self.contract_id.company_id.enable_contract_forecast:
|
||||
return False
|
||||
if self.is_canceled or not self.active:
|
||||
return False
|
||||
contract_forecast_end_date = self._get_contract_forecast_end_date()
|
||||
@@ -108,6 +110,7 @@ class ContractLine(models.Model):
|
||||
def create(self, values):
|
||||
contract_lines = super(ContractLine, self).create(values)
|
||||
for contract_line in contract_lines:
|
||||
if contract_line.contract_id.company_id.enable_contract_forecast:
|
||||
contract_line.with_delay()._generate_forecast_periods()
|
||||
return contract_lines
|
||||
|
||||
@@ -141,5 +144,6 @@ class ContractLine(models.Model):
|
||||
]
|
||||
):
|
||||
for rec in self:
|
||||
if rec.contract_id.company_id.enable_contract_forecast:
|
||||
rec.with_delay()._generate_forecast_periods()
|
||||
return res
|
||||
|
||||
@@ -14,3 +14,6 @@ class ResCompany(models.Model):
|
||||
contract_forecast_rule_type = fields.Selection(
|
||||
[("monthly", "Month(s)"), ("yearly", "Year(s)")], default="monthly"
|
||||
)
|
||||
enable_contract_forecast = fields.Boolean(
|
||||
string="Enable contract forecast", default=True
|
||||
)
|
||||
|
||||
29
contract_forecast/models/res_config_settings.py
Normal file
29
contract_forecast/models/res_config_settings.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
enable_contract_forecast = fields.Boolean(
|
||||
string="Enable contract forecast",
|
||||
default=True,
|
||||
readonly=False,
|
||||
related="company_id.enable_contract_forecast",
|
||||
)
|
||||
contract_forecast_interval = fields.Integer(
|
||||
string="Number of contract forecast Periods",
|
||||
default=12,
|
||||
related="company_id.contract_forecast_interval",
|
||||
readonly=False,
|
||||
|
||||
)
|
||||
contract_forecast_rule_type = fields.Selection(
|
||||
[("monthly", "Month(s)"), ("yearly", "Year(s)")],
|
||||
default="monthly",
|
||||
related="company_id.contract_forecast_rule_type",
|
||||
readonly=False,
|
||||
)
|
||||
36
contract_forecast/views/res_config_settings.xml
Normal file
36
contract_forecast/views/res_config_settings.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="res_config_settings_form_view">
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="contract.res_config_settings_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='create_new_line_at_contract_line_renew']/parent::div/parent::div/parent::div"
|
||||
position="after">
|
||||
<div class="row mt16 o_settings_container">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="enable_contract_forecast"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="enable_contract_forecast"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt16 o_settings_container" attrs="{'invisible': [('enable_contract_forecast', '=', False)]}">
|
||||
<label for="contract_forecast_interval" string="Forecast Interval"
|
||||
class="oe_inline"/>
|
||||
<field name="contract_forecast_interval"
|
||||
class="oe_inline"/>
|
||||
<field name="contract_forecast_rule_type"
|
||||
class="oe_inline"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user