[FIX] stock: inventory adjustment
Backport of commit c00267bc34
opw-767538
This commit is contained in:
@@ -3157,6 +3157,19 @@ class stock_inventory(osv.osv):
|
||||
to_clean['value']['package_id'] = False
|
||||
return to_clean
|
||||
|
||||
def action_inventory_line_tree(self, cr, uid, ids, context=None):
|
||||
inv = self.browse(cr, uid, ids, context=context)
|
||||
action = self.pool['ir.model.data'].xmlid_to_object(cr, uid, 'stock.action_inventory_line_tree', context=context).read()[0]
|
||||
action['context'] = {
|
||||
'default_location_id': inv.location_id.id,
|
||||
'default_product_id': inv.product_id.id,
|
||||
'default_prod_lot_id': inv.lot_id.id,
|
||||
'default_package_id': inv.package_id.id,
|
||||
'default_partner_id': inv.partner_id.id,
|
||||
'default_inventory_id': inv.id,
|
||||
}
|
||||
return action
|
||||
|
||||
_constraints = [
|
||||
(_check_filter_product, 'The selected inventory options are not coherent.',
|
||||
['filter', 'product_id', 'lot_id', 'partner_id', 'package_id']),
|
||||
@@ -3215,6 +3228,8 @@ class stock_inventory_line(osv.osv):
|
||||
'prodlot_name': fields.related('prod_lot_id', 'name', type='char', string='Serial Number Name', store={
|
||||
'stock.production.lot': (_get_prodlot_change, ['name'], 20),
|
||||
'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['prod_lot_id'], 20),}),
|
||||
'inventory_location_id': fields.related(
|
||||
'inventory_id', 'location_id', type='many2one', relation='stock.location', string='Location'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -51,6 +51,40 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_inventory_line_tree2" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.line.tree2</field>
|
||||
<field name="model">stock.inventory.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="top" string="Inventory Details" decoration-info="product_qty != theoretical_qty" decoration-danger="theoretical_qty < 0">
|
||||
<field name="product_id" domain="[('type','=','product')]" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)"/>
|
||||
<field name="product_uom_id" groups="product.group_uom" string="UoM" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)"/>
|
||||
<field name="location_id" domain="[('id', 'child_of', inventory_location_id)]" groups="stock.group_locations" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)"/>
|
||||
<field name="prod_lot_id" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
|
||||
<field name="package_id" domain="['|', ('location_id','=', False), ('location_id', '=', location_id)]" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)" groups="stock.group_tracking_lot"/>
|
||||
<field name="partner_id" on_change="onchange_createline(location_id, product_id, product_uom_id, package_id, prod_lot_id, partner_id)" groups="stock.group_tracking_owner"/>
|
||||
<field name="theoretical_qty" readonly="1"/>
|
||||
<field name="product_qty" string="Real Quantity"/>
|
||||
<field name="state" invisible="True"/>
|
||||
<field name="inventory_id" invisible="1"/>
|
||||
<field name="inventory_location_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_inventory_line_search" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.line.search</field>
|
||||
<field name="model">stock.inventory.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Inventory Lines">
|
||||
<field name="product_id"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="prod_lot_id" groups="stock.group_production_lot"/>
|
||||
<field name="package_id" groups="stock.group_tracking_lot"/>
|
||||
<field name="partner_id" groups="stock.group_tracking_owner"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_inventory_filter" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.filter</field>
|
||||
<field name="model">stock.inventory</field>
|
||||
@@ -93,6 +127,19 @@
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,done"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="action_inventory_line_tree"
|
||||
class="oe_stat_button"
|
||||
icon="fa-building-o"
|
||||
type="object"
|
||||
help="List view of lines"
|
||||
groups="base.group_no_one"
|
||||
states="confirm">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_text">Details</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name" placeholder="e.g. Annual inventory"/></h1>
|
||||
@@ -221,6 +268,17 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_inventory_line_tree" model="ir.actions.act_window">
|
||||
<field name="name">Inventory Lines</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.inventory.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="stock_inventory_line_tree2"/>
|
||||
<field name="domain">[('inventory_id', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_inventory_form" id="menu_action_inventory_form" parent="menu_stock_inventory_control" sequence="30"/>
|
||||
|
||||
<record id="view_production_lot_form" model="ir.ui.view">
|
||||
|
||||
Reference in New Issue
Block a user