diff --git a/stock_inventory_verification_request/README.rst b/stock_inventory_verification_request/README.rst index 6daaa11f3..81a86ca61 100644 --- a/stock_inventory_verification_request/README.rst +++ b/stock_inventory_verification_request/README.rst @@ -6,8 +6,8 @@ Stock Inventory Verification Request ==================================== -Adds the capability to request a Slot Verification when a inventory is -'Pending to Approve'. When asked from Inventory Adjustment, which have +Adds the capability to request a Slot Verification when an inventory is +'Pending to Approve'. When asked from an inventory adjustment, which have discrepancies over the threshold for the location, a Slot Verification Request will be created for each line that exceed the maximum discrepancy allowed. @@ -15,8 +15,8 @@ allowed. A SVR must be created when warehouse operation (e.g. an inventory adjustment, a cycle count...) uncovers a count discrepancy within a slot (a small stock location), and the discrepancy is greater than the pre-defined acceptable -variance threshold. A stock manager should accept the SVR and assign it to -someone to perform it. +variance threshold. It is a stock manager's task to confirm the SVR and +assign it to someone to perform it. The aim of SVR is to find and fix errors before they are transferred to another location, so they will not be found again in similar stock operations. @@ -38,10 +38,9 @@ In order to use this module act as follow: * Once you have found the problem and you have fixed it 'Mark as Solved' the Verification. - .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/9.0 + :target: https://runbot.odoo-community.org/runbot/153/10.0 Bug Tracker @@ -52,7 +51,6 @@ Bugs are tracked on `GitHub Issues check there if your issue has already been reported. If you spotted it first, help us smash it by providing detailed and welcomed feedback. - Images ------ @@ -63,7 +61,6 @@ Contributors * Lois Rilo Antelo - Maintainer ---------- diff --git a/stock_inventory_verification_request/__init__.py b/stock_inventory_verification_request/__init__.py index 08f93b3a4..149f4e4fd 100644 --- a/stock_inventory_verification_request/__init__.py +++ b/stock_inventory_verification_request/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/stock_inventory_verification_request/__openerp__.py b/stock_inventory_verification_request/__manifest__.py similarity index 92% rename from stock_inventory_verification_request/__openerp__.py rename to stock_inventory_verification_request/__manifest__.py index 72b03ce56..6ccc1ea29 100644 --- a/stock_inventory_verification_request/__openerp__.py +++ b/stock_inventory_verification_request/__manifest__.py @@ -6,7 +6,7 @@ "name": "Stock Inventory Verification Request", "summary": "Adds the capability to request a Slot Verification when " "a inventory is Pending to Approve", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "author": "Eficent, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", @@ -17,7 +17,7 @@ 'views/stock_slot_verification_request_view.xml', 'views/stock_inventory_view.xml', 'data/slot_verification_request_sequence.xml', - 'security/ir.model.access.csv' + 'security/ir.model.access.csv', ], "license": "AGPL-3", 'installable': True, diff --git a/stock_inventory_verification_request/models/__init__.py b/stock_inventory_verification_request/models/__init__.py index 1e646e350..b34bbef15 100644 --- a/stock_inventory_verification_request/models/__init__.py +++ b/stock_inventory_verification_request/models/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import stock_slot_verification_request diff --git a/stock_inventory_verification_request/models/stock_inventory.py b/stock_inventory_verification_request/models/stock_inventory.py index f8fe9e252..43bee7063 100644 --- a/stock_inventory_verification_request/models/stock_inventory.py +++ b/stock_inventory_verification_request/models/stock_inventory.py @@ -3,20 +3,21 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import _, api, fields, models +from odoo import api, fields, models class StockInventory(models.Model): _inherit = 'stock.inventory' - requested_verification = fields.Boolean(string='Requested Verification?', - default=False, copy=False) + requested_verification = fields.Boolean( + string='Requested Verification?', copy=False) slot_verification_ids = fields.One2many( comodel_name='stock.slot.verification.request', string='Slot Verification Requests', inverse_name='inventory_id') @api.multi def action_request_verification(self): + self.ensure_one() self.requested_verification = True for line in self.line_ids: if line.discrepancy_threshold and (line.discrepancy_percent > @@ -41,17 +42,18 @@ class StockInventoryLine(models.Model): @api.multi def action_open_svr(self): - ''' - Open the corresponding Slot Verification Request directly from the - Inventory Lines. - ''' - request_svr_ids = [] - for line in self: - request_svr_ids += line.slot_verification_ids.ids - domain = [('id', 'in', request_svr_ids)] - return {'name': _('Slot Verification Request'), - 'type': 'ir.actions.act_window', - 'res_model': 'stock.slot.verification.request', - 'view_type': 'form', - 'view_mode': 'tree,form', - 'domain': domain} + """Open the corresponding Slot Verification Request directly from the + Inventory Lines.""" + request_svr_ids = self.mapped('slot_verification_ids').ids + action = self.env.ref('stock_inventory_verification_request.' + 'action_slot_verification_request') + result = action.read()[0] + if len(request_svr_ids) > 1: + result['domain'] = [('id', 'in', request_svr_ids)] + elif len(request_svr_ids) == 1: + view = self.env.ref( + 'stock_inventory_verification_request.stock_' + 'slot_verification_request_form_view', False) + result['views'] = [(view and view.id or False, 'form')] + result['res_id'] = request_svr_ids[0] or False + return result diff --git a/stock_inventory_verification_request/models/stock_slot_verification_request.py b/stock_inventory_verification_request/models/stock_slot_verification_request.py index a200494d7..75f43150d 100644 --- a/stock_inventory_verification_request/models/stock_slot_verification_request.py +++ b/stock_inventory_verification_request/models/stock_slot_verification_request.py @@ -3,7 +3,7 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models +from odoo import api, fields, models class SlotVerificationRequest(models.Model): @@ -12,19 +12,24 @@ class SlotVerificationRequest(models.Model): @api.model def create(self, vals): - vals['name'] = self.env['ir.sequence'].next_by_code( - 'stock.slot.verification.request') or '' + if not vals.get('name') or vals.get('name') == '/': + vals['name'] = self.env['ir.sequence'].next_by_code( + 'stock.slot.verification.request') or '/' return super(SlotVerificationRequest, self).create(vals) - @api.one + @api.multi def _count_involved_moves(self): - self.involved_move_count = len(self.involved_move_ids) + for rec in self: + rec.involved_move_count = len(rec.involved_move_ids) - @api.one + @api.multi def _count_involved_inv_lines(self): - self.involved_inv_line_count = len(self.involved_inv_line_ids) + for rec in self: + rec.involved_inv_line_count = len(rec.involved_inv_line_ids) - name = fields.Char(string='Name', readonly=True) + name = fields.Char( + default="/", required=True, + readonly=True, states={'wait': [('readonly', False)]}) inventory_id = fields.Many2one(comodel_name='stock.inventory', string='Inventory Adjustment', readonly=True) @@ -44,36 +49,37 @@ class SlotVerificationRequest(models.Model): string='Assigned to') product_id = fields.Many2one(comodel_name='product.product', string='Product', required=True) - notes = fields.Text('Notes') + notes = fields.Text(string='Notes') involved_move_ids = fields.Many2many( comodel_name='stock.move', relation='slot_verification_move_involved_rel', column1='slot_verification_request_id', column2='move_id', string='Involved Stock Moves') - involved_move_count = fields.Integer(compute=_count_involved_moves) + involved_move_count = fields.Integer(compute='_count_involved_moves') involved_inv_line_ids = fields.Many2many( comodel_name='stock.inventory.line', relation='slot_verification_inv_line_involved_rel', column1='slot_verification_request_id', column2='inventory_line_id', string='Involved Inventory Lines') - involved_inv_line_count = fields.Integer(compute=_count_involved_inv_lines) + involved_inv_line_count = fields.Integer( + compute='_count_involved_inv_lines') - @api.model + @api.multi def _get_involved_moves_domain(self): domain = [('product_id', '=', self.product_id.id), '|', ('location_id', '=', self.location_id.id), ('location_dest_id', '=', self.location_id.id)] return domain - @api.model + @api.multi def _get_involved_lines_domain(self): domain = [('product_id', '=', self.product_id.id), ('location_id', '=', self.location_id.id)] return domain - @api.model + @api.multi def _get_involved_lines_and_locations(self): involved_moves = self.env['stock.move'].search( self._get_involved_moves_domain()) @@ -81,34 +87,34 @@ class SlotVerificationRequest(models.Model): self._get_involved_lines_domain()) return involved_moves, involved_lines - @api.one + @api.multi def action_confirm(self): - self.state = 'open' - involved_moves, involved_lines = \ - self._get_involved_lines_and_locations() - self.involved_move_ids = involved_moves - self.involved_inv_line_ids = involved_lines + self.write({'state': 'open'}) + for rec in self: + involved_moves, involved_lines = \ + rec._get_involved_lines_and_locations() + rec.involved_move_ids = involved_moves + rec.involved_inv_line_ids = involved_lines return True - @api.one + @api.multi def action_cancel(self): - self.state = 'cancelled' + self.write({'state': 'cancelled'}) return True - @api.one + @api.multi def action_solved(self): - self.state = 'done' + self.write({'state': 'done'}) return True @api.multi def action_view_moves(self): - action = self.env.ref('stock.action_move_form2') + action = self.env.ref('stock.stock_move_action') result = action.read()[0] result['context'] = {} - moves_ids = sum([svr.involved_move_ids.ids for svr in self], []) + moves_ids = self.mapped('involved_move_ids').ids if len(moves_ids) > 1: - result['domain'] = \ - "[('id','in',[" + ','.join(map(str, moves_ids)) + "])]" + result['domain'] = [('id', 'in', moves_ids)] elif len(moves_ids) == 1: res = self.env.ref('stock.view_move_form', False) result['views'] = [(res and res.id or False, 'form')] @@ -121,10 +127,9 @@ class SlotVerificationRequest(models.Model): 'stock_inventory_verification_request.action_inv_adj_line_tree') result = action.read()[0] result['context'] = {} - line_ids = sum([svr.involved_inv_line_ids.ids for svr in self], []) + line_ids = self.mapped('involved_inv_line_ids').ids if len(line_ids) > 1: - result['domain'] = \ - "[('id','in',[" + ','.join(map(str, line_ids)) + "])]" + result['domain'] = [('id', 'in', line_ids)] elif len(line_ids) == 1: res = self.env.ref('stock_inventory_verification_request.' 'view_inventory_line_form', False) diff --git a/stock_inventory_verification_request/tests/__init__.py b/stock_inventory_verification_request/tests/__init__.py index 4ff41560f..7748710ec 100644 --- a/stock_inventory_verification_request/tests/__init__.py +++ b/stock_inventory_verification_request/tests/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import test_verification_request diff --git a/stock_inventory_verification_request/tests/test_verification_request.py b/stock_inventory_verification_request/tests/test_verification_request.py index 67ee8ed8b..9ba7a4ade 100644 --- a/stock_inventory_verification_request/tests/test_verification_request.py +++ b/stock_inventory_verification_request/tests/test_verification_request.py @@ -3,8 +3,8 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common -from openerp.exceptions import AccessError +import odoo.tests.common as common +from odoo.exceptions import AccessError class TestStockVerificationRequest(common.TransactionCase): diff --git a/stock_inventory_verification_request/views/stock_inventory_view.xml b/stock_inventory_verification_request/views/stock_inventory_view.xml index f8ccffdcc..6d6df820f 100644 --- a/stock_inventory_verification_request/views/stock_inventory_view.xml +++ b/stock_inventory_verification_request/views/stock_inventory_view.xml @@ -5,7 +5,7 @@ - Inventory form view - SVR extension + Inventory form view - SVR extension stock.inventory @@ -35,7 +35,7 @@ attrs="{'invisible': [('slot_verification_ids', '=', [])]}" name="action_open_svr" type="object" - icon="gtk-open"/> + icon="fa-sticky-note"/>