File tree Expand file tree Collapse file tree
sale_order_product_availability_inline Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
22from . import product_product
3+ from . import product_template
34from . import sale
Original file line number Diff line number Diff line change 1+ # Copyright 2020 Tecnativa - Ernesto Tejeda
2+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+ from odoo import models
5+
6+
7+ class ProductTemplate (models .Model ):
8+ _inherit = "product.template"
9+
10+ def _compute_display_name (self ):
11+ res = super ()._compute_display_name ()
12+ if self .env .context .get ("so_product_stock_inline" ):
13+ self = self .with_context (warehouse = self .env .context .get ("warehouse" ))
14+ availability = {
15+ r .id : [
16+ sum (p .free_qty for p in r .product_variant_ids ),
17+ r .uom_id .display_name ,
18+ ]
19+ for r in self
20+ }
21+ precision = self .env ["decimal.precision" ].precision_get (
22+ "Product Unit of Measure"
23+ )
24+ for record in self :
25+ name = "{} ({:.{}f} {})" .format (
26+ record .display_name ,
27+ availability [record .id ][0 ],
28+ precision ,
29+ availability [record .id ][1 ],
30+ )
31+ record .display_name = name
32+ return res
Original file line number Diff line number Diff line change @@ -12,3 +12,8 @@ def _compute_name(self):
1212 if self .env .context .get ("so_product_stock_inline" ):
1313 self = self .with_context (so_product_stock_inline = False )
1414 return super ()._compute_name ()
15+
16+ def _compute_translated_product_name (self ):
17+ if self .env .context .get ("so_product_stock_inline" ):
18+ self = self .with_context (so_product_stock_inline = False )
19+ return super ()._compute_translated_product_name ()
Original file line number Diff line number Diff line change 1515 "warehouse": parent.warehouse_id}
1616 </attribute >
1717 </xpath >
18+
19+ <xpath
20+ expr =" //field[@name='order_line']/list//field[@name='product_template_id']"
21+ position =" attributes"
22+ >
23+ <attribute name =" context" operation =" update" >
24+ {"so_product_stock_inline": True,
25+ "warehouse": parent.warehouse_id}
26+ </attribute >
27+ </xpath >
1828 <xpath
1929 expr =" //field[@name='order_line']/form//field[@name='product_id']"
2030 position =" attributes"
You can’t perform that action at this time.
0 commit comments