[ADD] stock_picking_wave: chatter in picking waves

Useful if you want to the pickings to be done to your carrier by sending
her the picking list.
This commit is contained in:
Hitesh Trivedi
2015-03-31 18:24:11 +02:00
committed by Richard Mathot
parent 6e14dd0ef9
commit 5e45084f1a
4 changed files with 28 additions and 6 deletions
+1
View File
@@ -32,6 +32,7 @@ This module adds the picking wave option in warehouse management.
'depends': ['stock'],
'data': ['security/ir.model.access.csv',
'stock_picking_wave_view.xml',
'stock_picking_wave_data.xml',
'stock_picking_wave_sequence.xml',
'wizard/picking_to_wave_view.xml',
],
@@ -4,14 +4,15 @@ 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', help='Person responsible for this wave'),
'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", required=True, copy=False),
'state': fields.selection([('draft', 'Draft'), ('in_progress', 'Running'), ('done', 'Done'), ('cancel', 'Cancelled')], string="State", track_visibility='onchange', required=True, copy=False),
}
_defaults = {
@@ -56,11 +57,19 @@ class stock_picking_wave(osv.osv):
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):
record = self.browse(cr, uid, ids[0], context=context)
if 'state' in init_values and record.state != 'draft':
return 'stock_picking_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"
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Picking Wave related subtypes for messaging / Chatter -->
<record id="stock_picking_wave.state" model="mail.message.subtype">
<field name="name">Stage Changed</field>
<field name="res_model">stock.picking.wave</field>
<field name="default" eval="False"/>
<field name="description">Stage Changed</field>
</record>
</odoo>
@@ -1,5 +1,4 @@
<openerp>
<data>
<odoo>
<record id="view_picking_wave_form" model="ir.ui.view">
<field name="name">picking.wave.form</field>
<field name="model">stock.picking.wave</field>
@@ -38,6 +37,10 @@
</tree>
</field>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
@@ -123,5 +126,4 @@
</field>
</record>
</data>
</openerp>
</odoo>