diff options
| author | Virbhadrasinh Gohil <vgo@openerp.com> | 2015-08-05 11:36:33 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2016-04-19 16:01:06 +0200 |
| commit | 030d25f0ded1c92fc5eafd6bd72c8abffe6007bc (patch) | |
| tree | 36783937ae59525d7fa4d02deabb8e8677f7c82e /addons/stock_picking_wave/models | |
| parent | 09c5c241be0faf5780af1786f57981ecf9873a4f (diff) | |
[MOV] stock_picking_wave: rearrange files
Files are renamed and moved according to the guidelines. No change has been
performed in this commit. No bug has been harmed.
Diffstat (limited to 'addons/stock_picking_wave/models')
| -rw-r--r-- | addons/stock_picking_wave/models/__init__.py | 3 | ||||
| -rw-r--r-- | addons/stock_picking_wave/models/stock_picking_wave.py | 77 |
2 files changed, 80 insertions, 0 deletions
diff --git a/addons/stock_picking_wave/models/__init__.py b/addons/stock_picking_wave/models/__init__.py new file mode 100644 index 00000000000..2c858e134f3 --- /dev/null +++ b/addons/stock_picking_wave/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import stock_picking_wave
\ No newline at end of file diff --git a/addons/stock_picking_wave/models/stock_picking_wave.py b/addons/stock_picking_wave/models/stock_picking_wave.py new file mode 100644 index 00000000000..95c85548f95 --- /dev/null +++ b/addons/stock_picking_wave/models/stock_picking_wave.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +from openerp.osv import fields, osv +from openerp.tools.translate import _ +from openerp.exceptions import UserError + +class stock_picking_wave(osv.osv): + _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', + } + + 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) + + 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) + + 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: + 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) + + def create(self, cr, uid, vals, context=None): + 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) + + 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 = "<b>%s:</b> %s <a href=#id=%s&view_type=form&model=stock.picking.wave>%s</a>" % (_("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) + + def _track_subtype(self, cr, uid, ids, init_values, context=None): + 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) + + +class stock_picking(osv.osv): + _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'), + } |
