From 4576bef84b093710450d6edb80788001720ad8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com> Date: Sat, 18 Sep 2021 15:20:38 +0200 Subject: [PATCH] [ADD] available quants on lots --- models/stock_production_lot.py | 10 ++++++++++ views/stock_move_line.xml | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/models/stock_production_lot.py b/models/stock_production_lot.py index d51e07a..b926e6b 100644 --- a/models/stock_production_lot.py +++ b/models/stock_production_lot.py @@ -1,4 +1,5 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) +# Copyright 2017 Open For Small Business Ltd # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import datetime import re @@ -60,3 +61,12 @@ class FumocStockProductionLot(models.Model): for field, value in dates_dict.items(): setattr(self, field, value) + # function copied from https://github.com/odoonz/odoonz-addons/tree/14.0/stock_prodlot_qty + # Copyright 2017 Open For Small Business Ltd + def name_get(self): + res = super().name_get() + if self.env.context.get("show_qty"): + res = self.browse([r[0] for r in res]).mapped( + lambda r: (r.id, r.name + " (en stock : %.0f)" % r.product_qty) + ) + return res diff --git a/views/stock_move_line.xml b/views/stock_move_line.xml index 50c6561..5af70f3 100644 --- a/views/stock_move_line.xml +++ b/views/stock_move_line.xml @@ -10,13 +10,28 @@ <field name="inherit_id" ref="product_expiry.view_stock_move_line_detailed_operation_tree_expiry"/> <field name="priority" eval="8"/> <field name="arch" type="xml"> + <field name="lot_id" position="attributes"> + <attribute name="context">{'default_product_id': product_id, 'default_company_id': company_id, 'active_picking_id': picking_id, 'show_qty': True}</attribute> + </field> <xpath expr="//field[@name='expiration_date']" position="attributes"> <attribute name="string">DLC</attribute> - <attribute name="attrs">{'column_invisible': [('parent.show_lots_text', '=', True)]}</attribute> + <attribute name="attrs">{'column_invisible': [('parent.show_lots_text', '=', True)], 'readonly': [('picking_type_use_existing_lots', '=', True)]}</attribute> <attribute name="widget">date</attribute> </xpath> </field> </record> + <record id="fumoc_stock_move_line_operation_tree_inherit" model="ir.ui.view"> + <field name="name">fumoc_sale.stock.move.line.op.tree</field> + <field name="model">stock.move.line</field> + <field name="inherit_id" ref="product_expiry.view_stock_move_line_operation_tree_expiry"/> + <field name="priority" eval="8"/> + <field name="arch" type="xml"> + <field name="lot_id" position="attributes"> + <attribute name="context">{'default_product_id': parent.product_id, 'default_company_id': parent.company_id, 'active_picking_id': picking_id, 'show_qty': True}</attribute> + </field> + </field> + </record> + </data> </odoo> -- GitLab