[9.0][IMP] stock_cycle_count: add server action to confirm several CC at a time

This commit is contained in:
lreficent
2017-05-17 11:56:30 +02:00
committed by Lois Rilo
parent d609c947a0
commit 5ac6c086d2
3 changed files with 37 additions and 1 deletions

View File

@@ -32,6 +32,15 @@ To install this module, you need to:
* Download this module to your addons path.
* Install the module in your database.
Recommendations
---------------
It is highly recommended to use this module in conjunction with:
* `stock_inventory_verification_request`: Adds the capability to request Slot
Verifications.
* `stock_inventory_lockdown`: Lock down locations during inventories.
Configuration
=============

View File

@@ -3,7 +3,8 @@
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from openerp import api, fields, models, _
from openerp.exceptions import UserError
class StockCycleCount(models.Model):
@@ -71,6 +72,10 @@ class StockCycleCount(models.Model):
@api.one
def action_create_inventory_adjustment(self):
if self.state != 'draft':
raise UserError(_(
"You can only confirm cycle counts in state 'Planned'."
))
data = self._prepare_inventory_adjustment()
self.env['stock.inventory'].create(data)
self.state = 'open'

View File

@@ -127,4 +127,26 @@
name="Cycle Counts" parent="stock.menu_stock_inventory_control"
action="action_stock_cycle_count" />
<!-- Action to confirm several Stock Cycle Counts -->
<record id="action_server_cycle_count_confirm"
model="ir.actions.server">
<field name="name">Confirm Cycle Counts</field>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_stock_cycle_count" />
<field name="state">code</field>
<field name="code">self.action_create_inventory_adjustment(cr, uid, context.get('active_ids', []), context=context)</field>
</record>
<record model="ir.values" id="action_cycle_count_confirm">
<field name="name">confirm several cycle counts</field>
<field name="action_id"
ref="action_server_cycle_count_confirm" />
<field name="value" eval="'ir.actions.server,' + str(ref('action_server_cycle_count_confirm'))" />
<field name="key">action</field>
<field name="model_id" ref="model_stock_cycle_count" />
<field name="model">stock.cycle.count</field>
<field name="key2">client_action_multi</field>
</record>
</odoo>