Skip to content

Commit

Permalink
Merge PR #1736 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by rafaelbn
  • Loading branch information
OCA-git-bot committed Aug 28, 2024
2 parents d826b85 + 3ace259 commit f691672
Show file tree
Hide file tree
Showing 17 changed files with 900 additions and 0 deletions.
90 changes: 90 additions & 0 deletions partner_invoicing_mode_cash_on_delivery/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
=======================================
Partner Invoicing Mode Cash on Delivery
=======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5525b56e6241690abaa44bb465f180508ee6a0af871cd8a3d2232216e25c602c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%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/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/account-invoicing&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 identify cash on delivery invoices on shippings.

**Table of contents**

.. contents::
:local:

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 <https://github.com/OCA/account-invoicing/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/account-invoicing/issues/new?body=module:%20partner_invoicing_mode_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 <je@bcim.be>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Tuan Tran <anhtuan@trobz.com>
* Denis Roussel <denis.roussel@acsone.eu>

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/account-invoicing <https://github.com/OCA/account-invoicing/tree/16.0/partner_invoicing_mode_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 partner_invoicing_mode_cash_on_delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions partner_invoicing_mode_cash_on_delivery/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# Copyright 2023 ACSONE SA/NV
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"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/account-invoicing",
"depends": [
"account_payment_sale",
"partner_invoicing_mode_at_shipping",
],
"data": [
"views/account_payment_mode_views.xml",
"views/stock_picking_views.xml",
"data/account_payment_mode.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2024 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">

<record id="payment_mode_cash_on_delivery" model="account.payment.mode">
<field name="name">Cash On Delivery</field>
<field name="cash_on_delivery" eval="True" />
<field name="auto_validate_invoice_cash_on_delivery" eval="True" />
<field
name="payment_method_id"
ref="account.account_payment_method_manual_in"
/>
<field name="bank_account_link">variable</field>
</record>

</odoo>
2 changes: 2 additions & 0 deletions partner_invoicing_mode_cash_on_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_payment_mode
from . import stock_picking
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>

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."
)
57 changes: 57 additions & 0 deletions partner_invoicing_mode_cash_on_delivery/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# 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(
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):
"""
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
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_cash_on_delivery
)
# 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
2 changes: 2 additions & 0 deletions partner_invoicing_mode_cash_on_delivery/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Jacques-Etienne Baudoux <je@bcim.be>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Tuan Tran <anhtuan@trobz.com>
* Denis Roussel <denis.roussel@acsone.eu>
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 identify cash on delivery invoices on shippings.
Loading

0 comments on commit f691672

Please sign in to comment.