mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[12.0][IMP] stock_inventory_verification_request:
* link to created inv. adjustments * add _descrition
This commit is contained in:
committed by
Adrià Gil Sorribes
parent
9cdf9d0fe3
commit
0bbf095e8f
@@ -13,6 +13,10 @@ class StockInventory(models.Model):
|
||||
slot_verification_ids = fields.One2many(
|
||||
comodel_name='stock.slot.verification.request',
|
||||
string='Slot Verification Requests', inverse_name='inventory_id')
|
||||
solving_slot_verification_request_id = fields.Many2one(
|
||||
comodel_name="stock.slot.verification.request",
|
||||
help="This Inventory adjustment was created from the specified SVR."
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_request_verification(self):
|
||||
|
||||
@@ -8,6 +8,7 @@ from odoo import api, fields, models
|
||||
class SlotVerificationRequest(models.Model):
|
||||
_name = 'stock.slot.verification.request'
|
||||
_inherit = 'mail.thread'
|
||||
_description = "Slot Verification Request"
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
@@ -26,6 +27,11 @@ class SlotVerificationRequest(models.Model):
|
||||
for rec in self:
|
||||
rec.involved_inv_line_count = len(rec.involved_inv_line_ids)
|
||||
|
||||
@api.multi
|
||||
def _compute_created_inventory_count(self):
|
||||
for rec in self:
|
||||
rec.created_inventory_count = len(rec.created_inventory_ids)
|
||||
|
||||
name = fields.Char(
|
||||
default="/", required=True,
|
||||
readonly=True, states={'wait': [('readonly', False)]})
|
||||
@@ -71,6 +77,14 @@ class SlotVerificationRequest(models.Model):
|
||||
string='Involved Inventory Lines')
|
||||
involved_inv_line_count = fields.Integer(
|
||||
compute='_compute_involved_inv_line_count')
|
||||
created_inventory_ids = fields.One2many(
|
||||
comodel_name="stock.inventory",
|
||||
string="Created Inventories",
|
||||
inverse_name="solving_slot_verification_request_id",
|
||||
help="These inventory adjustment were created from this SVR.",
|
||||
)
|
||||
created_inventory_count = fields.Integer(
|
||||
compute='_compute_created_inventory_count')
|
||||
|
||||
@api.multi
|
||||
def _get_involved_moves_domain(self):
|
||||
@@ -146,11 +160,13 @@ class SlotVerificationRequest(models.Model):
|
||||
return result
|
||||
|
||||
def action_create_inventory_adjustment(self):
|
||||
self.ensure_one()
|
||||
inventory = self.env["stock.inventory"].sudo().create({
|
||||
"name": "Inventory Adjustment from %s" % self.name,
|
||||
"filter": "product" if self.product_id else "none",
|
||||
"location_id": self.location_id.id,
|
||||
"product_id": self.product_id.id,
|
||||
"solving_slot_verification_request_id": self.id,
|
||||
})
|
||||
action = self.env.ref('stock.action_inventory_form')
|
||||
result = action.read()[0]
|
||||
@@ -159,3 +175,17 @@ class SlotVerificationRequest(models.Model):
|
||||
result['views'] = [(res and res.id or False, 'form')]
|
||||
result['res_id'] = inventory.id
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def action_view_inventories(self):
|
||||
action = self.env.ref("stock.action_inventory_form")
|
||||
result = action.read()[0]
|
||||
result["context"] = {}
|
||||
inventory_ids = self.mapped("created_inventory_ids").ids
|
||||
if len(inventory_ids) > 1:
|
||||
result["domain"] = [("id", "in", inventory_ids)]
|
||||
elif len(inventory_ids) == 1:
|
||||
res = self.env.ref("stock.view_inventory_form", False)
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = inventory_ids and inventory_ids[0] or False
|
||||
return result
|
||||
|
||||
@@ -45,9 +45,18 @@
|
||||
<div class="oe_button_box" name="button_box"
|
||||
attrs="{'invisible':
|
||||
[('state', 'not in', ('open'))]}">
|
||||
<button name="action_view_moves"
|
||||
<button name="action_view_inventories"
|
||||
type="object" class="oe_stat_button"
|
||||
icon="fa-building-o">
|
||||
<field name="created_inventory_count"
|
||||
widget="statinfo"
|
||||
help="Inventory Adjustments created from this SVR."
|
||||
modifiers="{'readonly': true}"
|
||||
string="Inv. Adj. Created"/>
|
||||
</button>
|
||||
<button name="action_view_moves"
|
||||
type="object" class="oe_stat_button"
|
||||
icon="fa-arrows-h">
|
||||
<field name="involved_move_count"
|
||||
widget="statinfo"
|
||||
help="Stock Moves related to the given location and product."
|
||||
@@ -56,7 +65,7 @@
|
||||
</button>
|
||||
<button name="action_view_inv_lines"
|
||||
type="object" class="oe_stat_button"
|
||||
icon="fa-building-o">
|
||||
icon="fa-list">
|
||||
<field name="involved_inv_line_count"
|
||||
widget="statinfo"
|
||||
help="Inventory Adjustment Lines related to the given location and product."
|
||||
|
||||
Reference in New Issue
Block a user