Skip to content

Commit

Permalink
[IMP] l10n_it_sale_commission_riba: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
odooNextev authored and matteonext committed Mar 23, 2023
1 parent c626f2c commit 201101a
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 50 deletions.
30 changes: 15 additions & 15 deletions l10n_it_sale_commission_riba/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Italian Localization - Sale commission - Ri.Ba',
'summary': 'Modulo ponte tra provvigioni agenti e Ri.Ba',
'version': '12.0.1.0.0',
'category': 'Sales',
'website': 'https://github.com/OCA/l10n-italy',
'author': 'Nextev Srl, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': [
'sale_commission',
'l10n_it_ricevute_bancarie',
"name": "Italian Localization - Sale commission - Ri.Ba",
"summary": "Modulo ponte tra provvigioni agenti e Ri.Ba",
"version": "14.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/l10n-italy",
"author": "Nextev Srl, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"sale_commission",
"l10n_it_ricevute_bancarie",
],
'data': [
'views/invoice_no_commission.xml',
'views/configuration_riba_view.xml',
"data": [
"views/invoice_no_commission.xml",
"views/configuration_riba_view.xml",
],
}
2 changes: 1 addition & 1 deletion l10n_it_sale_commission_riba/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import account_invoice
from . import account_move
from . import riba_config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from odoo import fields, models


class AccountInvoice(models.Model):
_inherit = "account.invoice"
class AccountMove(models.Model):
_inherit = "account.move"

no_commission = fields.Boolean(string="Don't consider commissions")
2 changes: 1 addition & 1 deletion l10n_it_sale_commission_riba/models/riba_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import fields, models


class RibaConfiguration(models.Model):
Expand Down
10 changes: 5 additions & 5 deletions l10n_it_sale_commission_riba/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
**Italiano**

Il modulo permette di integrare il pagamento riba con le commissioni agenti.
Il modulo permette di integrare il pagamento riba con le commissioni agenti.

Una fattura con termini di pagamento Riba ed emissione con tipologia
"Salvo buon fine" verrà presa in considerazione nella generazione delle
provvigioni agente solamente trascorsi i giorni configurati nel campo
Una fattura con termini di pagamento Riba ed emissione con tipologia
"Salvo buon fine" verrà presa in considerazione nella generazione delle
provvigioni agente solamente trascorsi i giorni configurati nel campo
"Giorni di sicurezza" nella configurazione ri.ba.

E' possibile inserire aggiungere "Senza commissioni" ad una fattura, in modo
Expand All @@ -20,4 +20,4 @@ agent commissions only after the days configured in the field "Safety Days"
in ri.ba configuration.

It is possible to add "Without commissions" to an invoice, in this way
that no agent commissions are generated.
that no agent commissions are generated.
14 changes: 10 additions & 4 deletions l10n_it_sale_commission_riba/views/configuration_riba_view.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="riba_safety_days">
<field name="name">riba.conf.form.safety.days</field>
<field name="model">riba.configuration</field>
<field name="inherit_id" ref="l10n_it_ricevute_bancarie.view_riba_configuration_form"/>
<field
name="inherit_id"
ref="l10n_it_ricevute_bancarie.view_riba_configuration_form"
/>
<field name="arch" type="xml">
<field name="type" position="after">
<field name="safety_days" attrs="{'invisible': [('type', '!=', 'sbf')]}"/>
<field
name="safety_days"
attrs="{'invisible': [('type', '!=', 'sbf')]}"
/>
</field>
</field>
</record>
</odoo>
</odoo>
12 changes: 6 additions & 6 deletions l10n_it_sale_commission_riba/views/invoice_no_commission.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="invoice_no_commission_form">
<field name="name">invoice.no.commission.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<field name="team_id" position="after">
<field name="no_commission"/>
</field>
<group id="header_right_group" position="inside">
<field name="no_commission" />
</group>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from datetime import date, timedelta

from odoo import models


class SaleCommissionMakeSettle(models.TransientModel):
_inherit = "sale.commission.make.settle"

def _get_agent_lines(self, agent, date_to_agent):
"""
Exclude outstanding invoices, those with Ri.Ba subject to collection payment
if at least safety days haven't passed since expiration date and those that
have manually set the flag 'no_commission' (for example if it has been
outstanding for years now).
Exclude outstanding invoices, those with Ri.Ba subject to collection payment
if at least safety days haven't passed since expiration date and those that
have manually set the flag 'no_commission' (for example if it has been
outstanding for years now).
"""
agent_lines = super()._get_agent_lines(agent, date_to_agent)
# rimuove righe delle fatture che hanno impostato flag "no_commission"
agent_lines = agent_lines.filtered(lambda al: not al.invoice.no_commission)
agent_lines = agent_lines.filtered(lambda al: not al.invoice_id.no_commission)
for line in agent_lines:
# filtro su Ri.Ba
if line.invoice.payment_term_id.riba:
if line.invoice_id.invoice_payment_term_id.riba:
# rimuove le righe se ri.ba è insoluta o nel caso sia sbf non siano
# passati almeno i giorni di sicurezza da data di scadenza del pagamento
# per tenersi un margine e verificare che sia stata pagata
riba_mv_line = self.env['riba.distinta.move.line'].search([
('move_line_id.invoice_id', '=', line.invoice.id)
])
riba_mv_line = self.env["riba.distinta.move.line"].search(
[("move_line_id.move_id", "=", line.invoice_id.id)]
)
riba_type = riba_mv_line.riba_line_id.type
if line.commission.invoice_state == 'paid' and (
line.invoice.is_unsolved or (
(line.invoice.date_due + timedelta(
days=riba_mv_line.riba_line_id.config_id.safety_days)
> date.today())
and riba_type == 'sbf')):
if line.commission_id.invoice_state == "paid" and (
line.invoice_id.is_unsolved
or (
(
line.invoice_id.invoice_date_due
+ timedelta(
days=riba_mv_line.riba_line_id.config_id.safety_days
)
> date.today()
)
and riba_type == "sbf"
)
):
agent_lines -= line
return agent_lines
6 changes: 6 additions & 0 deletions setup/l10n_it_sale_commission_riba/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pdfminer.six # needed by attachment_indexation module
odoo14-addon-l10n_it_sale_commission_riba @ git+https://github.com/OCA/commission.git@refs/pull/407/head#subdirectory=setup/sale_commission

0 comments on commit 201101a

Please sign in to comment.