Skip to content

Commit

Permalink
[MIG] account_commission: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Dec 6, 2024
1 parent b46871b commit 1b9a9c7
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 41 deletions.
10 changes: 5 additions & 5 deletions account_commission/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Account commissions
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github
:target: https://github.com/OCA/commission/tree/17.0/account_commission
:target: https://github.com/OCA/commission/tree/18.0/account_commission
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/commission-17-0/commission-17-0-account_commission
:target: https://translation.odoo-community.org/projects/commission-18-0/commission-18-0-account_commission
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -103,7 +103,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20account_commission%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20account_commission%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -168,6 +168,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza|

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/17.0/account_commission>`_ project on GitHub.
This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/18.0/account_commission>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_commission/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
{
"name": "Account commissions",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"category": "Sales Management",
"license": "AGPL-3",
Expand Down
6 changes: 3 additions & 3 deletions account_commission/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo import _, api, exceptions, fields, models
from odoo import api, exceptions, fields, models


class AccountMove(models.Model):
Expand Down Expand Up @@ -78,7 +78,7 @@ def button_cancel(self):
"""
if any(self.mapped("invoice_line_ids.any_settled")):
raise exceptions.ValidationError(
_("You can't cancel an invoice with settled lines"),
self.env._("You can't cancel an invoice with settled lines"),
)
self.mapped("line_ids.settlement_id").write({"state": "except_invoice"})
return super().button_cancel()
Expand Down Expand Up @@ -215,7 +215,7 @@ def _check_settle_integrity(self):
for record in self:
if any(record.mapped("settled")):
raise exceptions.ValidationError(
_("You can't modify a settled line"),
record.env._("You can't modify a settled line"),
)

def _skip_settlement(self):
Expand Down
10 changes: 5 additions & 5 deletions account_commission/models/commission_settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools import groupby

Expand Down Expand Up @@ -51,7 +51,7 @@ def _compute_invoice_id(self):
def action_cancel(self):
"""Check if any settlement has been invoiced."""
if any(x.state != "settled" for x in self):
raise UserError(_("Cannot cancel an invoiced settlement."))
raise UserError(self.env._("Cannot cancel an invoiced settlement."))
return super().action_cancel()

def action_draft(self):
Expand All @@ -60,13 +60,13 @@ def action_draft(self):
def unlink(self):
"""Allow to delete only cancelled settlements."""
if any(x.state == "invoiced" for x in self):
raise UserError(_("You can't delete invoiced settlements."))
raise UserError(self.env._("You can't delete invoiced settlements."))
return super().unlink()

def action_invoice(self):
return {
"type": "ir.actions.act_window",
"name": _("Make invoice"),
"name": self.env._("Make invoice"),
"res_model": "commission.make.invoice",
"target": "new",
"view_mode": "form",
Expand Down Expand Up @@ -110,7 +110,7 @@ def _prepare_invoice(self, journal, product, date=False):
"price_unit": abs(settlement.total),
"name": product.with_context(lang=lang.code).display_name
+ "\n"
+ _(
+ settlement.env._(
"Period: from %(date_from)s to %(date_to)s",
date_from=date_from.strftime(lang.date_format),
date_to=date_to.strftime(lang.date_format),
Expand Down
17 changes: 10 additions & 7 deletions account_commission/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Account commissions</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0fb13edf183d9d1ecf7c4415929fabd687f91bd51e719c0e149a7148c57da4ef
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/commission/tree/17.0/account_commission"><img alt="OCA/commission" src="https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/commission-17-0/commission-17-0-account_commission"><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/commission&amp;target_branch=17.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="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/commission/tree/18.0/account_commission"><img alt="OCA/commission" src="https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/commission-18-0/commission-18-0-account_commission"><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/commission&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 adds the function to calculate commissions in invoices
(account moves).</p>
<p>It also allows to create vendor bills from settlements for external
Expand Down Expand Up @@ -451,7 +452,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/commission/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/commission/issues/new?body=module:%20account_commission%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/commission/issues/new?body=module:%20account_commission%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -499,13 +500,15 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/pedrobaeza"><img alt="pedrobaeza" src="https://github.com/pedrobaeza.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/commission/tree/17.0/account_commission">OCA/commission</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/commission/tree/18.0/account_commission">OCA/commission</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions account_commission/tests/test_account_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUpClass(cls):
)
cls.default_line_account = cls.env["account.account"].search(
[
("company_id", "=", cls.company.id),
("company_ids", "in", cls.company.id),
("account_type", "=", "asset_receivable"),
],
limit=1,
Expand All @@ -53,7 +53,7 @@ def setUpClass(cls):
)
cls.income_account = cls.env["account.account"].search(
[
("company_id", "=", cls.company.id),
("company_ids", "in", cls.company.id),
("account_type", "=", "income"),
],
limit=1,
Expand Down
16 changes: 8 additions & 8 deletions account_commission/views/account_move_views.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- This view is needed for proper visualization of the popup / embedded one2many -->
<record id="invoice_line_agent_tree" model="ir.ui.view">
<record id="invoice_line_agent_list" model="ir.ui.view">
<field name="model">account.invoice.line.agent</field>
<field name="arch" type="xml">
<tree editable="bottom">
<list editable="bottom">
<field name="agent_id" context="{'default_agent': True}" />
<field
name="commission_id"
Expand All @@ -16,14 +16,14 @@
options="{'currency_field': 'currency_id'}"
/>
<field name="currency_id" column_invisible="1" />
</tree>
</list>
</field>
</record>
<record id="view_move_line_form" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='blocked']/.." position="after">
<xpath expr="//field[@name='product_id']/.." position="after">
<field name="settlement_id" invisible="1" />
<group
string="Commissions"
Expand Down Expand Up @@ -59,7 +59,7 @@
</button>
</xpath>
<xpath
expr="//field[@name='invoice_line_ids']/tree//field[@name='price_subtotal']"
expr="//field[@name='invoice_line_ids']/list//field[@name='price_subtotal']"
position="after"
>
<field name="settlement_id" column_invisible="1" />
Expand Down Expand Up @@ -87,7 +87,7 @@
/>
</xpath>
<!-- Needed for fields in invoice lines to be saved -->
<xpath expr="//field[@name='line_ids']/tree" position="inside">
<xpath expr="//field[@name='line_ids']/list" position="inside">
<field name="settlement_id" column_invisible="1" />
<field name="commission_free" column_invisible="1" />
<field name="any_settled" column_invisible="1" />
Expand All @@ -103,8 +103,8 @@
</field>
</field>
</record>
<record id="view_in_invoice_bill_tree_inherit" model="ir.ui.view">
<field name="name">account.out.invoice.tree</field>
<record id="view_in_invoice_bill_list_inherit" model="ir.ui.view">
<field name="name">account.out.invoice.list</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_in_invoice_bill_tree" />
<field name="arch" type="xml">
Expand Down
14 changes: 7 additions & 7 deletions account_commission/views/commission_settlement_views.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="view_settlement_tree">
<field name="name">Settlements tree - Invoice decoration</field>
<record model="ir.ui.view" id="view_settlement_list">
<field name="name">Settlements list - Invoice decoration</field>
<field name="model">commission.settlement</field>
<field name="inherit_id" ref="commission.view_settlement_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<list position="attributes">
<attribute name="decoration-muted">state == 'invoiced'</attribute>
<attribute
name="decoration-danger"
>state == 'except_invoice'</attribute>
</tree>
</list>
</field>
</record>
<record model="ir.ui.view" id="view_settlement_form">
Expand Down Expand Up @@ -43,7 +43,7 @@
/>
</field>
<xpath
expr="//field[@name='line_ids']/tree/field[@name='date']"
expr="//field[@name='line_ids']/list/field[@name='date']"
position="after"
>
<field
Expand All @@ -54,7 +54,7 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_settlement_line_tree_inherit">
<record model="ir.ui.view" id="view_settlement_line_list_inherit">
<field name="name">Settlement lines</field>
<field name="model">commission.settlement.line</field>
<field name="inherit_id" ref="commission.view_settlement_line_tree" />
Expand All @@ -68,7 +68,7 @@
<field name="name">Invoices Settlements</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">commission.settlement</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="domain">[('settlement_type', '=', 'sale_invoice')]</field>
</record>
<menuitem
Expand Down
8 changes: 5 additions & 3 deletions account_commission/wizards/wizard_invoice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import _, exceptions, fields, models
from odoo import exceptions, fields, models


class CommissionMakeInvoice(models.TransientModel):
Expand All @@ -25,7 +25,9 @@ def _default_settlement_ids(self):
]
)
if not settlements:
raise exceptions.UserError(_("No valid settlements to invoice."))
raise exceptions.UserError(
self.env._("No valid settlements to invoice.")
)
return settlements.ids
return self.env.context.get("settlement_ids", [])

Expand Down Expand Up @@ -77,7 +79,7 @@ def button_create(self):
# go to results
if len(settlements):
return {
"name": _("Created Invoices"),
"name": self.env._("Created Invoices"),
"type": "ir.actions.act_window",
"views": [[False, "list"], [False, "form"]],
"res_model": "account.move",
Expand Down

0 comments on commit 1b9a9c7

Please sign in to comment.