Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP/ADD] shipment_advice*: Add action on shipment advice to print delivery slip and cash on delivery invoices #129

Open
wants to merge 5 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)
3 changes: 2 additions & 1 deletion shipment_advice/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Contributors
* Simone Orsi <[email protected]>
* `Trobz <https://trobz.com>`_:
* Dung Tran <[email protected]>

* Tuan Tran <[email protected]>
* Tri Doan <[email protected]>
Design
~~~~~~

Expand Down
1 change: 1 addition & 0 deletions shipment_advice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"data/ir_sequence.xml",
"data/queue_job_channel.xml",
"data/queue_job_function.xml",
"report/reports.xml",
"views/res_config_settings.xml",
"views/shipment_advice.xml",
"views/stock_picking.xml",
Expand Down
8 changes: 8 additions & 0 deletions shipment_advice/models/shipment_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,11 @@
action["views"][tree_view_index] = (view_tree.id, "tree")
action["domain"] = [("id", "in", self.planned_picking_ids.ids)]
return action

def print_all_deliveryslip(self):
pickings = self.mapped("loaded_picking_ids").filtered(
lambda p: p.picking_type_code == "outgoing" and p.state != "cancel"
)
if pickings:
return self.env.ref("stock.action_report_delivery").report_action(pickings)
return {}

Check warning on line 538 in shipment_advice/models/shipment_advice.py

View check run for this annotation

Codecov / codecov/patch

shipment_advice/models/shipment_advice.py#L538

Added line #L538 was not covered by tests
3 changes: 2 additions & 1 deletion shipment_advice/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Simone Orsi <[email protected]>
* `Trobz <https://trobz.com>`_:
* Dung Tran <[email protected]>

* Tuan Tran <[email protected]>
* Tri Doan <[email protected]>
Design
~~~~~~

Expand Down
11 changes: 11 additions & 0 deletions shipment_advice/tests/test_shipment_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ def test_shipment_advice_done_full(self):
)
)
self.assertEqual(picking.state, "done")
# Print deliveryslip
action = self.shipment_advice_out.with_context(
discard_logo_check=True
).print_all_deliveryslip()
self.assertEqual(action.get("type"), "ir.actions.report")
self.assertEqual(action.get("report_name"), "stock.report_deliveryslip")
self.assertEqual(action.get("report_type"), "qweb-pdf")
self.assertEqual(
action.get("context").get("active_ids"),
picking.ids,
)

def test_shipment_advice_done_backorder_policy_disabled(self):
"""Validating a shipment with no backorder policy should let partial
Expand Down
23 changes: 23 additions & 0 deletions shipment_advice/views/shipment_advice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@
class="btn-secondary"
states="cancel"
/>
<button
name="%(action_report_shipment_advice)d"
type="action"
string="Print Shipment Advice"
class="btn-secondary"
states="in_progress,done"
/>
<button
name="print_all_deliveryslip"
type="object"
string="Print Delivery Slip"
class="btn-secondary"
states="in_progress,done"
/>
<field
name="state"
widget="statusbar"
Expand Down Expand Up @@ -364,4 +378,13 @@
parent="stock.menu_stock_warehouse_mgmt"
action="shipment_advice_action"
/>
<!-- Shipment Advice - Print Delivery Slip -->
<record id="action_print_batch_delivery_slip" model="ir.actions.server">
<field name="name">Print Delivery Slip</field>
<field name="model_id" ref="shipment_advice.model_shipment_advice" />
<field name="binding_model_id" ref="shipment_advice.model_shipment_advice" />
<field name="state">code</field>
<field name="code">action = records.print_all_deliveryslip()
</field>
</record>
</odoo>
85 changes: 85 additions & 0 deletions shipment_advice_cash_on_delivery/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
================================
Shipment Advice Cash on Delivery
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c84344ebd4687e9ba6c09fda8cc3c7fa7f29dffa453ddc4b37a4f589a0a29d1e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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|

Allows users to print cash on delivery invoices from a shipment advice

**Table of contents**

.. contents::
:local:

Configuration
=============

Nothing to do

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.
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
18 changes: 18 additions & 0 deletions shipment_advice_cash_on_delivery/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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": ["shipment_advice", "partner_invoicing_mode_cash_on_delivery"],
"data": [
"views/shipment_advice.xml",
],
}
1 change: 1 addition & 0 deletions shipment_advice_cash_on_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import shipment_advice
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
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 @@
Nothing to do
4 changes: 4 additions & 0 deletions shipment_advice_cash_on_delivery/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Jacques-Etienne Baudoux <[email protected]>
* Souheil Bejaoui <[email protected]>
* Tuan Tran <[email protected]>
* Tri Doan <[email protected]>
1 change: 1 addition & 0 deletions shipment_advice_cash_on_delivery/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allows users to print cash on delivery invoices from a shipment advice
Loading
Loading