diff --git a/gitoo.yml b/gitoo.yml index bb9f857..5b05143 100644 --- a/gitoo.yml +++ b/gitoo.yml @@ -29,6 +29,11 @@ includes: - date_range +- url: https://github.com/OCA/stock-logistics-workflow + branch: "14.0" + includes: + - stock_picking_invoice_link + - url: https://github.com/OCA/web branch: "14.0" includes: diff --git a/invoice_per_delivery/README.rst b/invoice_per_delivery/README.rst index 9573433..daf05dc 100644 --- a/invoice_per_delivery/README.rst +++ b/invoice_per_delivery/README.rst @@ -2,12 +2,19 @@ Invoice Per Delivery ==================== This module provides the possibility to create an invoice per delivery order for specific partners. +This module depends of the module `stock_picking_invoice_link `_ to add a link between pickings and invoices as well as on the lines. + +With this module, you can find back which deliveries an invoice relates to. + +Note that the links are only for products with an invoicing policy set on delivery. + .. contents:: Table of Contents Usage ----- -From a contact form view, you can now check the checkbox Invoicing per delivery to generate an invoice for each delivery order of this client: +From a contact form view, you can now check the checkbox Invoicing per delivery +to generate an invoice for each delivery order of this client: .. image:: static/description/invoicing_per_delivery_checkbox.png @@ -18,12 +25,12 @@ From a contact form view, you can now check the checkbox Invoicing per delivery .. image:: static/description/delivery_order_form_view.png -- Validate your delivery order and then create a backorder for the remaining quantities. A smart button `Invoice` appears in the form view. +- Validate your delivery order and then create a backorder for the remaining quantities. A smart button `Invoices` appears in the form view. .. image:: static/description/delivery_order_invoice_button.png -- Click on the smart button to see the draft `Invoice` created from the delivery order. -- You can go to the delivery order that generated this Invoice through the smart button `Delivery` +- Click on the smart button to see the draft `Invoices` created from the delivery order. +- You can go to the delivery order that generated this Invoice through the smart button `Pickins` .. image:: static/description/draft_invoice.png diff --git a/invoice_per_delivery/__manifest__.py b/invoice_per_delivery/__manifest__.py index ac26d5c..a2d347f 100644 --- a/invoice_per_delivery/__manifest__.py +++ b/invoice_per_delivery/__manifest__.py @@ -10,11 +10,9 @@ "license": "LGPL-3", "category": "Accounting", "summary": "Create invoice per delivary for some partners", - "depends": ["stock_account", "sale_stock"], + "depends": ["stock_account", "sale_stock", "stock_picking_invoice_link"], "data": [ - "views/account_move.xml", "views/res_partner.xml", - "views/stock_picking.xml", ], "installable": True, "application": False, diff --git a/invoice_per_delivery/models/__init__.py b/invoice_per_delivery/models/__init__.py index bf2c7d6..51807e3 100644 --- a/invoice_per_delivery/models/__init__.py +++ b/invoice_per_delivery/models/__init__.py @@ -1,7 +1,6 @@ # Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from . import account_move from . import res_partner from . import sale_order from . import sale_order_line diff --git a/invoice_per_delivery/models/account_move.py b/invoice_per_delivery/models/account_move.py deleted file mode 100644 index 2541fb5..0000000 --- a/invoice_per_delivery/models/account_move.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -from odoo import fields, models - - -class AccountMove(models.Model): - - _inherit = "account.move" - - picking_id = fields.Many2one( - string="Delivery", - comodel_name="stock.picking", - ondelete="restrict", - ) - - def action_view_delivery(self): - form_view = [(self.env.ref("stock.view_picking_form").id, "form")] - return { - "type": "ir.actions.act_window", - "name": "Delivery", - "view_mode": "form", - "views": form_view, - "res_model": "stock.picking", - "res_id": self.picking_id.id, - "domain": [("id", "=", self.picking_id.id)], - } diff --git a/invoice_per_delivery/models/stock_picking.py b/invoice_per_delivery/models/stock_picking.py index dbacd2d..e6b65c1 100644 --- a/invoice_per_delivery/models/stock_picking.py +++ b/invoice_per_delivery/models/stock_picking.py @@ -1,39 +1,20 @@ # Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import fields, models +from odoo import models class StockPicking(models.Model): _inherit = "stock.picking" - invoice_id = fields.Many2one( - string="Invoice", - comodel_name="account.move", - ondelete="restrict", - ) - - def action_view_invoice(self): - form_view = [(self.env.ref("account.view_move_form").id, "form")] - return { - "type": "ir.actions.act_window", - "name": "Invoice", - "view_mode": "form", - "views": form_view, - "res_model": "account.move", - "res_id": self.invoice_id.id, - "domain": [("id", "=", self.invoice_id.id)], - } - def _create_invoice(self): self.ensure_one() if self.sale_id and self.partner_id.invoice_per_delivery: if any(line for line in self.sale_id.order_line if line.product_uom_qty != line.qty_invoiced): - invoice = self.sale_id.sudo().with_context(picking_id=self)._create_invoices() - invoice.write({"picking_id": self.id}) - self.invoice_id = invoice + self.sale_id.sudo().with_context(picking_id=self)._create_invoices() + return def write(self, vals): for rec in self: diff --git a/invoice_per_delivery/tests/test_invoicing_per_delivery.py b/invoice_per_delivery/tests/test_invoicing_per_delivery.py index c8814ee..2977424 100644 --- a/invoice_per_delivery/tests/test_invoicing_per_delivery.py +++ b/invoice_per_delivery/tests/test_invoicing_per_delivery.py @@ -10,7 +10,7 @@ class TestSaleStock(TestSaleCommon): def test_00_sale_stock_invoice(self): self.partner_a.write({"invoice_per_delivery": True}) - self.product = self.company_data["product_delivery_no"] + self.product = self.company_data["product_delivery_sales_price"] so_vals = { "partner_id": self.partner_a.id, "partner_invoice_id": self.partner_a.id, @@ -48,25 +48,21 @@ def test_00_sale_stock_invoice(self): wiz.process() self.assertTrue( - pick.invoice_id, - "No invoice is created after validating the delivery order", + self.so.invoice_ids, + "No invoice is liked to the so after validating the delivery order", ) self.assertEqual( - pick.invoice_id.state, + self.so.invoice_ids[0].state, "draft", "Invoice created in draft status after validating the delivery order", ) - self.assertTrue( - pick.invoice_id.picking_id, - "No piking is linked to the invoice after validating the delivery order", - ) - self.assertTrue( - self.so.invoice_ids, - "No invoice is liked to the so after validating the delivery order", - ) self.assertEqual( self.so.invoice_status, "no", 'so invoice_status should be "no" instead of "%s"' % self.so.invoice_status, ) + self.assertTrue( + self.so.invoice_ids.mapped("picking_ids"), + "No piking is linked to the invoice after validating the delivery order", + ) diff --git a/invoice_per_delivery/views/account_move.xml b/invoice_per_delivery/views/account_move.xml deleted file mode 100644 index 487bc30..0000000 --- a/invoice_per_delivery/views/account_move.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - account.move.delivery.form.view - account.move - - - - - - - - - - - - \ No newline at end of file diff --git a/invoice_per_delivery/views/stock_picking.xml b/invoice_per_delivery/views/stock_picking.xml deleted file mode 100644 index d77606b..0000000 --- a/invoice_per_delivery/views/stock_picking.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - stock.delivery.invoice.form.view - stock.picking - - - - - - - - - - - - \ No newline at end of file