[IMP] stock: revamp putaway rules screen
1. When creating a putway rule, default location_in_id is receipt destination location (in case of single warehouse). 2. When changing location_in_id, copy value to location_out_id. 3. Allow to hide some fields and change of some labels. 4. Move location tab to a smart button. closes odoo/odoo#69580 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
committed by
Arnold Moyaux
parent
c1693581d7
commit
7d4dfeb0e2
@@ -27,6 +27,10 @@ class StockPutawayRule(models.Model):
|
||||
def _default_location_id(self):
|
||||
if self.env.context.get('active_model') == 'stock.location':
|
||||
return self.env.context.get('active_id')
|
||||
if not self.env.user.has_group('stock.group_stock_multi_warehouses'):
|
||||
wh = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
|
||||
input_loc, _ = wh._get_input_output_locations(wh.reception_steps, wh.delivery_steps)
|
||||
return input_loc
|
||||
|
||||
def _default_product_id(self):
|
||||
if self.env.context.get('active_model') == 'product.template' and self.env.context.get('active_id'):
|
||||
@@ -62,7 +66,7 @@ class StockPutawayRule(models.Model):
|
||||
domain="[('child_ids', '!=', False), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
default=_default_location_id, required=True, ondelete='cascade', index=True)
|
||||
location_out_id = fields.Many2one(
|
||||
'stock.location', 'Store to', check_company=True,
|
||||
'stock.location', 'Store to sublocation', check_company=True,
|
||||
domain="[('id', 'child_of', location_in_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
required=True, ondelete='cascade')
|
||||
sequence = fields.Integer('Priority', help="Give to the more specialized category, a higher priority to have them in top of the list.")
|
||||
@@ -75,14 +79,15 @@ class StockPutawayRule(models.Model):
|
||||
|
||||
@api.onchange('location_in_id')
|
||||
def _onchange_location_in(self):
|
||||
child_location_count = 0
|
||||
if self.location_out_id:
|
||||
child_location_count = self.env['stock.location'].search_count([
|
||||
('id', '=', self.location_out_id.id),
|
||||
('id', 'child_of', self.location_in_id.id),
|
||||
('id', '!=', self.location_in_id.id),
|
||||
])
|
||||
if not child_location_count:
|
||||
self.location_out_id = None
|
||||
if not child_location_count or not self.location_out_id:
|
||||
self.location_out_id = self.location_in_id
|
||||
|
||||
def write(self, vals):
|
||||
if 'company_id' in vals:
|
||||
|
||||
@@ -22,14 +22,17 @@
|
||||
force_save="1"/>
|
||||
<field name="package_type_ids" string="Package type"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
groups="stock.group_tracking_lot" widget="many2many_tags"/>
|
||||
<field name="location_out_id" string="Store to"
|
||||
groups="stock.group_tracking_lot" widget="many2many_tags"
|
||||
optional="show"/>
|
||||
<field name="location_out_id"
|
||||
attrs="{'readonly': [('location_in_id', '=', False)]}"
|
||||
options="{'no_create': True}"/>
|
||||
<field name="storage_category_id" string="Storage Category"
|
||||
options="{'no_create': True}"
|
||||
optional="show"/>
|
||||
<field name="storage_category_id" string="Having Category"
|
||||
groups="stock.group_stock_storage_categories"
|
||||
options="{'no_create': True}"/>
|
||||
<field name="company_id" groups="stock.group_stock_multi_locations" force_save="1" readonly="context.get('fixed_location', False)" options="{'no_create': True}"/>
|
||||
options="{'no_create': True}"
|
||||
optional="show"/>
|
||||
<field name="company_id" groups="stock.group_stock_multi_locations" force_save="1" readonly="context.get('fixed_location', False)" options="{'no_create': True}" optional="show"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -111,6 +111,14 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_storage_category_locations">
|
||||
<field name="name">Locations</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.location</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('storage_category_id', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_location_form" model="ir.actions.act_window">
|
||||
<field name="name">Locations</field>
|
||||
<field name="res_model">stock.location</field>
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Storage Category">
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="%(action_storage_category_locations)d" string="Locations" type="action" class="oe_stat_button" icon="fa-arrows-v"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
@@ -21,17 +24,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Product Capacity" name="product_capacity">
|
||||
<field name="product_capacity_ids" context="{'default_storage_category_id': id}">
|
||||
<tree editable="bottom">
|
||||
<field name="product_id" required="1"/>
|
||||
<field name="quantity"/>
|
||||
<field name="product_uom_id" options="{'no_create': True, 'no_open': True}"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Package Capacity" name="package_capacity" groups="stock.group_tracking_lot">
|
||||
<page string="Capacity by Package" name="package_capacity" groups="stock.group_tracking_lot">
|
||||
<field name="package_capacity_ids" context="{'default_storage_category_id': id}">
|
||||
<tree editable="bottom">
|
||||
<field name="package_type_id" required="1"/>
|
||||
@@ -40,10 +33,13 @@
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Locations" name="locations">
|
||||
<field name="location_ids">
|
||||
<tree create="false" delete="false">
|
||||
<field name="complete_name" string="Location"/>
|
||||
<page string="Capacity by Product" name="product_capacity">
|
||||
<field name="product_capacity_ids" context="{'default_storage_category_id': id}">
|
||||
<tree editable="bottom">
|
||||
<field name="product_id" required="1"/>
|
||||
<field name="quantity"/>
|
||||
<field name="product_uom_id" options="{'no_create': True, 'no_open': True}"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user