mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_inventory: Migration to 17.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Stock Inventory Adjustment",
|
||||
"version": "16.0.2.3.0",
|
||||
"version": "17.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"maintainer": ["DavidJForgeFlow"],
|
||||
"development_status": "Beta",
|
||||
|
||||
@@ -2,10 +2,6 @@ from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.osv import expression
|
||||
|
||||
READONLY_STATES = {
|
||||
"draft": [("readonly", False)],
|
||||
}
|
||||
|
||||
|
||||
class InventoryAdjustmentsGroup(models.Model):
|
||||
_name = "stock.inventory"
|
||||
@@ -20,20 +16,17 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
default="Inventory",
|
||||
string="Inventory Reference",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
date = fields.Datetime(
|
||||
default=lambda self: fields.Datetime.now(),
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
readonly=True,
|
||||
index=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
default=lambda self: self.env.company,
|
||||
required=True,
|
||||
)
|
||||
@@ -54,7 +47,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
"Owner",
|
||||
help="This is the owner of the inventory adjustment",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
location_ids = fields.Many2many(
|
||||
@@ -63,7 +55,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
domain="[('usage', '=', 'internal'), "
|
||||
"'|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
product_selection = fields.Selection(
|
||||
@@ -77,7 +68,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
default="all",
|
||||
required=True,
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
product_ids = fields.Many2many(
|
||||
@@ -85,7 +75,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
string="Products",
|
||||
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
stock_quant_ids = fields.Many2many(
|
||||
@@ -93,14 +82,12 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
string="Inventory Adjustment",
|
||||
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
category_id = fields.Many2one(
|
||||
"product.category",
|
||||
string="Product Category",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
lot_ids = fields.Many2many(
|
||||
@@ -108,7 +95,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
string="Lot/Serial Numbers",
|
||||
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
stock_move_ids = fields.One2many(
|
||||
@@ -116,7 +102,6 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
"inventory_adjustment_id",
|
||||
string="Inventory Adjustments Done",
|
||||
readonly=True,
|
||||
states=READONLY_STATES,
|
||||
)
|
||||
|
||||
count_stock_quants = fields.Integer(
|
||||
@@ -276,7 +261,8 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
else:
|
||||
error_field = "location_id"
|
||||
error_message = _(
|
||||
"There's already an Adjustment in Process using one requested Location: %s"
|
||||
"There's already an Adjustment in Process using one "
|
||||
"requested Location: %s"
|
||||
)
|
||||
|
||||
quants = self.env["stock.quant"].search(search_filter)
|
||||
@@ -407,8 +393,9 @@ class InventoryAdjustmentsGroup(models.Model):
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"Cannot have more than one in-progress inventory adjustment "
|
||||
"affecting the same location or product at the same time."
|
||||
"Cannot have more than one in-progress inventory "
|
||||
"adjustment affecting the same location or product "
|
||||
"at the same time."
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class StockQuant(models.Model):
|
||||
self.env["stock.inventory"]
|
||||
.search([("state", "=", "in_progress")])
|
||||
.filtered(
|
||||
lambda x: rec.location_id in x.location_ids
|
||||
lambda x, rec=rec: rec.location_id in x.location_ids
|
||||
or (
|
||||
rec.location_id in x.location_ids.child_internal_location_ids
|
||||
and not x.exclude_sublocation
|
||||
@@ -32,7 +32,7 @@ class StockQuant(models.Model):
|
||||
],
|
||||
order="create_date asc",
|
||||
).filtered(
|
||||
lambda x: not x.company_id.id
|
||||
lambda x, rec=rec: not x.company_id.id
|
||||
or not rec.company_id.id
|
||||
or rec.company_id.id == x.company_id.id
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ from odoo.tests.common import TransactionCase
|
||||
|
||||
class TestStockInventory(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestStockInventory, self).setUp()
|
||||
super().setUp()
|
||||
self.env.company.stock_inventory_auto_complete = False
|
||||
self.quant_model = self.env["stock.quant"]
|
||||
self.move_model = self.env["stock.move.line"]
|
||||
@@ -142,7 +142,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 3)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "2 / 3")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 8)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 8)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_1.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location1.id)
|
||||
@@ -176,7 +176,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 2)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "1 / 2")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id)
|
||||
@@ -226,7 +226,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 2)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "1 / 2")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id)
|
||||
@@ -276,7 +276,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "0 / 1")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id)
|
||||
@@ -310,7 +310,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "0 / 1")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product2.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id)
|
||||
inventory1.action_state_to_done()
|
||||
@@ -354,7 +354,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "0 / 1")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 8)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 8)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_1.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location1.id)
|
||||
@@ -399,7 +399,7 @@ class TestStockInventory(TransactionCase):
|
||||
self.assertEqual(inventory1.count_stock_moves, 1)
|
||||
self.assertEqual(inventory1.count_stock_quants, 2)
|
||||
self.assertEqual(inventory1.count_stock_quants_string, "1 / 2")
|
||||
self.assertEqual(inventory1.stock_move_ids.qty_done, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.quantity, 26)
|
||||
self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id)
|
||||
self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='production_lot_info']" position='after'>
|
||||
<xpath expr="//block[@id='production_lot_info']" position='after'>
|
||||
<h2>Stock Inventory</h2>
|
||||
<div class="row mt16 o_settings_container">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
|
||||
@@ -11,27 +11,27 @@
|
||||
type="object"
|
||||
name="action_state_to_in_progress"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible':[('state', 'in', ['in_progress', 'done'])]}"
|
||||
invisible="state in ('in_progress', 'done')"
|
||||
string="Begin Adjustments"
|
||||
/>
|
||||
<button
|
||||
type="object"
|
||||
name="action_state_to_draft"
|
||||
attrs="{'invisible':['|',('state', 'in', ['draft', 'done']), ('count_stock_moves', '!=', 0)]}"
|
||||
invisible="state in ('draft', 'done') or count_stock_moves != 0"
|
||||
string="Back to Draft"
|
||||
/>
|
||||
<field name="action_state_to_cancel_allowed" invisible="1" />
|
||||
<button
|
||||
type="object"
|
||||
name="action_state_to_cancel"
|
||||
attrs="{'invisible':[('action_state_to_cancel_allowed', '=', False),]}"
|
||||
invisible="not action_state_to_cancel_allowed"
|
||||
string="Cancel"
|
||||
/>
|
||||
<button
|
||||
type="object"
|
||||
name="action_state_to_done"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible':[('state', 'in', ['draft', 'done'])]}"
|
||||
invisible="state in ('draft', 'done')"
|
||||
string="Set to Done"
|
||||
/>
|
||||
<field
|
||||
@@ -48,7 +48,7 @@
|
||||
name="action_view_inventory_adjustment"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
attrs="{'invisible':[('state', 'in', ['draft', 'done'])]}"
|
||||
invisible="state in ('draft', 'done')"
|
||||
>
|
||||
<field
|
||||
name="count_stock_quants_string"
|
||||
@@ -62,7 +62,7 @@
|
||||
name="action_view_stock_moves"
|
||||
class="oe_stat_button"
|
||||
icon="fa-cubes"
|
||||
attrs="{'invisible':['|', ('state', '=', 'draft'), ('count_stock_moves', '=', 0)]}"
|
||||
invisible="state == 'draft' or count_stock_moves == 0"
|
||||
>
|
||||
<field
|
||||
name="count_stock_moves"
|
||||
@@ -73,51 +73,65 @@
|
||||
</div>
|
||||
<div class="oe_title" name="title">
|
||||
<label for="name" class="oe_edit_only" />
|
||||
<h1><field name="name" placeholder="e.g. Annual inventory" /></h1>
|
||||
<h1><field
|
||||
name="name"
|
||||
placeholder="e.g. Annual inventory"
|
||||
readonly="state != 'draft'"
|
||||
/></h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="product_selection" widget="radio" />
|
||||
<field
|
||||
name="product_selection"
|
||||
widget="radio"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
<field
|
||||
name="location_ids"
|
||||
string="Locations"
|
||||
widget="many2many_tags"
|
||||
required="1"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
<field
|
||||
name="exclude_sublocation"
|
||||
attrs="{'readonly':[('state', 'in', ['in_progress', 'done'])]}"
|
||||
readonly="state in ['in_progress', 'done']"
|
||||
required="1"
|
||||
/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date" />
|
||||
<field name="company_id" />
|
||||
<field name="responsible_id" />
|
||||
<field
|
||||
name="owner_id"
|
||||
attrs="{'readonly':[('state', '=', 'done')]}"
|
||||
/>
|
||||
<field name="date" readonly="state != 'draft'" />
|
||||
<field name="company_id" readonly="state != 'draft'" />
|
||||
<field name="responsible_id" readonly="state != 'draft'" />
|
||||
<field name="owner_id" readonly="state != 'draft'" />
|
||||
<field
|
||||
name="product_ids"
|
||||
widget="many2many_tags"
|
||||
attrs="{'required': [('product_selection', 'in', ['manual', 'lot'])],'invisible': [('product_selection', 'in', ['all', 'category', 'one'])]}"
|
||||
readonly="state != 'draft'"
|
||||
required="product_selection in ['manual', 'lot']"
|
||||
invisible="product_selection in ['all', 'category', 'one']"
|
||||
/>
|
||||
<field
|
||||
name="product_ids"
|
||||
widget="many2many_tags"
|
||||
options="{'limit': 10}"
|
||||
attrs="{'required': [('product_selection', '=', 'one')],'invisible': [('product_selection', '!=', 'one')]}"
|
||||
required="product_selection == 'one'"
|
||||
invisible="product_selection != 'one'"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
<field
|
||||
name="category_id"
|
||||
attrs="{'required': [('product_selection', '=', 'category')],'invisible': [('product_selection', '!=', 'category')]}"
|
||||
required="product_selection == 'category'"
|
||||
invisible="product_selection != 'category'"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
<field
|
||||
name="lot_ids"
|
||||
widget="many2many_tags"
|
||||
domain="[('product_id', 'in', product_ids)]"
|
||||
attrs="{'required': [('product_selection', '=', 'lot')],'invisible': [('product_selection', '!=', 'lot')]}"
|
||||
readonly="state in ['in_progress', 'done']"
|
||||
required="product_selection == 'lot'"
|
||||
invisible="product_selection != 'lot'"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
@@ -175,7 +189,7 @@
|
||||
<menuitem
|
||||
id="menu_action_inventory_tree"
|
||||
name="Inventory Adjustments"
|
||||
parent="stock.menu_stock_warehouse_mgmt"
|
||||
parent="stock.menu_stock_adjustments"
|
||||
sequence="30"
|
||||
action="action_view_inventory_group_form"
|
||||
/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<field name="lot_id" />
|
||||
<field name="location_id" />
|
||||
<field name="location_dest_id" />
|
||||
<field name="qty_done" />
|
||||
<field name="quantity" />
|
||||
<field name="company_id" optional="hide" />
|
||||
<field name="reference" optional="show" />
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user