Skip to content

Commit

Permalink
TA#65012 [IMP] invoice_per_delivery: Add dependencies (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda authored Jul 24, 2024
1 parent b2f8b83 commit 25c5c5c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 108 deletions.
5 changes: 5 additions & 0 deletions gitoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 11 additions & 4 deletions invoice_per_delivery/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/OCA/stock-logistics-workflow/tree/14.0/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

Expand All @@ -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

Expand Down
4 changes: 1 addition & 3 deletions invoice_per_delivery/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion invoice_per_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 0 additions & 27 deletions invoice_per_delivery/models/account_move.py

This file was deleted.

25 changes: 3 additions & 22 deletions invoice_per_delivery/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
20 changes: 8 additions & 12 deletions invoice_per_delivery/tests/test_invoicing_per_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
)
19 changes: 0 additions & 19 deletions invoice_per_delivery/views/account_move.xml

This file was deleted.

20 changes: 0 additions & 20 deletions invoice_per_delivery/views/stock_picking.xml

This file was deleted.

0 comments on commit 25c5c5c

Please sign in to comment.