-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_es_account_import_facturae_purchase
- Loading branch information
Showing
10 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
======================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_move |
73 changes: 73 additions & 0 deletions
73
l10n_es_account_import_facturae_purchase/models/account_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
partner, company, line_data, data | ||
) | ||
data.setdefault("transaction_reference", set()) | ||
if vals.get("facturae_receiver_transaction_reference"): | ||
data["transaction_reference"].add( | ||
vals.get("facturae_receiver_transaction_reference") | ||
) | ||
return vals | ||
|
||
def _purchase_order_facturae_domain(self, purchase_order, vals): | ||
domain = [ | ||
("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( | ||
( | ||
"partner_id.commercial_partner_id", | ||
"=", | ||
partner.commercial_partner_id.id, | ||
) | ||
) | ||
return domain | ||
|
||
def _prepare_vals_invoice_from_attachment_facturae_invoice( | ||
self, partner, company, invoice_data | ||
): | ||
( | ||
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"] | ||
for purchase_order in data.get("transaction_reference"): | ||
new_po = self.env["purchase.order"].search( | ||
self._purchase_order_facturae_domain(purchase_order, vals) | ||
) | ||
if not new_po: | ||
data["messages"].append( | ||
_("Purchase Order %s cannot be processed") % purchase_order | ||
) | ||
purchases |= new_po | ||
data["purchases"] = purchases | ||
if purchases: | ||
vals["invoice_line_ids"] = [] | ||
return vals, context, data | ||
|
||
def _check_invoice_facturae(self, data): | ||
if data.get("purchases") and not self.line_ids: | ||
with Form(self) as f: | ||
for purchase_order in data["purchases"]: | ||
f.purchase_id = purchase_order | ||
return super()._check_invoice_facturae(data) | ||
1 change: 1 addition & 0 deletions
1
l10n_es_account_import_facturae_purchase/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Enric Tobella |
1 change: 1 addition & 0 deletions
1
l10n_es_account_import_facturae_purchase/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
1 change: 1 addition & 0 deletions
1
..._es_account_import_facturae_purchase/odoo/addons/l10n_es_account_import_facturae_purchase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../l10n_es_account_import_facturae_purchase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |