Skip to content

Commit

Permalink
Merge pull request #303 from OCA/16.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/commission (16.0)
  • Loading branch information
bt-admin authored Aug 21, 2023
2 parents aa177df + 3d10594 commit acf9b2b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[account_commission](account_commission/) | 16.0.1.2.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Account commissions
[account_commission](account_commission/) | 16.0.1.4.1 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Account commissions
[commission](commission/) | 16.0.1.2.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Commissions
[hr_commission](hr_commission/) | 16.0.1.0.0 | | HR commissions
[sale_commission](sale_commission/) | 16.0.1.0.1 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Sales commissions
Expand Down
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": "16.0.1.2.0",
"version": "16.0.1.4.1",
"author": "Tecnativa, Odoo Community Association (OCA)",
"category": "Sales Management",
"license": "AGPL-3",
Expand Down
10 changes: 5 additions & 5 deletions account_commission/i18n/account_commission.pot
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ msgstr ""
msgid "Balance"
msgstr ""

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.commission_make_invoice_form
msgid "Cancel"
msgstr ""

#. module: account_commission
#. odoo-python
#: code:addons/account_commission/models/commission_settlement.py:0
Expand Down Expand Up @@ -555,11 +560,6 @@ msgstr ""
msgid "You can't modify a settled line"
msgstr ""

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.commission_make_invoice_form
msgid "_Cancel"
msgstr ""

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.view_invoice_commission_analysis_graph
#: model_terms:ir.ui.view,arch_db:account_commission.view_invoice_commission_analysis_pivot
Expand Down
2 changes: 1 addition & 1 deletion account_commission/i18n/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ msgstr ""

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.commission_make_invoice_form
msgid "_Cancel"
msgid "Cancel"
msgstr ""

#. module: account_commission
Expand Down
4 changes: 2 additions & 2 deletions account_commission/i18n/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ msgstr "精算済明細を修正することはできません"

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.commission_make_invoice_form
msgid "_Cancel"
msgstr "_キャンセル"
msgid "Cancel"
msgstr "キャンセル"

#. module: account_commission
#: model_terms:ir.ui.view,arch_db:account_commission.view_invoice_commission_analysis_graph
Expand Down
7 changes: 7 additions & 0 deletions account_commission/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def fields_view_get(
res["arch"] = etree.tostring(invoice_xml)
return res

def unlink(self):
"""Put 'invoiced' settlements associated to the invoices back in settled state."""
self.invoice_line_ids.settlement_id.filtered(
lambda s: s.state == "invoiced"
).write({"state": "settled"})
return super().unlink()


class AccountMoveLine(models.Model):
_inherit = [
Expand Down
13 changes: 6 additions & 7 deletions account_commission/models/commission_settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ def _prepare_invoice(self, journal, product, date=False):
"product_id": product.id,
"quantity": -1 if settlement.total < 0 else 1,
"price_unit": abs(settlement.total),
"name": (
"\n"
+ _(
"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),
),
"name": product.with_context(lang=lang.code).display_name
+ "\n"
+ _(
"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),
),
# todo or compute agent currency_id?
"currency_id": settlement.currency_id.id,
Expand Down
11 changes: 11 additions & 0 deletions account_commission/tests/test_account_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,14 @@ def test_account_commission_multiple_settlement_ids(self):
settlements.make_invoices(self.journal, self.commission_product, grouped=True)
invoices = settlements.mapped("invoice_id")
self.assertEqual(2, invoices.settlement_count)

def test_unlink_settlement_invoice(self):
settlements = self._create_multi_settlements()
invoices = settlements.make_invoices(self.journal, self.commission_product)
self.assertTrue(
all(state == "invoiced" for state in settlements.mapped("state"))
)
invoices.unlink()
self.assertTrue(
all(state == "settled" for state in settlements.mapped("state"))
)
5 changes: 3 additions & 2 deletions account_commission/views/account_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@
name="recompute_lines_agents"
type="object"
string="Regenerate agents"
states="draft"
attrs="{'invisible': [
('move_type', 'not in', ['out_invoice', 'out_refund'])
'|',
('move_type', 'not in', ['out_invoice', 'out_refund']),
('state', '!=', 'draft')
]}"
/>
</xpath>
Expand Down
7 changes: 6 additions & 1 deletion account_commission/wizards/wizard_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
type="object"
class="oe_highlight"
/>
<button special="cancel" string="_Cancel" class="oe_link" />
<button
special="cancel"
data-hotkey="z"
string="Cancel"
class="oe_link"
/>
</footer>
</form>
</field>
Expand Down

0 comments on commit acf9b2b

Please sign in to comment.