diff --git a/addons/stock_picking_wave/__openerp__.py b/addons/stock_picking_wave/__openerp__.py
index 7eef4a93889..3a1acbbc6c0 100644
--- a/addons/stock_picking_wave/__openerp__.py
+++ b/addons/stock_picking_wave/__openerp__.py
@@ -21,5 +21,4 @@ This module adds the picking wave option in warehouse management.
'data/stock_picking_wave_demo.xml',
],
'installable': True,
- 'auto_install': False,
}
diff --git a/addons/stock_picking_wave/data/ir_sequence_data_picking_wave.xml b/addons/stock_picking_wave/data/ir_sequence_data_picking_wave.xml
index c38da83cc2f..f80128bbfb0 100644
--- a/addons/stock_picking_wave/data/ir_sequence_data_picking_wave.xml
+++ b/addons/stock_picking_wave/data/ir_sequence_data_picking_wave.xml
@@ -1,5 +1,5 @@
-
+
@@ -10,4 +10,4 @@
-
+
diff --git a/addons/stock_picking_wave/data/stock_picking_wave_demo.xml b/addons/stock_picking_wave/data/stock_picking_wave_demo.xml
index 5e9cf4a785d..2d074370200 100644
--- a/addons/stock_picking_wave/data/stock_picking_wave_demo.xml
+++ b/addons/stock_picking_wave/data/stock_picking_wave_demo.xml
@@ -1,6 +1,5 @@
-
-
+
@@ -123,5 +122,4 @@
-
-
+
diff --git a/addons/stock_picking_wave/models/__init__.py b/addons/stock_picking_wave/models/__init__.py
index 2c858e134f3..997875f4684 100644
--- a/addons/stock_picking_wave/models/__init__.py
+++ b/addons/stock_picking_wave/models/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
-import stock_picking_wave
\ No newline at end of file
+import stock_picking_wave
diff --git a/addons/stock_picking_wave/models/stock_picking_wave.py b/addons/stock_picking_wave/models/stock_picking_wave.py
index 95c85548f95..d4704fa2762 100644
--- a/addons/stock_picking_wave/models/stock_picking_wave.py
+++ b/addons/stock_picking_wave/models/stock_picking_wave.py
@@ -1,77 +1,83 @@
# -*- coding: utf-8 -*-
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
-from openerp.exceptions import UserError
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
-class stock_picking_wave(osv.osv):
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError
+
+
+class StockPickingWave(models.Model):
_inherit = "mail.thread"
_name = "stock.picking.wave"
_description = "Picking Wave"
_order = "name desc"
- _columns = {
- 'name': fields.char('Picking Wave Name', required=True, help='Name of the picking wave', copy=False),
- 'user_id': fields.many2one('res.users', 'Responsible', track_visibility='onchange', help='Person responsible for this wave'),
- 'picking_ids': fields.one2many('stock.picking', 'wave_id', 'Pickings', help='List of picking associated to this wave'),
- 'state': fields.selection([('draft', 'Draft'), ('in_progress', 'Running'), ('done', 'Done'), ('cancel', 'Cancelled')], string="State", track_visibility='onchange', required=True, copy=False),
- }
- _defaults = {
- 'name': '/',
- 'state': 'draft',
- }
+ name = fields.Char(
+ string='Picking Wave Name', default='/',
+ copy=False, required=True,
+ help='Name of the picking wave')
+ user_id = fields.Many2one(
+ 'res.users', string='Responsible', track_visibility='onchange',
+ help='Person responsible for this wave')
+ picking_ids = fields.One2many(
+ 'stock.picking', 'wave_id', string='Pickings',
+ help='List of picking associated to this wave')
+ state = fields.Selection([
+ ('draft', 'Draft'),
+ ('in_progress', 'Running'),
+ ('done', 'Done'),
+ ('cancel', 'Cancelled')], default='draft',
+ copy=False, track_visibility='onchange', required=True)
- def confirm_picking(self, cr, uid, ids, context=None):
- picking_todo = self.pool.get('stock.picking').search(cr, uid, [('wave_id', 'in', ids)], context=context)
- self.write(cr, uid, ids, {'state': 'in_progress'}, context=context)
- return self.pool.get('stock.picking').action_assign(cr, uid, picking_todo, context=context)
+ @api.multi
+ def confirm_picking(self):
+ pickings_todo = self.mapped('picking_ids')
+ self.write({'state': 'in_progress'})
+ return pickings_todo.action_assign()
- def cancel_picking(self, cr, uid, ids, context=None):
- picking_todo = self.pool.get('stock.picking').search(cr, uid, [('wave_id', 'in', ids)], context=context)
- self.pool.get('stock.picking').action_cancel(cr, uid, picking_todo, context=context)
- return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
+ @api.multi
+ def cancel_picking(self):
+ self.mapped('picking_ids').action_cancel()
+ return self.write({'state': 'cancel'})
- def print_picking(self, cr, uid, ids, context=None):
- '''
- This function print the report for all picking_ids associated to the picking wave
- '''
- context = dict(context or {})
- picking_ids = []
- for wave in self.browse(cr, uid, ids, context=context):
- picking_ids += [picking.id for picking in wave.picking_ids]
- if not picking_ids:
+ @api.multi
+ def print_picking(self):
+ pickings = self.mapped('picking_ids')
+ if not pickings:
raise UserError(_('Nothing to print.'))
- context['active_ids'] = picking_ids
- context['active_model'] = 'stock.picking'
- return self.pool.get("report").get_action(cr, uid, [], 'stock.report_picking', context=context)
+ return self.env["report"].with_context(active_ids=pickings.ids, active_model='stock.picking').get_action(pickings, 'stock.report_picking')
- def create(self, cr, uid, vals, context=None):
+ @api.model
+ def create(self, vals):
if vals.get('name', '/') == '/':
- vals['name'] = self.pool.get('ir.sequence').next_by_code(cr, uid, 'picking.wave') or '/'
- return super(stock_picking_wave, self).create(cr, uid, vals, context=context)
+ vals['name'] = self.env['ir.sequence'].next_by_code('picking.wave') or '/'
+ return super(StockPickingWave, self).create(vals)
- def done(self, cr, uid, ids, context=None):
- picking_todo = set()
- for wave in self.browse(cr, uid, ids, context=context):
- for picking in wave.picking_ids:
- if picking.state in ('cancel', 'done'):
- continue
- if picking.state != 'assigned':
- raise UserError(_('Some pickings are still waiting for goods. Please check or force their availability before setting this wave to done.'))
- message_body = "%s: %s %s" % (_("Transferred by"), _("Picking Wave"), wave.id, wave.name)
- picking.message_post(body=message_body)
- picking_todo.add(picking.id)
- if picking_todo:
- self.pool.get('stock.picking').action_done(cr, uid, list(picking_todo), context=context)
- return self.write(cr, uid, ids, {'state': 'done'}, context=context)
+ @api.multi
+ def done(self):
+ pickings = self.mapped('picking_ids').filtered(lambda picking: picking.state not in ('cancel', 'done'))
+ if any(picking.state != 'assigned' for picking in pickings):
+ raise UserError(_('Some pickings are still waiting for goods. Please check or force their availability before setting this wave to done.'))
+ for picking in pickings:
+ picking.message_post(
+ body="%s: %s %s" % (
+ _("Transferred by"),
+ _("Picking Wave"),
+ picking.wave_id.id,
+ picking.wave_id.name))
+ if pickings:
+ pickings.action_done()
+ return self.write({'state': 'done'})
- def _track_subtype(self, cr, uid, ids, init_values, context=None):
+ def _track_subtype(self, init_values):
if 'state' in init_values:
return 'stock_picking_wave.mt_wave_state'
- return super(stock_picking_wave, self)._track_subtype(cr, uid, ids, init_values, context=context)
+ return super(StockPickingWave, self)._track_subtype(init_values)
-class stock_picking(osv.osv):
+class StockPicking(models.Model):
_inherit = "stock.picking"
- _columns = {
- 'wave_id': fields.many2one('stock.picking.wave', 'Picking Wave', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, help='Picking wave associated to this picking'),
- }
+
+ wave_id = fields.Many2one(
+ 'stock.picking.wave', string='Picking Wave',
+ states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
+ help='Picking wave associated to this picking')
diff --git a/addons/stock_picking_wave/views/stock_picking_wave_views.xml b/addons/stock_picking_wave/views/stock_picking_wave_views.xml
index a2eb6e38d01..33c0d3b1e85 100644
--- a/addons/stock_picking_wave/views/stock_picking_wave_views.xml
+++ b/addons/stock_picking_wave/views/stock_picking_wave_views.xml
@@ -1,3 +1,4 @@
+
picking.wave.form
diff --git a/addons/stock_picking_wave/wizard/__init__.py b/addons/stock_picking_wave/wizard/__init__.py
index 40ab8564b02..4ac2729d320 100644
--- a/addons/stock_picking_wave/wizard/__init__.py
+++ b/addons/stock_picking_wave/wizard/__init__.py
@@ -1 +1,4 @@
-import stock_picking_to_wave
\ No newline at end of file
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import stock_picking_to_wave
diff --git a/addons/stock_picking_wave/wizard/stock_picking_to_wave.py b/addons/stock_picking_wave/wizard/stock_picking_to_wave.py
index 653567849f3..eb7c8d2305e 100644
--- a/addons/stock_picking_wave/wizard/stock_picking_to_wave.py
+++ b/addons/stock_picking_wave/wizard/stock_picking_to_wave.py
@@ -1,16 +1,18 @@
+# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
-class stock_picking_to_wave(osv.osv_memory):
+from odoo import api, fields, models
+
+
+class StockPickingToWave(models.TransientModel):
_name = 'stock.picking.to.wave'
_description = 'Add pickings to a picking wave'
- _columns = {
- 'wave_id': fields.many2one('stock.picking.wave', 'Picking Wave', required=True),
- }
- def attach_pickings(self, cr, uid, ids, context=None):
+ wave_id = fields.Many2one('stock.picking.wave', string='Picking Wave', required=True)
+
+ @api.multi
+ def attach_pickings(self):
#use active_ids to add picking line to the selected wave
- wave_id = self.browse(cr, uid, ids, context=context)[0].wave_id.id
- picking_ids = context.get('active_ids', False)
- return self.pool.get('stock.picking').write(cr, uid, picking_ids, {'wave_id': wave_id})
\ No newline at end of file
+ self.ensure_one()
+ picking_ids = self.env.context.get('active_ids')
+ return self.env['stock.picking'].browse(picking_ids).write({'wave_id': self.wave_id.id})
diff --git a/addons/stock_picking_wave/wizard/stock_picking_to_wave_views.xml b/addons/stock_picking_wave/wizard/stock_picking_to_wave_views.xml
index 616407624aa..a8ed7dd8bdf 100644
--- a/addons/stock_picking_wave/wizard/stock_picking_to_wave_views.xml
+++ b/addons/stock_picking_wave/wizard/stock_picking_to_wave_views.xml
@@ -1,6 +1,5 @@
-
-
-
+
+
@@ -35,5 +34,4 @@
view_mode="form" target="new" view_type="form"
/>
-
-
\ No newline at end of file
+