-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
1 parent
b6101d1
commit 719a2ae
Showing
18 changed files
with
486 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_picking_on_hold |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_move, payment_method, sale_order, stock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.