-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] purchase_line_qty_update_in_picking: When the quantity on…
… the purchase line decreases, update on the picking.
- Loading branch information
1 parent
fb98933
commit f270704
Showing
7 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
=================================== | ||
Purchase line qty update in picking | ||
=================================== | ||
|
||
* When the quantity on the purchase line decreases, update on the picking. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <[email protected]> | ||
* Alfredo de la Fuente <[email protected]> |
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 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,15 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Purchase Line Qty Update In Picking", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Avanzosc", | ||
"category": "Inventory", | ||
"website": "https://github.com/avanzosc/odoo-addons", | ||
"depends": [ | ||
"purchase_stock", | ||
], | ||
"data": [], | ||
"installable": 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 @@ | ||
from . import purchase_order_line |
34 changes: 34 additions & 0 deletions
34
purchase_line_qty_update_in_picking/models/purchase_order_line.py
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,34 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import _, api, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = "purchase.order.line" | ||
|
||
@api.onchange("product_qty", "product_uom", "company_id") | ||
def _onchange_quantity(self): | ||
result = super(PurchaseOrderLine, self)._onchange_quantity() | ||
if self.qty_received and self.product_qty < self.qty_received: | ||
raise UserError(_("Amount less than amount received.")) | ||
return result | ||
|
||
def write(self, values): | ||
found = False | ||
if ( | ||
len(self) == 1 | ||
and "product_qty" in values | ||
and values.get("produt_qty", 0.0) < self.product_qty | ||
): | ||
found = True | ||
result = super(PurchaseOrderLine, self).write(values) | ||
if found: | ||
self._put_new_qty_in_picking() | ||
return result | ||
|
||
def _put_new_qty_in_picking(self): | ||
qty_in_picking = self.product_qty - self.qty_received | ||
move = self.move_ids.filtered(lambda x: x.state == "assigned") | ||
if len(move) == 1: | ||
move.product_uom_qty = qty_in_picking |
1 change: 1 addition & 0 deletions
1
setup/purchase_line_qty_update_in_picking/odoo/addons/purchase_line_qty_update_in_picking
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 @@ | ||
../../../../purchase_line_qty_update_in_picking |
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, | ||
) |