From 1d9e056d34bb469df1408b674eb47e90fc1ab3b2 Mon Sep 17 00:00:00 2001 From: Tran Anh Tuan Date: Thu, 14 Mar 2024 15:15:37 +0700 Subject: [PATCH 1/5] [ADD] shipment_advice_cash_on_delivery: Add action on shipment advice to print cash on delivery invoices --- shipment_advice_cash_on_delivery/README.rst | 88 ++++ shipment_advice_cash_on_delivery/__init__.py | 1 + .../__manifest__.py | 24 + .../models/__init__.py | 3 + .../models/account_payment_mode.py | 10 + .../models/shipment_advice.py | 20 + .../models/stock_picking.py | 45 ++ .../readme/CONFIGURE.rst | 1 + .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 4 + .../static/description/index.html | 435 ++++++++++++++++++ .../tests/__init__.py | 1 + .../test_shipment_advice_cash_on_delivery.py | 231 ++++++++++ .../views/account_payment_mode_views.xml | 17 + .../views/shipment_advice.xml | 30 ++ .../views/stock_picking_views.xml | 20 + 16 files changed, 933 insertions(+) create mode 100644 shipment_advice_cash_on_delivery/README.rst create mode 100644 shipment_advice_cash_on_delivery/__init__.py create mode 100644 shipment_advice_cash_on_delivery/__manifest__.py create mode 100644 shipment_advice_cash_on_delivery/models/__init__.py create mode 100644 shipment_advice_cash_on_delivery/models/account_payment_mode.py create mode 100644 shipment_advice_cash_on_delivery/models/shipment_advice.py create mode 100644 shipment_advice_cash_on_delivery/models/stock_picking.py create mode 100644 shipment_advice_cash_on_delivery/readme/CONFIGURE.rst create mode 100644 shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst create mode 100644 shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst create mode 100644 shipment_advice_cash_on_delivery/static/description/index.html create mode 100644 shipment_advice_cash_on_delivery/tests/__init__.py create mode 100644 shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py create mode 100644 shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml create mode 100644 shipment_advice_cash_on_delivery/views/shipment_advice.xml create mode 100644 shipment_advice_cash_on_delivery/views/stock_picking_views.xml diff --git a/shipment_advice_cash_on_delivery/README.rst b/shipment_advice_cash_on_delivery/README.rst new file mode 100644 index 00000000000..a800eaf77c4 --- /dev/null +++ b/shipment_advice_cash_on_delivery/README.rst @@ -0,0 +1,88 @@ +================================ +Shipment Advice Cash on Delivery +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:402231bc491adcd94e5edba386548075cb5aa8332caa2ca5843f7bea5ba88f0f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--transport-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice_cash_on_delivery + :alt: OCA/stock-logistics-transport +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice_cash_on_delivery + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-transport&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow to mark a payment mode as "cash on delivery". +When the picking is delivered, an invoice is automaticaly generated with the +amount to be paid. +Allows users to print cash on delivery invoices from a shipment advice + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You must mark a payment mode as "cash on delivery". + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* BCIM +* ACSONE SA/NV +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux +* Souheil Bejaoui +* Tuan Tran + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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/stock-logistics-transport `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shipment_advice_cash_on_delivery/__init__.py b/shipment_advice_cash_on_delivery/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/shipment_advice_cash_on_delivery/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/shipment_advice_cash_on_delivery/__manifest__.py b/shipment_advice_cash_on_delivery/__manifest__.py new file mode 100644 index 00000000000..59ae3f21c4e --- /dev/null +++ b/shipment_advice_cash_on_delivery/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) +# Copyright 2023 ACSONE SA/NV +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Shipment Advice Cash on Delivery", + "summary": """This module allows users to print cash on delivery invoices + from a shipment advice""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "BCIM, ACSONE SA/NV, Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-transport", + "depends": [ + "account_payment_sale", + "shipment_advice", + "partner_invoicing_mode_at_shipping", + ], + "data": [ + "views/account_payment_mode_views.xml", + "views/shipment_advice.xml", + "views/stock_picking_views.xml", + ], +} diff --git a/shipment_advice_cash_on_delivery/models/__init__.py b/shipment_advice_cash_on_delivery/models/__init__.py new file mode 100644 index 00000000000..4d956b2e189 --- /dev/null +++ b/shipment_advice_cash_on_delivery/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_payment_mode +from . import shipment_advice +from . import stock_picking diff --git a/shipment_advice_cash_on_delivery/models/account_payment_mode.py b/shipment_advice_cash_on_delivery/models/account_payment_mode.py new file mode 100644 index 00000000000..5725bd11c70 --- /dev/null +++ b/shipment_advice_cash_on_delivery/models/account_payment_mode.py @@ -0,0 +1,10 @@ +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) + +from odoo import fields, models + + +class AccountPaymentMode(models.Model): + _inherit = "account.payment.mode" + + cash_on_delivery = fields.Boolean("Cash on Delivery") + auto_validate_invoice = fields.Boolean() diff --git a/shipment_advice_cash_on_delivery/models/shipment_advice.py b/shipment_advice_cash_on_delivery/models/shipment_advice.py new file mode 100644 index 00000000000..95ad40e1b1d --- /dev/null +++ b/shipment_advice_cash_on_delivery/models/shipment_advice.py @@ -0,0 +1,20 @@ +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class ShipmentAdvice(models.Model): + _inherit = "shipment.advice" + + def print_cash_on_delivery_invoices(self): + done_shipment_advices = self.filtered(lambda s: s.state == "done") + cod_invoices = done_shipment_advices.mapped("loaded_picking_ids").mapped( + "cash_on_delivery_invoice_ids" + ) + if cod_invoices: + return self.env.ref( + "account.account_invoices_without_payment" + ).report_action(cod_invoices) + return {} diff --git a/shipment_advice_cash_on_delivery/models/stock_picking.py b/shipment_advice_cash_on_delivery/models/stock_picking.py new file mode 100644 index 00000000000..75e3ffe471a --- /dev/null +++ b/shipment_advice_cash_on_delivery/models/stock_picking.py @@ -0,0 +1,45 @@ +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) +# Copyright 2023 ACSONE SA/NV +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + cash_on_delivery_invoice_ids = fields.Many2many( + "account.move", string="COD Invoices", copy=False, readonly=True + ) + + def _invoice_at_shipping(self): + self.ensure_one() + res = super()._invoice_at_shipping() + res = res or self.sale_id.payment_mode_id.cash_on_delivery + return res + + def _invoicing_at_shipping_validation(self, invoices): + # COD invoices will be validated automatically + cod_invoices_to_validate = invoices.filtered( + lambda invoice: invoice.payment_mode_id.cash_on_delivery + and invoice.payment_mode_id.auto_validate_invoice + ) + # Non-COD invoices need to check in the call of `super` + invoices_to_validate = invoices.filtered( + lambda invoice: not invoice.payment_mode_id.cash_on_delivery + ) + res = super()._invoicing_at_shipping_validation(invoices_to_validate) + if cod_invoices_to_validate: + res |= cod_invoices_to_validate + return res + + def _invoicing_at_shipping(self): + self.ensure_one() + res = super()._invoicing_at_shipping() + if not isinstance(res, str): + cod_invoices = res.filtered( + lambda inv: inv.payment_mode_id.cash_on_delivery + ) + self.cash_on_delivery_invoice_ids = cod_invoices + return res diff --git a/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst b/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst new file mode 100644 index 00000000000..5a85e16d085 --- /dev/null +++ b/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst @@ -0,0 +1 @@ +You must mark a payment mode as "cash on delivery". diff --git a/shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst b/shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..e0ae86784fb --- /dev/null +++ b/shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Jacques-Etienne Baudoux +* Souheil Bejaoui +* Tuan Tran diff --git a/shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst b/shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..047006f7e69 --- /dev/null +++ b/shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Allow to mark a payment mode as "cash on delivery". +When the picking is delivered, an invoice is automaticaly generated with the +amount to be paid. +Allows users to print cash on delivery invoices from a shipment advice diff --git a/shipment_advice_cash_on_delivery/static/description/index.html b/shipment_advice_cash_on_delivery/static/description/index.html new file mode 100644 index 00000000000..a0bfca033c8 --- /dev/null +++ b/shipment_advice_cash_on_delivery/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Shipment Advice Cash on Delivery + + + +
+

Shipment Advice Cash on Delivery

+ + +

Beta License: AGPL-3 OCA/stock-logistics-transport Translate me on Weblate Try me on Runboat

+

Allow to mark a payment mode as “cash on delivery”. +When the picking is delivered, an invoice is automaticaly generated with the +amount to be paid. +Allows users to print cash on delivery invoices from a shipment advice

+

Table of contents

+ +
+

Configuration

+

You must mark a payment mode as “cash on delivery”.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • BCIM
  • +
  • ACSONE SA/NV
  • +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/stock-logistics-transport project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/shipment_advice_cash_on_delivery/tests/__init__.py b/shipment_advice_cash_on_delivery/tests/__init__.py new file mode 100644 index 00000000000..90b812091e2 --- /dev/null +++ b/shipment_advice_cash_on_delivery/tests/__init__.py @@ -0,0 +1 @@ +from . import test_shipment_advice_cash_on_delivery diff --git a/shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py b/shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py new file mode 100644 index 00000000000..cc5d64f56a7 --- /dev/null +++ b/shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py @@ -0,0 +1,231 @@ +# Copyright 2024 Jacques-Etienne Baudoux (BCIM) +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import Command + +from odoo.addons.queue_job.tests.common import trap_jobs +from odoo.addons.shipment_advice.tests.common import Common + + +class TestShipmentAdviceCashOnDelivery(Common): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.uom_kg = cls.env.ref("uom.product_uom_kgm") + cls.product = cls.env["product.product"].create( + { + "name": "Product COD", + "type": "product", + } + ) + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.company = cls.env.ref("base.main_company") + cls.manual_in = cls.env.ref("account.account_payment_method_manual_in") + cls.journal_c1 = cls.env["account.journal"].create( + { + "name": "J1", + "code": "J1", + "type": "bank", + "company_id": cls.company.id, + "bank_acc_number": "123456", + } + ) + + cls.payment_mode_normal = cls.env.ref( + "account_payment_mode.payment_mode_inbound_dd1" + ) + cls.payment_mode_cod = cls.env["account.payment.mode"].create( + { + "name": "COD", + "bank_account_link": "variable", + "payment_method_id": cls.manual_in.id, + "company_id": cls.company.id, + "fixed_journal_id": cls.journal_c1.id, + "variable_journal_ids": [(6, 0, [cls.journal_c1.id])], + "cash_on_delivery": True, + } + ) + cls.partner_standard = cls.env["res.partner"].create( + {"name": "partner_standard", "invoicing_mode": "standard"} + ) + cls.partner_at_shipping = cls.env["res.partner"].create( + {"name": "partner_at_shipping", "invoicing_mode": "at_shipping"} + ) + cls.company = cls.env.user.company_id + cls.default_pricelist = ( + cls.env["product.pricelist"] + .with_company(cls.company) + .create( + { + "name": "default_pricelist", + "currency_id": cls.company.currency_id.id, + } + ) + ) + cls.env["stock.quant"]._update_available_quantity( + cls.product, cls.warehouse.lot_stock_id, 3 + ) + + def _create_and_process_sale_order(self, dict_val): + # Create and confirm sale order + so = self.env["sale.order"].create(dict_val) + so.action_confirm() + pick = so.picking_ids + + # Process shipment advice & picking + shipment_advice = self.env["shipment.advice"].create( + {"shipment_type": "outgoing"} + ) + self._plan_records_in_shipment(shipment_advice, pick) + self._in_progress_shipment_advice(shipment_advice) + wiz = self._load_records_in_shipment(shipment_advice, pick) + self.assertEqual(wiz.picking_ids, pick) + self.assertFalse(wiz.move_line_ids) + pick.move_ids.write({"quantity_done": 1}) + with trap_jobs() as trap: + pick._action_done() + if trap.jobs_count() > 0: + trap.assert_enqueued_job( + pick._invoicing_at_shipping, + ) + trap.perform_enqueued_jobs() + shipment_advice.action_done() + self.assertEqual(shipment_advice.state, "done") + + return pick, shipment_advice + + def _check_picking_shipment(self, pick, shipment, partner): + self.assertEqual(len(pick.cash_on_delivery_invoice_ids), 1) + cod_invoice = pick.cash_on_delivery_invoice_ids[0] + self.assertEqual(cod_invoice.invoice_partner_display_name, partner.name) + action = shipment.with_context( + discard_logo_check=True + ).print_cash_on_delivery_invoices() + self.assertEqual(action.get("type"), "ir.actions.report") + self.assertEqual(action.get("report_name"), "account.report_invoice") + self.assertEqual(action.get("report_type"), "qweb-pdf") + self.assertEqual( + action.get("context").get("active_ids"), + pick.cash_on_delivery_invoice_ids.ids, + ) + + def test01(self): + """ + Create 1 SO with payment mode cash on delivery for partner without + invoicing at shipping + => Should be listed in picking.cash_on_delivery_invoice_ids + """ + pick, shipment = self._create_and_process_sale_order( + { + "partner_id": self.partner_standard.id, + "partner_invoice_id": self.partner_standard.id, + "partner_shipping_id": self.partner_standard.id, + "order_line": [ + Command.create( + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 1, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ), + ], + "pricelist_id": self.default_pricelist.id, + "picking_policy": "direct", + "payment_mode_id": self.payment_mode_cod.id, + } + ) + + self._check_picking_shipment(pick, shipment, self.partner_standard) + + def test02(self): + """ + Create 1 SO with payment mode cash on delivery for partner with + invoicing at shipping + => Should be listed in picking.cash_on_delivery_invoice_ids + """ + pick, shipment = self._create_and_process_sale_order( + { + "partner_id": self.partner_at_shipping.id, + "partner_invoice_id": self.partner_at_shipping.id, + "partner_shipping_id": self.partner_at_shipping.id, + "order_line": [ + Command.create( + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 1, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ), + ], + "pricelist_id": self.default_pricelist.id, + "picking_policy": "direct", + "payment_mode_id": self.payment_mode_cod.id, + } + ) + + self._check_picking_shipment(pick, shipment, self.partner_at_shipping) + + def test03(self): + """ + Create 1 SO without payment mode cash on delivery for partner with + invoicing at shipping + => Should NOT be listed in picking.cash_on_delivery_invoice_ids + """ + pick, dummy = self._create_and_process_sale_order( + { + "partner_id": self.partner_at_shipping.id, + "partner_invoice_id": self.partner_at_shipping.id, + "partner_shipping_id": self.partner_at_shipping.id, + "order_line": [ + Command.create( + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 2, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ), + ], + "pricelist_id": self.default_pricelist.id, + "picking_policy": "direct", + "payment_mode_id": self.payment_mode_normal.id, + } + ) + + self.assertEqual(len(pick.cash_on_delivery_invoice_ids), 0) + + def test04(self): + """ + Create 1 SO without payment mode cash on delivery for partner without + invoicing at shipping + => Should NOT be listed in picking.cash_on_delivery_invoice_ids + """ + pick, dummy = self._create_and_process_sale_order( + { + "partner_id": self.partner_standard.id, + "partner_invoice_id": self.partner_standard.id, + "partner_shipping_id": self.partner_standard.id, + "order_line": [ + Command.create( + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 2, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ), + ], + "pricelist_id": self.default_pricelist.id, + "picking_policy": "direct", + "payment_mode_id": self.payment_mode_normal.id, + } + ) + + self.assertEqual(len(pick.cash_on_delivery_invoice_ids), 0) diff --git a/shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml b/shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml new file mode 100644 index 00000000000..0d0214ba4f4 --- /dev/null +++ b/shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml @@ -0,0 +1,17 @@ + + + + cash on delivery + account.payment.mode + + + + + + + + + diff --git a/shipment_advice_cash_on_delivery/views/shipment_advice.xml b/shipment_advice_cash_on_delivery/views/shipment_advice.xml new file mode 100644 index 00000000000..50f9a241edf --- /dev/null +++ b/shipment_advice_cash_on_delivery/views/shipment_advice.xml @@ -0,0 +1,30 @@ + + + + + Print COD Invoice + + + code + action = records.print_cash_on_delivery_invoices() + + + + + shipment.advice.view.form.inherit + shipment.advice + + +
+
+
+
+ +
diff --git a/shipment_advice_cash_on_delivery/views/stock_picking_views.xml b/shipment_advice_cash_on_delivery/views/stock_picking_views.xml new file mode 100644 index 00000000000..d67fbcbf61a --- /dev/null +++ b/shipment_advice_cash_on_delivery/views/stock_picking_views.xml @@ -0,0 +1,20 @@ + + + + cash on delivery + stock.picking + + + + + + + + From 08818d93aedaf06476c12c18901eaa2b0227915c Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Thu, 13 Jun 2024 08:43:19 +0200 Subject: [PATCH 2/5] [REF][ADD] partner_invoicing_mode_cash_on_delivery The aim was to extract logic that depends on shipment_advice to have a separate module to manage cash on delivery process independently. --- .../README.rst | 30 ++++----- .../__init__.py | 0 .../__manifest__.py | 10 ++- .../models/__init__.py | 1 - .../models/account_payment_mode.py | 15 +++++ .../models/stock_picking.py | 7 ++- .../readme/CONFIGURE.rst | 2 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 2 +- .../static/description/index.html | 62 +++++++++---------- .../tests/__init__.py | 0 .../test_shipment_advice_cash_on_delivery.py | 47 ++++---------- .../views/account_payment_mode_views.xml | 2 +- .../views/stock_picking_views.xml | 0 .../partner_invoicing_mode_cash_on_delivery | 1 + .../setup.py | 6 ++ .../models/account_payment_mode.py | 10 --- .../models/shipment_advice.py | 20 ------ .../readme/CONFIGURE.rst | 1 - .../views/shipment_advice.xml | 30 --------- 20 files changed, 95 insertions(+), 152 deletions(-) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/README.rst (60%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/__init__.py (100%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/__manifest__.py (65%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/models/__init__.py (67%) create mode 100644 partner_invoicing_mode_cash_on_delivery/models/account_payment_mode.py rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/models/stock_picking.py (83%) create mode 100644 partner_invoicing_mode_cash_on_delivery/readme/CONFIGURE.rst rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/readme/CONTRIBUTORS.rst (73%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/readme/DESCRIPTION.rst (67%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/static/description/index.html (72%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/tests/__init__.py (100%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/tests/test_shipment_advice_cash_on_delivery.py (80%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/views/account_payment_mode_views.xml (90%) rename {shipment_advice_cash_on_delivery => partner_invoicing_mode_cash_on_delivery}/views/stock_picking_views.xml (100%) create mode 120000 setup/partner_invoicing_mode_cash_on_delivery/odoo/addons/partner_invoicing_mode_cash_on_delivery create mode 100644 setup/partner_invoicing_mode_cash_on_delivery/setup.py delete mode 100644 shipment_advice_cash_on_delivery/models/account_payment_mode.py delete mode 100644 shipment_advice_cash_on_delivery/models/shipment_advice.py delete mode 100644 shipment_advice_cash_on_delivery/readme/CONFIGURE.rst delete mode 100644 shipment_advice_cash_on_delivery/views/shipment_advice.xml diff --git a/shipment_advice_cash_on_delivery/README.rst b/partner_invoicing_mode_cash_on_delivery/README.rst similarity index 60% rename from shipment_advice_cash_on_delivery/README.rst rename to partner_invoicing_mode_cash_on_delivery/README.rst index a800eaf77c4..f21e5bd0aab 100644 --- a/shipment_advice_cash_on_delivery/README.rst +++ b/partner_invoicing_mode_cash_on_delivery/README.rst @@ -1,13 +1,13 @@ -================================ -Shipment Advice Cash on Delivery -================================ +======================================= +Partner Invoicing Mode Cash on Delivery +======================================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:402231bc491adcd94e5edba386548075cb5aa8332caa2ca5843f7bea5ba88f0f + !! source digest: sha256:5525b56e6241690abaa44bb465f180508ee6a0af871cd8a3d2232216e25c602c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -16,14 +16,14 @@ Shipment Advice Cash on Delivery .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--transport-lightgray.png?logo=github - :target: https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice_cash_on_delivery - :alt: OCA/stock-logistics-transport +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoicing/tree/16.0/partner_invoicing_mode_cash_on_delivery + :alt: OCA/account-invoicing .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice_cash_on_delivery + :target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-partner_invoicing_mode_cash_on_delivery :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-transport&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -31,7 +31,7 @@ Shipment Advice Cash on Delivery Allow to mark a payment mode as "cash on delivery". When the picking is delivered, an invoice is automaticaly generated with the amount to be paid. -Allows users to print cash on delivery invoices from a shipment advice +Allows users to identify cash on delivery invoices on shippings. **Table of contents** @@ -41,15 +41,16 @@ Allows users to print cash on delivery invoices from a shipment advice Configuration ============= -You must mark a payment mode as "cash on delivery". +You must mark a payment mode as "cash on delivery". If you want the invoice +to be posted at the same moment, check the "Auto validate Invoice When Cash On Delivery" Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -69,6 +70,7 @@ Contributors * Jacques-Etienne Baudoux * Souheil Bejaoui * Tuan Tran +* Denis Roussel Maintainers ~~~~~~~~~~~ @@ -83,6 +85,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/stock-logistics-transport `_ project on GitHub. +This module is part of the `OCA/account-invoicing `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shipment_advice_cash_on_delivery/__init__.py b/partner_invoicing_mode_cash_on_delivery/__init__.py similarity index 100% rename from shipment_advice_cash_on_delivery/__init__.py rename to partner_invoicing_mode_cash_on_delivery/__init__.py diff --git a/shipment_advice_cash_on_delivery/__manifest__.py b/partner_invoicing_mode_cash_on_delivery/__manifest__.py similarity index 65% rename from shipment_advice_cash_on_delivery/__manifest__.py rename to partner_invoicing_mode_cash_on_delivery/__manifest__.py index 59ae3f21c4e..6d8f11f1202 100644 --- a/shipment_advice_cash_on_delivery/__manifest__.py +++ b/partner_invoicing_mode_cash_on_delivery/__manifest__.py @@ -4,21 +4,19 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "Shipment Advice Cash on Delivery", - "summary": """This module allows users to print cash on delivery invoices - from a shipment advice""", + "name": "Partner Invoicing Mode Cash on Delivery", + "summary": """This module allows users to distinguish cash on delivery invoices + in the automatic invoicing flow""", "version": "16.0.1.0.0", "license": "AGPL-3", "author": "BCIM, ACSONE SA/NV, Camptocamp, Odoo Community Association (OCA)", - "website": "https://github.com/OCA/stock-logistics-transport", + "website": "https://github.com/OCA/account-invoicing", "depends": [ "account_payment_sale", - "shipment_advice", "partner_invoicing_mode_at_shipping", ], "data": [ "views/account_payment_mode_views.xml", - "views/shipment_advice.xml", "views/stock_picking_views.xml", ], } diff --git a/shipment_advice_cash_on_delivery/models/__init__.py b/partner_invoicing_mode_cash_on_delivery/models/__init__.py similarity index 67% rename from shipment_advice_cash_on_delivery/models/__init__.py rename to partner_invoicing_mode_cash_on_delivery/models/__init__.py index 4d956b2e189..dd21a50eb9f 100644 --- a/shipment_advice_cash_on_delivery/models/__init__.py +++ b/partner_invoicing_mode_cash_on_delivery/models/__init__.py @@ -1,3 +1,2 @@ from . import account_payment_mode -from . import shipment_advice from . import stock_picking diff --git a/partner_invoicing_mode_cash_on_delivery/models/account_payment_mode.py b/partner_invoicing_mode_cash_on_delivery/models/account_payment_mode.py new file mode 100644 index 00000000000..a595a64bbec --- /dev/null +++ b/partner_invoicing_mode_cash_on_delivery/models/account_payment_mode.py @@ -0,0 +1,15 @@ +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) + +from odoo import fields, models + + +class AccountPaymentMode(models.Model): + _inherit = "account.payment.mode" + + cash_on_delivery = fields.Boolean( + help="Check this if you want to identify Cash On Delivery invoices on stock pickings." + ) + auto_validate_invoice_cash_on_delivery = fields.Boolean( + help="Check this if you want Cash on Delivery deliveries to validate " + "automatically generated invoices." + ) diff --git a/shipment_advice_cash_on_delivery/models/stock_picking.py b/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py similarity index 83% rename from shipment_advice_cash_on_delivery/models/stock_picking.py rename to partner_invoicing_mode_cash_on_delivery/models/stock_picking.py index 75e3ffe471a..23d189bf140 100644 --- a/shipment_advice_cash_on_delivery/models/stock_picking.py +++ b/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py @@ -14,6 +14,11 @@ class StockPicking(models.Model): ) def _invoice_at_shipping(self): + """ + This will take this picking into account for invoice creation (at shipping) + when sale order has Cash On Delivery set and even if the partner is not + using that mode (at shipping). + """ self.ensure_one() res = super()._invoice_at_shipping() res = res or self.sale_id.payment_mode_id.cash_on_delivery @@ -23,7 +28,7 @@ def _invoicing_at_shipping_validation(self, invoices): # COD invoices will be validated automatically cod_invoices_to_validate = invoices.filtered( lambda invoice: invoice.payment_mode_id.cash_on_delivery - and invoice.payment_mode_id.auto_validate_invoice + and invoice.payment_mode_id.auto_validate_invoice_cash_on_delivery ) # Non-COD invoices need to check in the call of `super` invoices_to_validate = invoices.filtered( diff --git a/partner_invoicing_mode_cash_on_delivery/readme/CONFIGURE.rst b/partner_invoicing_mode_cash_on_delivery/readme/CONFIGURE.rst new file mode 100644 index 00000000000..7c8a9108918 --- /dev/null +++ b/partner_invoicing_mode_cash_on_delivery/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +You must mark a payment mode as "cash on delivery". If you want the invoice +to be posted at the same moment, check the "Auto validate Invoice When Cash On Delivery" diff --git a/shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst b/partner_invoicing_mode_cash_on_delivery/readme/CONTRIBUTORS.rst similarity index 73% rename from shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst rename to partner_invoicing_mode_cash_on_delivery/readme/CONTRIBUTORS.rst index e0ae86784fb..d7b17518465 100644 --- a/shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst +++ b/partner_invoicing_mode_cash_on_delivery/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Jacques-Etienne Baudoux * Souheil Bejaoui * Tuan Tran +* Denis Roussel diff --git a/shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst b/partner_invoicing_mode_cash_on_delivery/readme/DESCRIPTION.rst similarity index 67% rename from shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst rename to partner_invoicing_mode_cash_on_delivery/readme/DESCRIPTION.rst index 047006f7e69..f75c701ec88 100644 --- a/shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst +++ b/partner_invoicing_mode_cash_on_delivery/readme/DESCRIPTION.rst @@ -1,4 +1,4 @@ Allow to mark a payment mode as "cash on delivery". When the picking is delivered, an invoice is automaticaly generated with the amount to be paid. -Allows users to print cash on delivery invoices from a shipment advice +Allows users to identify cash on delivery invoices on shippings. diff --git a/shipment_advice_cash_on_delivery/static/description/index.html b/partner_invoicing_mode_cash_on_delivery/static/description/index.html similarity index 72% rename from shipment_advice_cash_on_delivery/static/description/index.html rename to partner_invoicing_mode_cash_on_delivery/static/description/index.html index a0bfca033c8..faf2b1beb50 100644 --- a/shipment_advice_cash_on_delivery/static/description/index.html +++ b/partner_invoicing_mode_cash_on_delivery/static/description/index.html @@ -1,20 +1,20 @@ + - -Shipment Advice Cash on Delivery + +Partner Invoicing Mode Cash on Delivery -
-

