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
  • Loading branch information
dsolanki-initos authored and ahashaam committed Jul 14, 2023
1 parent b6101d1 commit 719a2ae
Show file tree
Hide file tree
Showing 18 changed files with 486 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,
)
82 changes: 82 additions & 0 deletions stock_picking_on_hold/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
===================================================
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 hold the picking until the invoice is paid

**Table of contents**

.. contents::
:local:

Usage
=====

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


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

Go to Invoicing > Payment Methods > Select your payment method > Enable "Hold Picking Untill 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]>

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
27 changes: 27 additions & 0 deletions stock_picking_on_hold/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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",
"website_sale",
"sale_management",
"account_payment_mode",
],
"author": "initOS GmbH, Odoo Community Association (OCA)",
"license": "AGPL-3",
"data": [
"views/stock.xml",
"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 account_move, payment_method, sale_order, stock
41 changes: 41 additions & 0 deletions stock_picking_on_hold/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class AccountMove(models.Model):
_inherit = "account.move"

def write(self, vals):
"""When an invoice is paid a picking that is hold until payment may need
a status check"""
res = super(AccountMove, self).write(vals)
pickings_to_check = self.env["stock.picking"]
for invoice in self.filtered(lambda i: i.state == "posted"):
for sale in invoice.invoice_line_ids.mapped("sale_line_ids").mapped(
"order_id"
):
for picking in sale.picking_ids:
if picking.state == "hold":
pickings_to_check += picking
# trigger availability check
if pickings_to_check:
pickings_to_check.action_assign_unpaid()
return res

def confirm_paid(self):
"""
When an invoice is paid
a picking that is hold until payment may need a status check.
"""
res = super(AccountMove, self).confirm_paid()
# collect all pickings to check
pickings_to_check = self.env["stock.picking"]
for invoice in self:
for sale in invoice.sale_ids:
for picking in sale.picking_ids:
if picking.state == "hold":
pickings_to_check += picking
# trigger availability check
pickings_to_check.action_assign()
return res
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,
)
21 changes: 21 additions & 0 deletions stock_picking_on_hold/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from odoo import api, fields, models


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

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

@api.model
def create(self, vals):
sale_order = super(SaleOrder, self).create(vals)
if not sale_order.website_id:
sale_order.hold_picking_until_payment = True
return sale_order
Loading

0 comments on commit 719a2ae

Please sign in to comment.