Skip to content

Commit

Permalink
[ADD] shipment_advice_cash_on_delivery: Add action on shipment advice…
Browse files Browse the repository at this point in the history
… to print cash on delivery invoices
  • Loading branch information
tuantrantg committed Mar 15, 2024
1 parent c02bcc8 commit b60a8bd
Show file tree
Hide file tree
Showing 19 changed files with 831 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/shipment_advice_cash_on_delivery/setup.py
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,
)
93 changes: 93 additions & 0 deletions shipment_advice_cash_on_delivery/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
================================
Shipment Advice Cash on Delivery
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a197f5dd62b0eef97d07c82feb1149b1f1c97941d91bbd47a887512d6db47a45
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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 term 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 term 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]>

Other credits
~~~~~~~~~~~~~

The creation of this module was financially supported by Camptocamp.

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.
1 change: 1 addition & 0 deletions shipment_advice_cash_on_delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions shipment_advice_cash_on_delivery/__manifest__.py
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
# 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": ["sale_stock", "shipment_advice", "partner_invoicing_mode_at_shipping"],
"data": [
"views/account_payment_term_views.xml",
"views/shipment_advice.xml",
"views/stock_picking_views.xml",
],
}
3 changes: 3 additions & 0 deletions shipment_advice_cash_on_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import account_payment_term
from . import shipment_advice
from . import stock_picking
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>

from odoo import fields, models


class AccountPaymentTerm(models.Model):
_inherit = "account.payment.term"

cash_on_delivery = fields.Boolean("Cash on Delivery")
20 changes: 20 additions & 0 deletions shipment_advice_cash_on_delivery/models/shipment_advice.py
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 {}

Check warning on line 20 in shipment_advice_cash_on_delivery/models/shipment_advice.py

View check run for this annotation

Codecov / codecov/patch

shipment_advice_cash_on_delivery/models/shipment_advice.py#L20

Added line #L20 was not covered by tests
24 changes: 24 additions & 0 deletions shipment_advice_cash_on_delivery/models/stock_picking.py
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).

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 _invoicing_at_shipping(self):
self.ensure_one()
res = super()._invoicing_at_shipping()
if not isinstance(res, str):
cod_invoices = res.filtered(
lambda inv: inv.invoice_payment_term_id.cash_on_delivery
)
self.cash_on_delivery_invoice_ids = cod_invoices
return res
1 change: 1 addition & 0 deletions shipment_advice_cash_on_delivery/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You must mark a payment term as "cash on delivery".
3 changes: 3 additions & 0 deletions shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst
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]>
1 change: 1 addition & 0 deletions shipment_advice_cash_on_delivery/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The creation of this module was financially supported by Camptocamp.
4 changes: 4 additions & 0 deletions shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Allow to mark a payment term 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
Loading

0 comments on commit b60a8bd

Please sign in to comment.