diff --git a/sale_commission_so_based/README.rst b/sale_commission_so_based/README.rst index 4423212ec..24f2cf9c4 100644 --- a/sale_commission_so_based/README.rst +++ b/sale_commission_so_based/README.rst @@ -1,6 +1,6 @@ -=============================== +===================================== Sales commissions based on Sale Order -=============================== +===================================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/sale_commission_so_based/__init__.py b/sale_commission_so_based/__init__.py index cfcc83bb2..64face17a 100644 --- a/sale_commission_so_based/__init__.py +++ b/sale_commission_so_based/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import models, wizards diff --git a/sale_commission_so_based/__manifest__.py b/sale_commission_so_based/__manifest__.py index 9a9a0926f..48837aa63 100644 --- a/sale_commission_so_based/__manifest__.py +++ b/sale_commission_so_based/__manifest__.py @@ -1,16 +1,14 @@ # Copyright 2016-2022 Tecnativa - Pedro M. Baeza { - 'name': "Sales commissions based on Sale Order", - + "name": "Sales commissions based on Sale Order", "author": "Opsway, " "Odoo Community Association (OCA)", - 'license': "AGPL-3", - 'website': "https://github.com/OCA/commission", - 'category': 'Sales Management', - 'version': '16.0.1.0.0', - - 'depends': ['sale_commission'], - 'data': [ - 'reports/report_settlement_templates.xml', - 'views/commission_views.xml', + "license": "AGPL-3", + "website": "https://github.com/OCA/commission", + "category": "Sales Management", + "version": "16.0.1.0.0", + "depends": ["sale_commission", "account_commission"], + "data": [ + "reports/report_settlement_templates.xml", + "views/commission_views.xml", ], } diff --git a/sale_commission_so_based/models/commission_settlement.py b/sale_commission_so_based/models/commission_settlement.py index aa7bd5abb..772f8c9af 100644 --- a/sale_commission_so_based/models/commission_settlement.py +++ b/sale_commission_so_based/models/commission_settlement.py @@ -1,5 +1,5 @@ # Copyright 2014-2022 Tecnativa - Pedro M. Baeza -from odoo import fields, models, api +from odoo import api, fields, models class CommissionSettlement(models.Model): @@ -7,7 +7,7 @@ class CommissionSettlement(models.Model): settlement_type = fields.Selection( selection_add=[("sale_order", "Sales Orders")], - ondelete={"sale_order": "set default"} + ondelete={"sale_order": "set default"}, ) diff --git a/sale_commission_so_based/models/sale_order.py b/sale_commission_so_based/models/sale_order.py index 97270c3a0..1680e4552 100644 --- a/sale_commission_so_based/models/sale_order.py +++ b/sale_commission_so_based/models/sale_order.py @@ -1,5 +1,5 @@ # Copyright 2014-2022 Tecnativa - Pedro M. Baeza -from odoo import api, fields, models, exceptions, _ +from odoo import _, api, exceptions, fields, models class SaleOrderLineAgent(models.Model): @@ -65,7 +65,7 @@ def _skip_settlement(self): :return: bool """ self.ensure_one() - return self.order_id.state not in ('sale', 'done') + return self.order_id.state not in ("sale", "done") @api.depends("order_id", "order_id.date_order") def _compute_invoice_date(self): diff --git a/sale_commission_so_based/reports/report_settlement_templates.xml b/sale_commission_so_based/reports/report_settlement_templates.xml index 932d36c82..3111a6546 100644 --- a/sale_commission_so_based/reports/report_settlement_templates.xml +++ b/sale_commission_so_based/reports/report_settlement_templates.xml @@ -7,7 +7,10 @@ Commission line - + diff --git a/sale_commission_so_based/tests/test_sale_commission_based_on_so.py b/sale_commission_so_based/tests/test_sale_commission_based_on_so.py index c04f39077..234d7cbf8 100644 --- a/sale_commission_so_based/tests/test_sale_commission_based_on_so.py +++ b/sale_commission_so_based/tests/test_sale_commission_based_on_so.py @@ -1,11 +1,10 @@ # Copyright 2016-2022 Tecnativa - Pedro M. Baeza -from odoo.tests import Form, tagged +from odoo.tests import tagged from odoo.addons.sale_commission.tests.test_sale_commission import TestSaleCommission @tagged("post_install", "-at_install") class TestSaleCommissionBasedOnSO(TestSaleCommission): - def _settle_agent_sale_order(self, agent=None, period=None, date=None): vals = self._get_make_settle_vals(agent, period, date) vals["settlement_type"] = "sale_order" @@ -32,4 +31,4 @@ def test_sale_commission_so_based(self): settlement = self.settle_model.search([("state", "=", "settled")]) self.assertEqual(len(settlement), 1) - self.assertEqual(settlement.settlement_type, 'sale_order') + self.assertEqual(settlement.settlement_type, "sale_order") diff --git a/sale_commission_so_based/views/commission_views.xml b/sale_commission_so_based/views/commission_views.xml index ee7bb4db9..d5d5e6585 100644 --- a/sale_commission_so_based/views/commission_views.xml +++ b/sale_commission_so_based/views/commission_views.xml @@ -6,7 +6,9 @@ - {'invisible': [('settlement_type', '=', 'sale_order')]} + {'invisible': [('settlement_type', '=', 'sale_order')]} diff --git a/sale_commission_so_based/wizards/commission_make_settle.py b/sale_commission_so_based/wizards/commission_make_settle.py index 454923406..102b08d21 100644 --- a/sale_commission_so_based/wizards/commission_make_settle.py +++ b/sale_commission_so_based/wizards/commission_make_settle.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -from odoo import models, fields +from odoo import fields, models class CommissionMakeSettle(models.TransientModel): @@ -14,7 +13,9 @@ def _get_agent_lines(self, agent, date_to_agent): """Filter sales order agent lines for this type of settlement.""" if self.settlement_type == "sale_order": domain = self._get_account_settle_domain(agent, date_to_agent) - return self.env["sale.order.line.agent"].search(domain, order="invoice_date") + return self.env["sale.order.line.agent"].search( + domain, order="invoice_date" + ) return super()._get_agent_lines(agent, date_to_agent) def _get_account_settle_domain(self, agent, date_to_agent): @@ -29,7 +30,7 @@ def _prepare_settlement_line_vals(self, settlement, line): """Prepare extra settlement values when the source is a sales order agent line.""" res = super()._prepare_settlement_line_vals(settlement, line) if self.settlement_type == "sale_order": - res.pop('invoice_agent_line_id', None) + res.pop("invoice_agent_line_id", None) res.update( { "sale_agent_line_id": line.id,