mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] - Add multi-company to forecasts
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"name": "Contract Forecast",
|
||||
"description": """
|
||||
Contract forecast""",
|
||||
"version": "12.0.1.0.0",
|
||||
"version": "12.0.1.0.1",
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/contract",
|
||||
|
||||
18
contract_forecast/migrations/12.0.1.0.1/post-migration.py
Normal file
18
contract_forecast/migrations/12.0.1.0.1/post-migration.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright 2019 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
"""Set company_id for all forecasts"""
|
||||
_logger.info("Set company_id for all forecasts")
|
||||
cr.execute("""
|
||||
UPDATE contract_line_forecast_period AS forecast
|
||||
SET company_id=contract.company_id
|
||||
FROM account_analytic_account AS contract
|
||||
WHERE forecast.contract_id=contract.id
|
||||
AND forecast.contract_id IS NOT NULL
|
||||
""")
|
||||
@@ -27,6 +27,7 @@ class AccountAnalyticInvoiceLine(models.Model):
|
||||
return {
|
||||
"name": self._insert_markers(period_date_start, period_date_end),
|
||||
"contract_id": self.contract_id.id,
|
||||
"company_id": self.contract_id.company_id.id,
|
||||
"contract_line_id": self.id,
|
||||
"product_id": self.product_id.id,
|
||||
"date_start": period_date_start,
|
||||
|
||||
@@ -61,6 +61,7 @@ class ContractLineForecastPeriod(models.Model):
|
||||
help='Discount that is applied in generated invoices.'
|
||||
' It should be less or equal to 100',
|
||||
)
|
||||
company_id = fields.Many2one(comodel_name="res.company", string="Company")
|
||||
|
||||
@api.multi
|
||||
@api.depends('quantity', 'price_unit', 'discount')
|
||||
|
||||
@@ -14,4 +14,12 @@
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
</record>
|
||||
|
||||
<record id="contract_line_forecast_period_comp_rule" model="ir.rule">
|
||||
<field name="name">Forecast multi company rule</field>
|
||||
<field name="model_id" ref="model_contract_line_forecast_period"/>
|
||||
<field name="domain_force">
|
||||
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="contract_id" string="Contract"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Date Start" name="groupby_date_start"
|
||||
context="{'group_by':'date_start'}"/>
|
||||
@@ -37,6 +38,7 @@
|
||||
<field name="date_start"/>
|
||||
<field name="date_end"/>
|
||||
<field name="date_invoice"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user