Skip to content

Commit

Permalink
[MIG] contract_price_revision: Migration to 16.0
Browse files Browse the repository at this point in the history
Fix views in the process; variation % was not showing inside line list
embedded into contract forms.
  • Loading branch information
houzefa-abba committed Jan 16, 2024
1 parent f645d0f commit d4768e6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
5 changes: 3 additions & 2 deletions contract_price_revision/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
{
"name": "Contract Price Revision",
"summary": "Easy revision of contract prices",
"version": "15.0.1.0.0",
"category": "Contract",
"version": "16.0.1.0.0",
"category": "Contract Management",
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/contract",
"depends": ["contract"],
"data": [
"security/ir.model.access.csv",
"views/contract_contract.xml",
"views/contract_line.xml",
"wizards/contract_price_revision_views.xml",
],
Expand Down
11 changes: 5 additions & 6 deletions contract_price_revision/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ContractLine(models.Model):
_inherit = "contract.line"

previous_price = fields.Float(
previous_price = fields.Monetary(
string="Previous price",
related="predecessor_contract_line_id.price_unit",
readonly=True,
Expand Down Expand Up @@ -55,12 +55,11 @@ def _compute_variation_percent(self):
def _prepare_value_for_plan_successor_price(
self, date_start, date_end, is_auto_renew, price, recurring_next_date=False
):
"""
Override contract function to prepare values for new contract line
"""Wrap contract function to prepare values for new contract line
adding the new price as parameter
"""
res = super()._prepare_value_for_plan_successor(
values = self._prepare_value_for_plan_successor(
date_start, date_end, is_auto_renew, recurring_next_date=recurring_next_date
)
res.update({"price_unit": price})
return res
values["price_unit"] = price
return values
4 changes: 4 additions & 0 deletions contract_price_revision/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
* Vicent Cubells
* Carlos Dauden
* Carolina Fernandez

* `XCG Consulting <https://xcg-consulting.fr>`_:

* Houzéfa Abbasbhay
16 changes: 16 additions & 0 deletions contract_price_revision/views/contract_contract.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Add into contract line list view embedded into contract forms. -->
<record id="contract_contract_form_view" model="ir.ui.view">
<field name="model">contract.contract</field>
<field name="inherit_id" ref="contract.contract_contract_form_view" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='contract_line_ids']/tree/field[@name='last_date_invoiced']"
position="after"
>
<field name="variation_percent" groups="base.group_no_one" />
</xpath>
</field>
</record>
</odoo>
31 changes: 13 additions & 18 deletions contract_price_revision/views/contract_line.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="contract_line_tree_view" model="ir.ui.view">
<field name="model">contract.line</field>
<field name="inherit_id" ref="contract.contract_line_tree_view" />
<field name="arch" type="xml">
<field name="last_date_invoiced" position="after">
<field name="never_revise_price" />
<field name="variation_percent" groups="base.group_no_one" />
</field>
</field>
</record>
<!-- Add our fields within contract line views.
Note: We do not add them within their parent contract.abstract.contract.line views as
price revision only works on contracts with recurrence at line level. -->
<record id="contract_line_form_view" model="ir.ui.view">
<field name="model">contract.line</field>
<field name="inherit_id" ref="contract.contract_line_form_view" />
<field name="arch" type="xml">
<field name="discount" position="after">
<field name="never_revise_price" />
<field
name="variation_percent"
groups="base.group_no_one"
attrs="{'invisible': [('predecessor_contract_line_id', '=', False)]}"
/>
</field>
<label for="name" position="before">
<group>
<field name="never_revise_price" />
<field
name="variation_percent"
groups="base.group_no_one"
attrs="{'invisible': [('predecessor_contract_line_id', '=', False)]}"
/>
</group>
</label>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/contract_price_revision/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit d4768e6

Please sign in to comment.