Skip to content

Commit

Permalink
[14.0][MIG] l10n_it_fatturapa_in Migration to 14.0 from 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMule71 committed Dec 18, 2020
1 parent edf18eb commit 4608797
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 331 deletions.
13 changes: 7 additions & 6 deletions l10n_it_fatturapa_in/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ ITA - Fattura elettronica - Ricezione
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in
:target: https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_in
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_in
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_fatturapa_in
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/12.0
:target: https://runbot.odoo-community.org/runbot/122/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -91,7 +91,7 @@ See also the README file of l10n_it_fatturapa module.

For every supplier, it is possible to set the 'E-bills Detail Level':

- Minimum level: Bill is created with no lines; User will have to create them, according to what specified in the electronic bill
- Minimum level: Bill is created with no lines; User will have to create them, according to what specified in the electronic bill
- Maximum level: Every line contained in electronic bill will create a line in bill

Moreover, in supplier form you can set the 'E-bill Default Product': this product will be used, during generation of bills, when no other possible product is found. Tax and account of bill line will be set according to what configured in the product.
Expand Down Expand Up @@ -152,7 +152,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_in%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_fatturapa_in%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -174,6 +174,7 @@ Contributors
* Sergio Zanchetta <https://github.com/primes2h>
* Giovanni Serra <[email protected]>
* Gianmarco Conte <[email protected]>
* Marco Colombo <https://github.com/TheMule71>

