From cd36a22feabfd5d022a42fcfa9b777edd45a729c Mon Sep 17 00:00:00 2001 From: jordan <jordan@le-filament.com> Date: Wed, 5 Jan 2022 15:48:51 +0100 Subject: [PATCH] [update] add invoice idf in res_partner form view --- __init__.py | 1 + models/scop_invoice_idf.py | 2 +- report/__init__.py | 4 ++++ report/account_invoice_all.py | 38 +++++++++++++++++++++++++++++++ wizard/scop_invoice_idf_wizard.py | 2 ++ 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 report/__init__.py create mode 100644 report/account_invoice_all.py diff --git a/__init__.py b/__init__.py index dda4ab1..2a6dab5 100644 --- a/__init__.py +++ b/__init__.py @@ -3,4 +3,5 @@ from . import controllers from . import models +from . import report from . import wizard diff --git a/models/scop_invoice_idf.py b/models/scop_invoice_idf.py index 41d77da..2d2e041 100644 --- a/models/scop_invoice_idf.py +++ b/models/scop_invoice_idf.py @@ -23,7 +23,7 @@ class ScopInvoiceIDF(models.Model): domain=[('is_company', '=', True)]) journal = fields.Char('Journal') writing_date = fields.Date('Date écriture') - piece = fields.Integer('Numéro de pièce comptable') + acc_doc = fields.Char('Numéro de pièce comptable') year = fields.Char('Année') type = fields.Selection([ ('inv', 'Facture'), diff --git a/report/__init__.py b/report/__init__.py new file mode 100755 index 0000000..8c22d98 --- /dev/null +++ b/report/__init__.py @@ -0,0 +1,4 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_invoice_all diff --git a/report/account_invoice_all.py b/report/account_invoice_all.py new file mode 100644 index 0000000..27aa6ca --- /dev/null +++ b/report/account_invoice_all.py @@ -0,0 +1,38 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class ScopAccountInvoiceIDFReport(models.Model): + _inherit = "account.invoice.all" + + def _select(self): + select_str = super(ScopAccountInvoiceIDFReport, self)._select() + select_str += """ + UNION ALL ( + SELECT + id, + null as invoice_id, + writing_date as date_invoice, + writing_date as date_due, + acc_doc as number, + company_id, + partner_id, + null as user_id, + debit as amount_untaxed_signed, + debit as amount_total_signed, + amount_residual as residual_company_signed, + null as payment_mode_id, + 'out_invoice' as type, + CASE + WHEN amount_residual = 0 THEN 'paid' + ELSE 'open' + END AS state + FROM + scop_invoice_idf + WHERE + type = 'inv' + ) + """ + return select_str diff --git a/wizard/scop_invoice_idf_wizard.py b/wizard/scop_invoice_idf_wizard.py index ffcdb56..519036c 100644 --- a/wizard/scop_invoice_idf_wizard.py +++ b/wizard/scop_invoice_idf_wizard.py @@ -143,12 +143,14 @@ class ScopImportIDFWizard(models.TransientModel): lettrage = row['Lettrage N'] year = row['Année'] + acc_doc = row['Pièce'] values = { 'company_id': company_id.id, 'partner_id': partner_id.id, 'journal': journal, 'writing_date': writing_date, + 'acc_doc': acc_doc, 'name': libelle, 'year': year, 'type': line_type, -- GitLab