-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_picking_product_availability_inline: Migration to 18.0
- Loading branch information
1 parent
2eed50f
commit b6ad847
Showing
9 changed files
with
51 additions
and
85 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
21 changes: 13 additions & 8 deletions
21
stock_picking_product_availability_inline/models/product_product.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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
# Copyright 2022 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
from odoo import api, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
def name_get(self): | ||
res = super().name_get() | ||
@api.model | ||
def name_search(self, name="", args=None, operator="ilike", limit=100): | ||
res = super().name_search(name=name, args=args, operator=operator, limit=limit) | ||
if self.env.context.get("sp_product_stock_inline"): | ||
product_dict = {r.id: r for r in self} | ||
dp = self.env["decimal.precision"].precision_get("Product Unit of Measure") | ||
new_res = [] | ||
for rec_name in res: | ||
prod = product_dict[rec_name[0]] | ||
name = f"{rec_name[1]} ({prod.free_qty:.{dp}f} {prod.uom_id.name})" | ||
new_res.append((prod.id, name)) | ||
for product_id, display_name in res: | ||
product = self.env["product.product"].browse(product_id) | ||
new_res.append( | ||
( | ||
product_id, | ||
f"{display_name} ({product.free_qty:.{dp}f}" | ||
+ f" {product.uom_id.name})", | ||
) | ||
) | ||
res = new_res | ||
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
1 change: 1 addition & 0 deletions
1
stock_picking_product_availability_inline/readme/CONTRIBUTORS.md
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- [Tecnativa](https://www.tecnativa.com): | ||
- Ernesto Tejeda | ||
- Sergio Teruel | ||
- Carlos Roca |
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
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