Skip to content

Commit

Permalink
[REF] autoflake fixes, dependency added
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymkv25 committed Oct 17, 2023
1 parent 8c9e889 commit 3b66c20
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions sale_commission_so_based/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===============================
=====================================
Sales commissions based on Sale Order
===============================
=====================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
2 changes: 0 additions & 2 deletions sale_commission_so_based/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import models, wizards
20 changes: 9 additions & 11 deletions sale_commission_so_based/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
4 changes: 2 additions & 2 deletions sale_commission_so_based/models/commission_settlement.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
from odoo import fields, models, api
from odoo import api, fields, models


class CommissionSettlement(models.Model):
_inherit = "commission.settlement"

settlement_type = fields.Selection(
selection_add=[("sale_order", "Sales Orders")],
ondelete={"sale_order": "set default"}
ondelete={"sale_order": "set default"},
)


Expand Down
4 changes: 2 additions & 2 deletions sale_commission_so_based/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<xpath expr="//th[text()='Invoice line']" position="replace">
<th>Commission line</th>
</xpath>
<xpath expr="//table/tbody/tr/td//span[@t-field='l.invoice_line_id']" position="replace">
<xpath
expr="//table/tbody/tr/td//span[@t-field='l.invoice_line_id']"
position="replace"
>
<span t-if="l.invoice_line_id" t-field="l.invoice_line_id" />
<span t-if="l.sale_line_id" t-field="l.sale_line_id" />
</xpath>
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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")
4 changes: 3 additions & 1 deletion sale_commission_so_based/views/commission_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<field name="inherit_id" ref="account_commission.commission_form" />
<field name="arch" type="xml">
<field name="invoice_state" position="attributes">
<attribute name="attrs">{'invisible': [('settlement_type', '=', 'sale_order')]}</attribute>
<attribute
name="attrs"
>{'invisible': [('settlement_type', '=', 'sale_order')]}</attribute>
</field>
</field>
</record>
Expand Down
9 changes: 5 additions & 4 deletions sale_commission_so_based/wizards/commission_make_settle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from odoo import models, fields
from odoo import fields, models


class CommissionMakeSettle(models.TransientModel):
Expand All @@ -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):
Expand All @@ -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,
Expand Down

0 comments on commit 3b66c20

Please sign in to comment.