Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimizzare le modifiche al metodo get_importo. #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion l10n_it_fatturapa_out/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2022 Simone Rubino - TAKOBI
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->

<odoo>
<data>
<!--
Expand Down Expand Up @@ -119,7 +124,7 @@ e 'line' per riga di fattura (a seconda del livello in cui sono chiamati)
</template>

<template id="account_invoice_line_it_sconto_maggiorazione">
<t t-set="importo" t-value="get_importo(line.price_unit, line.discount)" />
<t t-set="importo" t-value="get_importo(line)" />
<ScontoMaggiorazione t-if="line.discount != 0 or importo != 0">
<!-- [2.2.1.10] -->
<t t-if="importo">
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_out/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* `TAKOBI <https://takobi.online>`_:

* Simone Rubino <sir@takobi.online>
8 changes: 5 additions & 3 deletions l10n_it_fatturapa_out/wizard/efattura.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2020 Giuseppe Borruso
# Copyright 2020 Marco Colombo
# Copyright 2022 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
import os
from datetime import datetime
Expand Down Expand Up @@ -257,12 +259,12 @@ def _key(tax_id):
out.update(out_computed)
return out

def get_importo(price_unit, discount):
str_number = str(discount)
def get_importo(line, discount_field='discount'):
str_number = str(line[discount_field])
number = str_number[::-1].find(".")
if number <= 2:
return False
return price_unit * discount / 100
return line.price_unit * line.discount / 100

def get_importo_totale(invoice):
# wrapper to a method in wizard (for better overriding)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2022 Simone Rubino - TAKOBI
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->

<odoo>
<data>
<template
Expand All @@ -8,11 +13,11 @@
<xpath expr="//ScontoMaggiorazione" position="after">
<t
t-set="importo2"
t-value="get_importo(line.price_unit, line.discount2)"
t-value="get_importo(line, discount_field='discount2')"
/>
<t
t-set="importo3"
t-value="get_importo(line.price_unit, line.discount3)"
t-value="get_importo(line, discount_field='discount3')"
/>
<ScontoMaggiorazione t-if="line.discount2 != 0 or importo2 != 0">
<!-- [2.2.1.10] -->
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_out_triple_discount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Simone Rubino
* Alex Comba <alex.comba@agilebg.com>
* Giovanni Serra <giovanni@gslab.it>
* `TAKOBI <https://takobi.online>`_:

* Simone Rubino <sir@takobi.online>