Skip to content

Commit

Permalink
[MIG] agreement_rebate: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoca13 committed Jan 29, 2025
1 parent cba02e6 commit 9a8a3f2
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 64 deletions.
9 changes: 5 additions & 4 deletions agreement_rebate/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Agreement Rebate
!! source digest: sha256:5b7242b1d8b9588b1724ec1d569cbd0ea5999c7ba01c2223a0efcc0c6a286fa4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
Expand Down Expand Up @@ -112,8 +112,9 @@ Contributors

- `Tecnativa <https://www.tecnativa.com>`__:

- Carlos Dauden <[email protected]>
- Sergio Teruel <[email protected]>
- Carlos Dauden
- Sergio Teruel
- Carlos Roca

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions agreement_rebate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{
"name": "Agreement Rebate",
"summary": "Rebate in agreements",
"version": "16.0.1.0.1",
"development_status": "Beta",
"version": "18.0.1.0.0",
"development_status": "Production/Stable",
"category": "Agreement",
"website": "https://github.com/OCA/agreement",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
11 changes: 3 additions & 8 deletions agreement_rebate/models/agreement_rebate_settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create(self, vals_list):
vals["name"] = self.env["ir.sequence"].next_by_code(
"agreement.rebate.settlement"
)
return super(AgreementRebateSettlement, self).create(vals_list)
return super().create(vals_list)

def write(self, vals):
res = super().write(vals)
Expand Down Expand Up @@ -101,7 +101,7 @@ def action_show_detail(self):
"name": _("Details"),
"type": "ir.actions.act_window",
"res_model": "account.invoice.report",
"view_mode": "pivot,tree",
"view_mode": "pivot,list",
"domain": domain,
"context": self.env.context,
}
Expand Down Expand Up @@ -291,9 +291,6 @@ def _prepare_invoice(self):
"invoice_origin": self.settlement_id.name,
"invoice_line_ids": [],
"currency_id": partner.currency_id.id,
# 'comment': self.note,
# 'user_id': self.user_id and self.user_id.id,
# 'team_id': self.team_id.id,
}
)
return invoice_vals
Expand Down Expand Up @@ -335,8 +332,6 @@ def _prepare_invoice_line(self, invoice_vals):
date_from=self.settlement_id.date_from,
date_to=self.settlement_id.date_to,
),
# 'account_analytic_id': self.analytic_account_id.id,
# 'analytic_tag_ids': [(6, 0, self.analytic_tag_ids.ids)],
"price_unit": self.amount_rebate,
}
)
Expand All @@ -358,7 +353,7 @@ def action_show_detail(self):
"name": _("Details"),
"type": "ir.actions.act_window",
"res_model": "account.invoice.report",
"view_mode": "pivot,tree",
"view_mode": "pivot,list",
"domain": self.target_domain,
"context": self.env.context,
}
5 changes: 3 additions & 2 deletions agreement_rebate/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- [Tecnativa](https://www.tecnativa.com):

> - Carlos Dauden \<<[email protected]>\>
> - Sergio Teruel \<<[email protected]>\>
> - Carlos Dauden
> - Sergio Teruel
> - Carlos Roca
7 changes: 4 additions & 3 deletions agreement_rebate/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Agreement Rebate</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5b7242b1d8b9588b1724ec1d569cbd0ea5999c7ba01c2223a0efcc0c6a286fa4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/agreement/tree/18.0/agreement_rebate"><img alt="OCA/agreement" src="https://img.shields.io/badge/github-OCA%2Fagreement-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/agreement-18-0/agreement-18-0-agreement_rebate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/agreement&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/agreement/tree/18.0/agreement_rebate"><img alt="OCA/agreement" src="https://img.shields.io/badge/github-OCA%2Fagreement-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/agreement-18-0/agreement-18-0-agreement_rebate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/agreement&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of agreement module to allow
define rebate conditions.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -449,8 +449,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li><p class="first"><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:</p>
<blockquote>
<ul class="simple">
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
<li>Carlos Dauden</li>
<li>Sergio Teruel</li>
<li>Carlos Roca</li>
</ul>
</blockquote>
</li>
Expand Down
2 changes: 1 addition & 1 deletion agreement_rebate/tests/test_agreement_rebate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from freezegun import freeze_time

from odoo import fields
from odoo.tests.common import Form, TransactionCase, tagged
from odoo.tests import Form, TransactionCase, tagged


@freeze_time("2022-02-01 09:30:00")
Expand Down
6 changes: 3 additions & 3 deletions agreement_rebate/views/agreement_condition_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
<field name="name">agreement.rebate.condition.tree</field>
<field name="model">agreement.rebate.condition</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="rebate_domain" groups="base.group_no_one" />
</tree>
</list>
</field>
</record>
<record id="agreement_rebate_condition_action" model="ir.actions.act_window">
<field name="name">Agreement rebate conditions</field>
<field name="res_model">agreement.rebate.condition</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
24 changes: 12 additions & 12 deletions agreement_rebate/views/agreement_rebate_settlement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
<field name="name">agreement.rebate.settlement</field>
<field name="model">agreement.rebate.settlement</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="partner_id" />
<field name="date" />
<field name="date_from" />
<field name="date_to" />
<field name="amount_invoiced" />
<field name="amount_rebate" />
</tree>
</list>
</field>
</record>
<record id="agreement_rebate_settlement_form" model="ir.ui.view">
Expand Down Expand Up @@ -93,7 +93,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<group>
<group>
Expand All @@ -115,34 +115,34 @@
</group>
<group string="Lines">
<field name="line_ids" nolabel="1" colspan="2">
<tree>
<list>
<field name="rebate_type" invisible="1" />
<field name="partner_id" readonly="1" />
<field name="amount_invoiced" />
<field name="percent" />
<field name="amount_rebate" />
<field
name="amount_from"
attrs="{'invisible': [('rebate_type', 'not in', ['section_total', 'section_prorated'])]}"
invisible="rebate_type not in ['section_total', 'section_prorated']"
/>
<field
name="amount_to"
attrs="{'invisible': [('rebate_type', 'not in', ['section_total', 'section_prorated'])]}"
invisible="rebate_type not in ['section_total', 'section_prorated']"
/>
<field name="invoice_status" optional="show" />
<button
name="action_show_detail"
type="object"
icon="fa-table"
title="Show details"
attrs="{'invisible': [('rebate_type', '!=', 'line')]}"
invisible="rebate_type != 'line'"
/>
<field
name="target_domain"
groups="base.group_no_one"
optional="hidden"
/>
</tree>
</list>
</field>
</group>
</sheet>
Expand All @@ -153,7 +153,7 @@
<field name="name">agreement.rebate.settlement.line</field>
<field name="model">agreement.rebate.settlement.line</field>
<field name="arch" type="xml">
<tree create="false" edit="false">
<list create="false" edit="false">
<field name="date" />
<field name="partner_id" />
<field name="agreement_id" />
Expand All @@ -174,7 +174,7 @@
groups="base.group_no_one"
optional="hidden"
/>
</tree>
</list>
</field>
</record>
<record id="agreement_rebate_settlement_line_search" model="ir.ui.view">
Expand Down Expand Up @@ -228,13 +228,13 @@
<record id="agreement_rebate_settlement_action" model="ir.actions.act_window">
<field name="name">Agreement settlements</field>
<field name="res_model">agreement.rebate.settlement</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="context">{'search_default_not_invoiced': 1}</field>
</record>
<record id="agreement_rebate_settlement_line_action" model="ir.actions.act_window">
<field name="name">Agreement settlement lines</field>
<field name="res_model">agreement.rebate.settlement.line</field>
<field name="view_mode">tree,form,pivot</field>
<field name="view_mode">list,form,pivot</field>
<field name="context">{'search_default_not_invoiced': 1}</field>
</record>
</odoo>
42 changes: 16 additions & 26 deletions agreement_rebate/views/agreement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
<field name="inherit_id" ref="agreement.agreement_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page
name="rebate"
string="Rebate"
attrs="{'invisible': [('is_rebate', '=', False)]}"
>
<page name="rebate" string="Rebate" invisible="not is_rebate">
<field name="is_rebate" invisible="1" />
<group>
<group>
Expand All @@ -18,44 +14,38 @@
<group>
<field
name="rebate_discount"
attrs="{'invisible': [('rebate_type', '!=', 'global')]}"
invisible="rebate_type != 'global'"
/>
</group>
</group>
<group
string="Lines"
attrs="{'invisible': [('rebate_type', '=', False)]}"
cols="4"
>
<group string="Lines" invisible="not rebate_type" cols="4">
<p class="text-muted" colspan="2">
<i class="fa fa-filter" />
You can create a filter to apply the rebate.
Categories, products, variants, generic conditions to reuse or a custom filter
<!-- Puede crear un filtro para aplicar el rápel.-->
<!-- Categorías, productos, variantes, condiciones genéricas para reutilizar o un filtro personalizado-->
</p>
<field
name="rebate_line_ids"
context="{'hide_rebate_discount': rebate_type != 'line'}"
nolabel="1"
colspan="2"
>
<tree>
<list create="1" delete="1" edit="1">
<field name="rebate_target" />
<field
name="rebate_domain"
groups="base.group_no_one"
/>
<field
name="rebate_discount"
attrs="{'column_invisible': [('parent.rebate_type', '!=', 'line')]}"
column_invisible="parent.rebate_type != 'line'"
/>
</tree>
</list>
</field>
</group>
<group
string="Sections"
attrs="{'invisible': [('rebate_type', 'not in', ['section_total', 'section_prorated'])]}"
invisible="rebate_type not in ['section_total', 'section_prorated']"
>
<field name="rebate_section_ids" nolabel="1" colspan="2" />
</group>
Expand All @@ -80,11 +70,11 @@
<field name="name">agreement.rebate.line.tree</field>
<field name="model">agreement.rebate.line</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="rebate_target" />
<field name="rebate_domain" groups="base.group_no_one" />
<field name="rebate_discount" />
</tree>
</list>
</field>
</record>
<record id="agreement_rebate_line_form" model="ir.ui.view">
Expand All @@ -108,31 +98,31 @@
<field
name="rebate_product_ids"
widget="many2many_tags"
attrs="{'invisible': [('rebate_target', '!=', 'product')]}"
invisible="rebate_target != 'product'"
nolabel="1"
/>
<field
name="rebate_product_tmpl_ids"
widget="many2many_tags"
attrs="{'invisible': [('rebate_target', '!=', 'product_tmpl')]}"
invisible="rebate_target != 'product_tmpl'"
nolabel="1"
/>
<field
name="rebate_category_ids"
widget="many2many_tags"
attrs="{'invisible': [('rebate_target', '!=', 'category')]}"
invisible="rebate_target != 'category'"
nolabel="1"
/>
<field
name="rebate_condition_id"
attrs="{'invisible': [('rebate_target', '!=', 'condition')]}"
invisible="rebate_target != 'condition'"
nolabel="1"
/>
<field
name="rebate_domain"
widget="domain"
options="{'model': 'account.move.line', 'in_dialog': True}"
attrs="{'invisible': [('rebate_target', '!=', 'domain')]}"
invisible="rebate_target != 'domain'"
nolabel="1"
/>
</group>
Expand All @@ -144,11 +134,11 @@
<field name="name">agreement.rebate.section.tree</field>
<field name="model">agreement.rebate.section</field>
<field name="arch" type="xml">
<tree editable="bottom">
<list editable="bottom">
<field name="amount_from" />
<field name="amount_to" />
<field name="rebate_discount" />
</tree>
</list>
</field>
</record>
</odoo>
4 changes: 2 additions & 2 deletions agreement_rebate/wizards/invoice_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def action_show_invoices(self, invoices):
"type": "ir.actions.act_window",
"name": "Invoices",
"res_model": "account.move",
"view_mode": "tree,kanban,form,calendar,pivot,graph,activity",
"view_mode": "list,kanban,form,calendar,pivot,graph,activity",
"domain": [("id", "in", invoices.ids)],
}
if tree_view and form_view:
action["views"] = [(tree_view.id, "tree"), (form_view.id, "form")]
action["views"] = [(tree_view.id, "list"), (form_view.id, "form")]
return action
4 changes: 3 additions & 1 deletion agreement_rebate/wizards/settlement_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ def _settlement_line_break_fields(self):
def _filter_settlement_lines(self, settlement_lines):
return [
line
for line in filter(lambda l: l[2]["amount_rebate"] != 0.0, settlement_lines)
for line in filter(
lambda sl: sl[2]["amount_rebate"] != 0.0, settlement_lines
)
]

def _prepare_settlement(self, settlement_lines):
Expand Down

0 comments on commit 9a8a3f2

Please sign in to comment.