Shipment Advice Cash on Delivery

+
+

Partner Invoicing Mode Cash on Delivery

-

Beta License: AGPL-3 OCA/stock-logistics-transport Translate me on Weblate Try me on Runboat

+

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

Allow to mark a payment mode as “cash on delivery”. When the picking is delivered, an invoice is automaticaly generated with the amount to be paid. -Allows users to print cash on delivery invoices from a shipment advice

+Allows users to identify cash on delivery invoices on shippings.

Table of contents

-

Configuration

-

You must mark a payment mode as “cash on delivery”.

+

Configuration

+

You must mark a payment mode as “cash on delivery”. If you want the invoice +to be posted at the same moment, check the “Auto validate Invoice When Cash On Delivery”

-

Bug Tracker

-

Bugs are tracked on GitHub Issues. +

Bug Tracker

+

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

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

-

Credits

+

Credits

-

Authors

+

Authors

  • BCIM
  • ACSONE SA/NV
  • @@ -410,23 +411,22 @@

    Authors

-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

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/stock-logistics-transport project on GitHub.

+

This module is part of the OCA/account-invoicing project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/shipment_advice_cash_on_delivery/tests/__init__.py b/partner_invoicing_mode_cash_on_delivery/tests/__init__.py similarity index 100% rename from shipment_advice_cash_on_delivery/tests/__init__.py rename to partner_invoicing_mode_cash_on_delivery/tests/__init__.py diff --git a/shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py b/partner_invoicing_mode_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py similarity index 80% rename from shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py rename to partner_invoicing_mode_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py index cc5d64f56a7..3bd28e6f649 100644 --- a/shipment_advice_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py +++ b/partner_invoicing_mode_cash_on_delivery/tests/test_shipment_advice_cash_on_delivery.py @@ -4,11 +4,11 @@ from odoo import Command +from odoo.addons.base.tests.common import BaseCommon from odoo.addons.queue_job.tests.common import trap_jobs -from odoo.addons.shipment_advice.tests.common import Common -class TestShipmentAdviceCashOnDelivery(Common): +class TestPartnerInvoiceCashOnDelivery(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() @@ -73,42 +73,17 @@ def _create_and_process_sale_order(self, dict_val): so.action_confirm() pick = so.picking_ids - # Process shipment advice & picking - shipment_advice = self.env["shipment.advice"].create( - {"shipment_type": "outgoing"} - ) - self._plan_records_in_shipment(shipment_advice, pick) - self._in_progress_shipment_advice(shipment_advice) - wiz = self._load_records_in_shipment(shipment_advice, pick) - self.assertEqual(wiz.picking_ids, pick) - self.assertFalse(wiz.move_line_ids) pick.move_ids.write({"quantity_done": 1}) with trap_jobs() as trap: pick._action_done() - if trap.jobs_count() > 0: - trap.assert_enqueued_job( - pick._invoicing_at_shipping, - ) - trap.perform_enqueued_jobs() - shipment_advice.action_done() - self.assertEqual(shipment_advice.state, "done") + trap.perform_enqueued_jobs() - return pick, shipment_advice + return pick - def _check_picking_shipment(self, pick, shipment, partner): + def _check_picking(self, pick, partner): self.assertEqual(len(pick.cash_on_delivery_invoice_ids), 1) cod_invoice = pick.cash_on_delivery_invoice_ids[0] self.assertEqual(cod_invoice.invoice_partner_display_name, partner.name) - action = shipment.with_context( - discard_logo_check=True - ).print_cash_on_delivery_invoices() - self.assertEqual(action.get("type"), "ir.actions.report") - self.assertEqual(action.get("report_name"), "account.report_invoice") - self.assertEqual(action.get("report_type"), "qweb-pdf") - self.assertEqual( - action.get("context").get("active_ids"), - pick.cash_on_delivery_invoice_ids.ids, - ) def test01(self): """ @@ -116,7 +91,7 @@ def test01(self): invoicing at shipping => Should be listed in picking.cash_on_delivery_invoice_ids """ - pick, shipment = self._create_and_process_sale_order( + pick = self._create_and_process_sale_order( { "partner_id": self.partner_standard.id, "partner_invoice_id": self.partner_standard.id, @@ -138,7 +113,7 @@ def test01(self): } ) - self._check_picking_shipment(pick, shipment, self.partner_standard) + self._check_picking(pick, self.partner_standard) def test02(self): """ @@ -146,7 +121,7 @@ def test02(self): invoicing at shipping => Should be listed in picking.cash_on_delivery_invoice_ids """ - pick, shipment = self._create_and_process_sale_order( + pick = self._create_and_process_sale_order( { "partner_id": self.partner_at_shipping.id, "partner_invoice_id": self.partner_at_shipping.id, @@ -168,7 +143,7 @@ def test02(self): } ) - self._check_picking_shipment(pick, shipment, self.partner_at_shipping) + self._check_picking(pick, self.partner_at_shipping) def test03(self): """ @@ -176,7 +151,7 @@ def test03(self): invoicing at shipping => Should NOT be listed in picking.cash_on_delivery_invoice_ids """ - pick, dummy = self._create_and_process_sale_order( + pick = self._create_and_process_sale_order( { "partner_id": self.partner_at_shipping.id, "partner_invoice_id": self.partner_at_shipping.id, @@ -206,7 +181,7 @@ def test04(self): invoicing at shipping => Should NOT be listed in picking.cash_on_delivery_invoice_ids """ - pick, dummy = self._create_and_process_sale_order( + pick = self._create_and_process_sale_order( { "partner_id": self.partner_standard.id, "partner_invoice_id": self.partner_standard.id, diff --git a/shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml b/partner_invoicing_mode_cash_on_delivery/views/account_payment_mode_views.xml similarity index 90% rename from shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml rename to partner_invoicing_mode_cash_on_delivery/views/account_payment_mode_views.xml index 0d0214ba4f4..a173c9a591a 100644 --- a/shipment_advice_cash_on_delivery/views/account_payment_mode_views.xml +++ b/partner_invoicing_mode_cash_on_delivery/views/account_payment_mode_views.xml @@ -8,7 +8,7 @@ diff --git a/shipment_advice_cash_on_delivery/views/stock_picking_views.xml b/partner_invoicing_mode_cash_on_delivery/views/stock_picking_views.xml similarity index 100% rename from shipment_advice_cash_on_delivery/views/stock_picking_views.xml rename to partner_invoicing_mode_cash_on_delivery/views/stock_picking_views.xml diff --git a/setup/partner_invoicing_mode_cash_on_delivery/odoo/addons/partner_invoicing_mode_cash_on_delivery b/setup/partner_invoicing_mode_cash_on_delivery/odoo/addons/partner_invoicing_mode_cash_on_delivery new file mode 120000 index 00000000000..d430887a99e --- /dev/null +++ b/setup/partner_invoicing_mode_cash_on_delivery/odoo/addons/partner_invoicing_mode_cash_on_delivery @@ -0,0 +1 @@ +../../../../partner_invoicing_mode_cash_on_delivery \ No newline at end of file diff --git a/setup/partner_invoicing_mode_cash_on_delivery/setup.py b/setup/partner_invoicing_mode_cash_on_delivery/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/partner_invoicing_mode_cash_on_delivery/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shipment_advice_cash_on_delivery/models/account_payment_mode.py b/shipment_advice_cash_on_delivery/models/account_payment_mode.py deleted file mode 100644 index 5725bd11c70..00000000000 --- a/shipment_advice_cash_on_delivery/models/account_payment_mode.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2018 Jacques-Etienne Baudoux (BCIM) - -from odoo import fields, models - - -class AccountPaymentMode(models.Model): - _inherit = "account.payment.mode" - - cash_on_delivery = fields.Boolean("Cash on Delivery") - auto_validate_invoice = fields.Boolean() diff --git a/shipment_advice_cash_on_delivery/models/shipment_advice.py b/shipment_advice_cash_on_delivery/models/shipment_advice.py deleted file mode 100644 index 95ad40e1b1d..00000000000 --- a/shipment_advice_cash_on_delivery/models/shipment_advice.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2018 Jacques-Etienne Baudoux (BCIM) -# Copyright 2023 ACSONE SA/NV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models - - -class ShipmentAdvice(models.Model): - _inherit = "shipment.advice" - - def print_cash_on_delivery_invoices(self): - done_shipment_advices = self.filtered(lambda s: s.state == "done") - cod_invoices = done_shipment_advices.mapped("loaded_picking_ids").mapped( - "cash_on_delivery_invoice_ids" - ) - if cod_invoices: - return self.env.ref( - "account.account_invoices_without_payment" - ).report_action(cod_invoices) - return {} diff --git a/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst b/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst deleted file mode 100644 index 5a85e16d085..00000000000 --- a/shipment_advice_cash_on_delivery/readme/CONFIGURE.rst +++ /dev/null @@ -1 +0,0 @@ -You must mark a payment mode as "cash on delivery". diff --git a/shipment_advice_cash_on_delivery/views/shipment_advice.xml b/shipment_advice_cash_on_delivery/views/shipment_advice.xml deleted file mode 100644 index 50f9a241edf..00000000000 --- a/shipment_advice_cash_on_delivery/views/shipment_advice.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Print COD Invoice - - - code - action = records.print_cash_on_delivery_invoices() - - - - - shipment.advice.view.form.inherit - shipment.advice - - -
-
-
-
- -
From c3148ba6d21ee44b2b2db5c25172350f21c1a76c Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Thu, 13 Jun 2024 09:22:19 +0200 Subject: [PATCH 3/5] [FIX] partner_invoicing_mode_cash_on_delivery: Avoid relation table collisions --- .../models/stock_picking.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py b/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py index 23d189bf140..d9b447b6cd2 100644 --- a/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py +++ b/partner_invoicing_mode_cash_on_delivery/models/stock_picking.py @@ -10,7 +10,14 @@ class StockPicking(models.Model): _inherit = "stock.picking" cash_on_delivery_invoice_ids = fields.Many2many( - "account.move", string="COD Invoices", copy=False, readonly=True + comodel_name="account.move", + # Force the table relation to avoid naming collisions + relation="stock_picking_cash_on_delivery_move_id_rel", + column1="picking_id", + column2="move_id", + string="COD Invoices", + copy=False, + readonly=True, ) def _invoice_at_shipping(self): From 084b2a8afa7d8e35667d2e1566c627907a3a4df7 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Mon, 17 Jun 2024 10:22:05 +0200 Subject: [PATCH 4/5] [IMP] partner_invoicing_mode_cash_on_delivery: Add Cash On Delivery payment mode data --- .../__manifest__.py | 1 + .../data/account_payment_mode.xml | 17 ++++++++++ .../static/description/index.html | 33 +++++++++---------- 3 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 partner_invoicing_mode_cash_on_delivery/data/account_payment_mode.xml diff --git a/partner_invoicing_mode_cash_on_delivery/__manifest__.py b/partner_invoicing_mode_cash_on_delivery/__manifest__.py index 6d8f11f1202..8e5588384c0 100644 --- a/partner_invoicing_mode_cash_on_delivery/__manifest__.py +++ b/partner_invoicing_mode_cash_on_delivery/__manifest__.py @@ -18,5 +18,6 @@ "data": [ "views/account_payment_mode_views.xml", "views/stock_picking_views.xml", + "data/account_payment_mode.xml", ], } diff --git a/partner_invoicing_mode_cash_on_delivery/data/account_payment_mode.xml b/partner_invoicing_mode_cash_on_delivery/data/account_payment_mode.xml new file mode 100644 index 00000000000..0fc8ff6ba86 --- /dev/null +++ b/partner_invoicing_mode_cash_on_delivery/data/account_payment_mode.xml @@ -0,0 +1,17 @@ + + + + + + Cash On Delivery + + + + variable + + + diff --git a/partner_invoicing_mode_cash_on_delivery/static/description/index.html b/partner_invoicing_mode_cash_on_delivery/static/description/index.html index faf2b1beb50..37af8b004c3 100644 --- a/partner_invoicing_mode_cash_on_delivery/static/description/index.html +++ b/partner_invoicing_mode_cash_on_delivery/static/description/index.html @@ -1,20 +1,19 @@ - - + Partner Invoicing Mode Cash on Delivery