Skip to content

Commit

Permalink
[ADD] stock_picking_on_hold
Browse files Browse the repository at this point in the history
[15.0][upd] conditional readonly added to hold_picking_until_payment

[15.0][upd] hold_picking_until_payment set to true by default

[15.0][IMP] Base stock_picking_on_hold on sale_stock_picking_blocking
  • Loading branch information
dsolanki-initos authored and ortlam committed Sep 7, 2023
1 parent 5c2d077 commit 40e579c
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ jobs:
include: "portal_sale_personal_data_only"
name: test with OCB
- container: ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest
exclude: "portal_sale_personal_data_only"
exclude: "portal_sale_personal_data_only, sale_automatic_workflow_job, sale_stock_secondary_unit"
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.8-ocb15.0:latest
exclude: "portal_sale_personal_data_only"
exclude: "portal_sale_personal_data_only, sale_automatic_workflow_job, sale_stock_secondary_unit"
name: test with OCB
services:
postgres:
Expand Down
6 changes: 6 additions & 0 deletions setup/stock_picking_on_hold/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,
)
84 changes: 84 additions & 0 deletions stock_picking_on_hold/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
===================================================
Sale Payment Method - Hold Pickings (Until Payment)
===================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |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%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/15.0/stock_picking_on_hold
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-stock_picking_on_hold
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to automatically hold a sale order's deliveries until the invoice is paid

**Table of contents**

.. contents::
:local:

Usage
=====

1) Set on payment methods whether they should block deliveries until paid
2) Set payment method on sale order
3) A sale order's picking won't be created until it is paid


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

Go to Invoicing > Payment Methods > Select your payment method > Enable "Hold Picking Until Payment"


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
~~~~~~~~~~~~

* Thomas Rehn <[email protected]>
* Katja Matthes <[email protected]>
* Dhara Solanki <[email protected]>
* Ruben Ortlam <[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/sale-workflow <https://github.com/OCA/sale-workflow/tree/15.0/stock_picking_on_hold>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions stock_picking_on_hold/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
25 changes: 25 additions & 0 deletions stock_picking_on_hold/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sale Payment Method - Hold Pickings (until payment)",
"version": "15.0.1.0.0",
"website": "https://github.com/OCA/sale-workflow",
"category": "Warehouse",
"summary": """
Sale Payment Method - Hold Pickings until payment
===================================================
* This module allows to hold the picking until the invoice is paid""",
"depends": [
"stock",
"sale_stock_picking_blocking",
"account_payment_mode",
],
"author": "initOS GmbH, Odoo Community Association (OCA)",
"license": "AGPL-3",
"data": [
"views/payment_method.xml",
"views/sale_order_view.xml",
],
"installable": True,
"application": False,
}
1 change: 1 addition & 0 deletions stock_picking_on_hold/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import payment_method, sale_order
13 changes: 13 additions & 0 deletions stock_picking_on_hold/models/payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class PaymentMethod(models.Model):
_inherit = "account.payment.method"

hold_picking_until_payment = fields.Boolean(
help="If set to true, pickings will not be automatically confirmed when "
"the invoice has not been paid.",
default=True,
)
52 changes: 52 additions & 0 deletions stock_picking_on_hold/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from odoo import fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

payment_method_id = fields.Many2one(
"account.payment.method",
string="Payment Method",
ondelete="restrict",
)

def auto_set_invoice_block(self):
recs = self.filtered_domain(
[("payment_method_id.hold_picking_until_payment", "=", True)]
)

if not recs:
return

block_reason = self.env.ref("sale_stock_picking_blocking.pay_before_delivery")

# Block records that are not yet invoiced or draft
# Unblock the rest
block = recs.filtered_domain(
[
"|",
"&",
("state", "=", "draft"),
("invoice_status", "=", "no"),
("invoice_status", "!=", "invoiced"),
]
)

unblock = recs - block

block.write({"delivery_block_id": block_reason.id})
unblock.action_remove_delivery_block()

def onchange_partner_id(self):
result = super().onchange_partner_id()

self.auto_set_invoice_block()

return result

def _get_invoice_status(self):
result = super()._get_invoice_status()

self.auto_set_invoice_block()

return result
1 change: 1 addition & 0 deletions stock_picking_on_hold/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#. Go to Invoicing > Payment Methods > Select your payment method > Enable "Hold Picking Untill Payment"
3 changes: 3 additions & 0 deletions stock_picking_on_hold/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Thomas Rehn <[email protected]>
* Katja Matthes <[email protected]>
* Dhara Solanki <[email protected]>
1 change: 1 addition & 0 deletions stock_picking_on_hold/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to hold the picking until the invoice is paid.
4 changes: 4 additions & 0 deletions stock_picking_on_hold/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To use functionality of module,

1) You need to generate "Sale Order" using "Payment Method: Enabled Hold Picking Untill Payment"
2) Picking can not "confirm" untill the payment is "confirmed" of that Sale Order
16 changes: 16 additions & 0 deletions stock_picking_on_hold/views/payment_method.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="payment_method_view_form_picking_on_hold" model="ir.ui.view">
<field name="name">sale_payment_method.payment_method.view_form</field>
<field name="model">account.payment.method</field>
<field
name="inherit_id"
ref="account_payment_mode.account_payment_method_form"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_type']" position="after">
<field name="hold_picking_until_payment" />
</xpath>
</field>
</record>
</odoo>
27 changes: 27 additions & 0 deletions stock_picking_on_hold/views/sale_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="sale_order_view_form_inherit_payment_method" model="ir.ui.view">
<field name="name">sale.order.payment_method.view_form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath
expr="//group[@name='sale_info']//field[@name='invoice_status']"
position="after"
>
<field name="payment_method_id" />
</xpath>
</field>
</record>

<record id="view_sale_order_tree_stock_picking_on_hold" model="ir.ui.view">
<field name="name">sale.order.tree.stock_picking_on_hold</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="arch" type="xml">
<field name="state" position="after">
<field name='payment_method_id' />
</field>
</field>
</record>
</odoo>

0 comments on commit 40e579c

Please sign in to comment.