Maintainers
~~~~~~~~~~~
Expand All @@ -188,6 +189,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_in>`_ project on GitHub.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_in>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_in/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "ITA - Fattura elettronica - Ricezione",
"version": "12.0.2.1.3",
"version": "14.0.2.1.3",
"development_status": "Beta",
"category": "Localization/Italy",
"summary": "Ricezione fatture elettroniche",
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_fatturapa_in/i18n/l10n_it_fatturapa_in.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
Expand Down
129 changes: 39 additions & 90 deletions l10n_it_fatturapa_in/models/account.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.exceptions import ValidationError
from odoo.tools import float_compare

import odoo.addons.decimal_precision as dp


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

fatturapa_attachment_in_id = fields.Many2one(
"fatturapa.attachment.in", "E-bill Import File", ondelete="restrict", copy=False
Expand Down Expand Up @@ -42,78 +40,28 @@ class AccountInvoice(models.Model):

e_invoice_received_date = fields.Date(string="E-Bill Received Date")

@api.multi
@api.depends(
"invoice_line_ids.price_subtotal",
"tax_line_ids.amount",
"tax_line_ids.amount_rounding",
"currency_id",
"company_id",
"date_invoice",
"type",
"efatt_rounding",
"line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual",
"line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950
"line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual",
"line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950
"line_ids.debit",
"line_ids.credit",
"line_ids.currency_id",
"line_ids.amount_currency",
"line_ids.amount_residual",
"line_ids.amount_residual_currency",
"line_ids.payment_id.state",
"line_ids.full_reconcile_id",
)
def _compute_amount(self):
super(AccountInvoice, self)._compute_amount()
for inv in self:
if inv.efatt_rounding != 0:
inv.amount_total += inv.efatt_rounding
amount_total_company_signed = inv.amount_total
if (
inv.currency_id
and inv.company_id
and inv.currency_id != inv.company_id.currency_id
):
currency_id = inv.currency_id
amount_total_company_signed = currency_id._convert(
inv.amount_total,
inv.company_id.currency_id,
inv.company_id,
inv.date_invoice or fields.Date.today(),
)
sign = inv.type in ["in_refund", "out_refund"] and -1 or 1
inv.amount_total_company_signed = amount_total_company_signed * sign
sign = inv.move_type in ["in_refund", "out_refund"] and -1 or 1
inv.amount_total_signed = inv.amount_total * sign

@api.model
def invoice_line_move_line_get(self):
"""Append global rounding move lines"""
res = super().invoice_line_move_line_get()

if self.efatt_rounding != 0:
if self.efatt_rounding > 0:
arrotondamenti_account_id = (
self.env.user.company_id.arrotondamenti_passivi_account_id
)
if not arrotondamenti_account_id:
raise UserError(
_("Round down account is not set " "in Accounting Settings")
)
name = _("Rounding down")
else:
arrotondamenti_account_id = (
self.env.user.company_id.arrotondamenti_attivi_account_id
)
if not arrotondamenti_account_id:
raise UserError(
_("Round up account is not set " "in Accounting Settings")
)
name = _("Rounding up")

res.append(
{
"type": "global_rounding",
"name": name,
"price_unit": self.efatt_rounding,
"quantity": 1,
"price": self.efatt_rounding,
"account_id": arrotondamenti_account_id.id,
"invoice_id": self.id,
}
)
return res

@api.multi
def invoice_validate(self):
for invoice in self:
if (
Expand Down Expand Up @@ -216,18 +164,22 @@ def e_inv_dati_ritenuta(self):
return error_message

@api.depends(
"type",
"move_type",
"state",
"fatturapa_attachment_in_id",
"amount_untaxed",
"amount_tax",
"amount_total",
"reference",
"date_invoice",
"ref",
"invoice_date",
)
def _compute_e_invoice_validation_error(self):
self.ensure_one()
self.e_invoice_validation_error = False
self.e_invoice_validation_message = False

bills_to_check = self.filtered(
lambda inv: inv.type in ["in_invoice", "in_refund"]
lambda inv: inv.move_type in ["in_invoice", "in_refund"]
and inv.state in ["draft", "open", "paid"]
and inv.fatturapa_attachment_in_id
)
Expand All @@ -250,29 +202,32 @@ def _compute_e_invoice_validation_error(self):
if error_message:
error_messages.append(error_message)

if bill.e_invoice_reference and bill.reference != bill.e_invoice_reference:
if (
bill.e_invoice_reference
and bill.payment_reference != bill.e_invoice_reference
):
error_messages.append(
_(
"Vendor reference ({bill_vendor_ref}) "
"does not match with "
"e-bill vendor reference ({e_bill_vendor_ref})"
).format(
bill_vendor_ref=bill.reference or "",
bill_vendor_ref=bill.payment_reference or "",
e_bill_vendor_ref=bill.e_invoice_reference,
)
)

if (
bill.e_invoice_date_invoice
and bill.e_invoice_date_invoice != bill.date_invoice
and bill.e_invoice_date_invoice != bill.invoice_date
):
error_messages.append(
_(
"Invoice date ({bill_date_invoice}) "
"does not match with "
"e-bill invoice date ({e_bill_date_invoice})"
).format(
bill_date_invoice=bill.date_invoice or "",
bill_date_invoice=bill.invoice_date or "",
e_bill_date_invoice=bill.e_invoice_date_invoice,
)
)
Expand All @@ -282,27 +237,25 @@ def _compute_e_invoice_validation_error(self):
bill.e_invoice_validation_error = True
bill.e_invoice_validation_message = ",\n".join(error_messages) + "."

@api.multi
def name_get(self):
result = super(AccountInvoice, self).name_get()
res = []
for tup in result:
invoice = self.browse(tup[0])
if invoice.type in ("in_invoice", "in_refund"):
if invoice.move_type in ("in_invoice", "in_refund"):
name = "{}, {}".format(tup[1], invoice.partner_id.name)
if invoice.amount_total_signed:
name += ", {} {}".format(
invoice.amount_total_signed,
invoice.currency_id.symbol,
)
if invoice.origin:
name += ", %s" % invoice.origin
if invoice.invoice_origin:
name += ", %s" % invoice.invoice_origin
res.append((invoice.id, name))
else:
res.append(tup)
return res

@api.multi
def remove_attachment_link(self):
self.ensure_one()
self.fatturapa_attachment_in_id = False
Expand Down Expand Up @@ -359,7 +312,7 @@ def process_negative_lines(self):
# if every line is negative, change them all
for line in self.invoice_line_ids:
line.price_unit = -line.price_unit
self.compute_taxes()
self._recompute_dynamic_lines(recompute_all_taxes=True)


class FatturapaArticleCode(models.Model):
Expand All @@ -379,13 +332,13 @@ class AccountInvoiceLine(models.Model):
# '2.2.1.3', '2.2.1.6', '2.2.1.7',
# '2.2.1.8', '2.1.1.10'
# ]
_inherit = "account.invoice.line"
_inherit = "account.move.line"

fatturapa_attachment_in_id = fields.Many2one(
"fatturapa.attachment.in",
"E-bill Import File",
readonly=True,
related="invoice_id.fatturapa_attachment_in_id",
related="move_id.fatturapa_attachment_in_id",
)


Expand All @@ -400,23 +353,19 @@ class EInvoiceLine(models.Model):
_name = "einvoice.line"
_description = "E-invoice line"
invoice_id = fields.Many2one(
"account.invoice", "Bill", readonly=True, ondelete="cascade"
"account.move", "Bill", readonly=True, ondelete="cascade"
)
line_number = fields.Integer("Line Number", readonly=True)
service_type = fields.Char("Sale Provision Type", readonly=True)
cod_article_ids = fields.One2many(
"fatturapa.article.code", "e_invoice_line_id", "Articles Code", readonly=True
)
name = fields.Char("Description", readonly=True)
qty = fields.Float(
"Quantity", readonly=True, digits=dp.get_precision("Product Unit of Measure")
)
qty = fields.Float("Quantity", readonly=True, digits="Product Unit of Measure")
uom = fields.Char("Unit of measure", readonly=True)
period_start_date = fields.Date("Period Start Date", readonly=True)
period_end_date = fields.Date("Period End Date", readonly=True)
unit_price = fields.Float(
"Unit Price", readonly=True, digits=dp.get_precision("Product Price")
)
unit_price = fields.Float("Unit Price", readonly=True, digits="Product Price")
discount_rise_price_ids = fields.One2many(
"discount.rise.price",
"e_invoice_line_id",
Expand Down
Loading

0 comments on commit 4608797

Please sign in to comment.