-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] shipment_advice_cash_on_delivery: Add action on shipment advice…
… to print cash on delivery invoices
- Loading branch information
1 parent
d1b165d
commit 1d11d86
Showing
19 changed files
with
941 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/shipment_advice_cash_on_delivery/odoo/addons/shipment_advice_cash_on_delivery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../shipment_advice_cash_on_delivery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/OCA/stock-logistics-transport/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 <https://github.com/OCA/stock-logistics-transport/issues/new?body=module:%20shipment_advice_cash_on_delivery%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* BCIM | ||
* ACSONE SA/NV | ||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Jacques-Etienne Baudoux <[email protected]> | ||
* Souheil Bejaoui <[email protected]> | ||
* Tuan Tran <[email protected]> | ||
|
||
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 <https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice_cash_on_delivery>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# 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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import account_payment_mode | ||
from . import shipment_advice | ||
from . import stock_picking |
10 changes: 10 additions & 0 deletions
10
shipment_advice_cash_on_delivery/models/account_payment_mode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
|
||
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() |
20 changes: 20 additions & 0 deletions
20
shipment_advice_cash_on_delivery/models/shipment_advice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# 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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
You must mark a payment mode as "cash on delivery". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Jacques-Etienne Baudoux <[email protected]> | ||
* Souheil Bejaoui <[email protected]> | ||
* Tuan Tran <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.