Skip to content

Commit

Permalink
[ADD] l10n_es_account_import_facturae_purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Sep 15, 2023
1 parent 3826c19 commit c846056
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 0 deletions.
7 changes: 7 additions & 0 deletions l10n_es_account_import_facturae_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

========================================
L10n Es Account Import Facturae Purchase
========================================
1 change: 1 addition & 0 deletions l10n_es_account_import_facturae_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions l10n_es_account_import_facturae_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 CreuBlanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "L10n Es Account Import Facturae Purchase",
"summary": """
Integrate purchase and import of facturae""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "CreuBlanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"depends": ["l10n_es_account_import_facturae", "purchase"],
"auto_install": True,
"data": [],
"demo": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
73 changes: 73 additions & 0 deletions l10n_es_account_import_facturae_purchase/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2023 CreuBlanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo.tests import Form


class AccountMove(models.Model):

_inherit = "account.move"

def _prepare_vals_invoice_from_attachment_facturae_invoice_line(
self, partner, company, line_data, data
):
vals = super()._prepare_vals_invoice_from_attachment_facturae_invoice_line(

Check warning on line 15 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L15

Added line #L15 was not covered by tests
partner, company, line_data, data
)
data.setdefault("transaction_reference", set())

Check warning on line 18 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L18

Added line #L18 was not covered by tests
if vals.get("facturae_receiver_transaction_reference"):
data["transaction_reference"].add(

Check warning on line 20 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L20

Added line #L20 was not covered by tests
vals.get("facturae_receiver_transaction_reference")
)
return vals

Check warning on line 23 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L23

Added line #L23 was not covered by tests

def _purchase_order_facturae_domain(self, purchase_order, vals):
domain = [

Check warning on line 26 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L26

Added line #L26 was not covered by tests
("name", "=", purchase_order),
("state", "in", ["purchase", "done"]),
("invoice_status", "=", "to invoice"),
]
if vals.get("partner_id"):
partner = self.env["res.partner"].browse(vals.get("partner_id"))
domain.append(

Check warning on line 33 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L32-L33

Added lines #L32 - L33 were not covered by tests
(
"partner_id.commercial_partner_id",
"=",
partner.commercial_partner_id.id,
)
)
return domain

Check warning on line 40 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L40

Added line #L40 was not covered by tests

def _prepare_vals_invoice_from_attachment_facturae_invoice(
self, partner, company, invoice_data
):
(

Check warning on line 45 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L45

Added line #L45 was not covered by tests
vals,
context,
data,
) = super()._prepare_vals_invoice_from_attachment_facturae_invoice(
partner, company, invoice_data
)
if data.get("transaction_reference"):
purchases = self.env["purchase.order"]

Check warning on line 53 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L53

Added line #L53 was not covered by tests
for purchase_order in data.get("transaction_reference"):
new_po = self.env["purchase.order"].search(

Check warning on line 55 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L55

Added line #L55 was not covered by tests
self._purchase_order_facturae_domain(purchase_order, vals)
)
if not new_po:
data["messages"].append(

Check warning on line 59 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L59

Added line #L59 was not covered by tests
_("Purchase Order %s cannot be processed") % purchase_order
)
purchases |= new_po
data["purchases"] = purchases

Check warning on line 63 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L62-L63

Added lines #L62 - L63 were not covered by tests
if purchases:
vals["invoice_line_ids"] = []
return vals, context, data

Check warning on line 66 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L65-L66

Added lines #L65 - L66 were not covered by tests

def _check_invoice_facturae(self, data):
if data.get("purchases") and not self.line_ids:
with Form(self) as f:

Check warning on line 70 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L70

Added line #L70 was not covered by tests
for purchase_order in data["purchases"]:
f.purchase_id = purchase_order
return super()._check_invoice_facturae(data)

Check warning on line 73 in l10n_es_account_import_facturae_purchase/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_account_import_facturae_purchase/models/account_move.py#L72-L73

Added lines #L72 - L73 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Enric Tobella
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Este módulo permite integrar el módulo de compras con el de importación de facturas en formato facturae.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions setup/l10n_es_account_import_facturae_purchase/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,
)

0 comments on commit c846056

Please sign in to comment.