From 75e2ff8de25b0c59f7c2087e957ef3e15d6279dd Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Fri, 22 Mar 2024 23:39:59 +0100 Subject: [PATCH] [FIX] account_receipt_sale: invoice word occurrences --- account_receipt_sale/README.rst | 2 +- account_receipt_sale/__manifest__.py | 5 +- .../security/ir.model.access.csv | 2 + .../security/sale_security.xml | 8 ++ .../static/description/index.html | 3 +- account_receipt_sale/views/sale_views.xml | 42 ++++++ .../wizard/sale_make_invoice.py | 25 +++- .../wizard/sale_make_invoice.xml | 123 ++++++++++++++++++ 8 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 account_receipt_sale/security/ir.model.access.csv create mode 100644 account_receipt_sale/security/sale_security.xml create mode 100644 account_receipt_sale/wizard/sale_make_invoice.xml diff --git a/account_receipt_sale/README.rst b/account_receipt_sale/README.rst index 8e032f28c9a5..6f63ff358ea1 100644 --- a/account_receipt_sale/README.rst +++ b/account_receipt_sale/README.rst @@ -7,7 +7,7 @@ Receipts from sales !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:6f068a91ec4cb239575ef3388d18a368a9622ae2763736dd37ecd1adaa9e954c + !! source digest: sha256:0eac2bad09a214cf91e19d6b619ab814d959e7235012f77c1ca17c2470d4eef9 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/account_receipt_sale/__manifest__.py b/account_receipt_sale/__manifest__.py index 98ff6a2a74e9..47ce11dfdf5a 100644 --- a/account_receipt_sale/__manifest__.py +++ b/account_receipt_sale/__manifest__.py @@ -1,6 +1,6 @@ # Copyright 2016-2022 Lorenzo Battistini # Copyright 2018-2019 Simone Rubino -# Copyright 2019 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) +# Copyright 2019-2024 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) # Copyright 2020 Giovanni Serra - GSLab.it # Copyright 2023 Simone Rubino - TAKOBI # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). @@ -23,7 +23,10 @@ "sale", ], "data": [ + "wizard/sale_make_invoice.xml", "views/sale_views.xml", + "security/sale_security.xml", + "security/ir.model.access.csv", ], "pre_init_hook": "rename_old_italian_module", "post_init_hook": "migrate_corrispettivi_data", diff --git a/account_receipt_sale/security/ir.model.access.csv b/account_receipt_sale/security/ir.model.access.csv new file mode 100644 index 000000000000..f7e4e9716197 --- /dev/null +++ b/account_receipt_sale/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_advance_payment_rec,access.sale.advance.payment.rec,model_sale_advance_payment_rec,sales_team.group_sale_salesman,1,1,1,0 diff --git a/account_receipt_sale/security/sale_security.xml b/account_receipt_sale/security/sale_security.xml new file mode 100644 index 000000000000..dd37c98c9f21 --- /dev/null +++ b/account_receipt_sale/security/sale_security.xml @@ -0,0 +1,8 @@ + + + + Sales Advance Payment Receipt Rule + + [('create_uid', '=', user.id)] + + diff --git a/account_receipt_sale/static/description/index.html b/account_receipt_sale/static/description/index.html index f2299904fbf6..dd2415e48947 100644 --- a/account_receipt_sale/static/description/index.html +++ b/account_receipt_sale/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

Receipts from sales

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:6f068a91ec4cb239575ef3388d18a368a9622ae2763736dd37ecd1adaa9e954c +!! source digest: sha256:0eac2bad09a214cf91e19d6b619ab814d959e7235012f77c1ca17c2470d4eef9 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

Based on account_receipt_journal, this module allows to create receipts from sale orders.

diff --git a/account_receipt_sale/views/sale_views.xml b/account_receipt_sale/views/sale_views.xml index f26cf275efeb..1fd4a3f7daf2 100644 --- a/account_receipt_sale/views/sale_views.xml +++ b/account_receipt_sale/views/sale_views.xml @@ -1,6 +1,7 @@ @@ -9,6 +10,7 @@ sale.order.form.receipts sale.order + @@ -25,6 +27,46 @@ + + diff --git a/account_receipt_sale/wizard/sale_make_invoice.py b/account_receipt_sale/wizard/sale_make_invoice.py index a7d4c6979a3c..39ba6010f2ac 100644 --- a/account_receipt_sale/wizard/sale_make_invoice.py +++ b/account_receipt_sale/wizard/sale_make_invoice.py @@ -1,11 +1,30 @@ -from odoo import models +from odoo import fields, models -class SaleAdvancePaymentInv(models.TransientModel): +class SaleAdvancePaymentRec(models.TransientModel): + _name = "sale.advance.payment.rec" _inherit = "sale.advance.payment.inv" + advance_payment_method = fields.Selection(selection="_get_advance_payment_method") + + def _get_advance_payment_method(self): + order_ids = self._context.get("active_ids", []) + orders = self.env["sale.order"].browse(order_ids) + if all(orders.mapped("receipts")): + return [ + ("delivered", "Regular receipt"), + ("percentage", "Down payment (percentage)"), + ("fixed", "Down payment (fixed amount)"), + ] + else: + return [ + ("delivered", "Regular invoice"), + ("percentage", "Down payment (percentage)"), + ("fixed", "Down payment (fixed amount)"), + ] + def _prepare_invoice_values(self, order, name, amount, so_line): - invoice_vals = super(SaleAdvancePaymentInv, self)._prepare_invoice_values( + invoice_vals = super(SaleAdvancePaymentRec, self)._prepare_invoice_values( order, name, amount, so_line ) if order.receipts: diff --git a/account_receipt_sale/wizard/sale_make_invoice.xml b/account_receipt_sale/wizard/sale_make_invoice.xml new file mode 100644 index 000000000000..f132ecb18dea --- /dev/null +++ b/account_receipt_sale/wizard/sale_make_invoice.xml @@ -0,0 +1,123 @@ + + + + + Receipt Orders + sale.advance.payment.rec + +
+

+ Receipts will be created in draft so that you can review + them before validation. +

+ + + + + +
+
+
+
+
+ + + Create receipts + ir.actions.act_window + sale.advance.payment.rec + form + new + + + list + + +