Odoo Help


[V8] Custom state in stock.picking

Aurélien Rivet
on 4/13/16, 7:45 AM 754 views


I want to add a custom state "Printed" in stock.picking between "Ready to Transfer" and "Transfer". 

I also want to add a button to go to this state. However, I managed to add button and I created the matching function in my python but I can't change the state of the object.

This is the code of the button action:


def print_report_picking(self):


and the code for adding my new item to the selection:

state = fields.Selection(

[('draft', 'Draft'),

('cancel', 'Cancelled'),

('waiting', 'Waiting Another Operation'),

('confirmed', 'Waiting Availability'),

('partially_available', 'Partially Available'),

('assigned', 'Ready to Transfer'),

('printed', 'Printed'),

('done', 'Transferred')])

Could someone tells me why my state is not updated ?

Jose Vasquez
On 4/13/16, 10:22 AM


First you have to inherit the model

Then add the field again but with your new state

class stock_picking(osv.osv):

 _inherit = 'stock.picking'

_columns = {

'state': fields.function(_state_get, type="selection", copy=False,


'stock.picking': (lambda self, cr, uid, ids, ctx: ids, ['move_type'], 20),

'stock.move': (_get_pickings, ['state', 'picking_id', 'partially_available'], 20)},


('draft', 'Draft'),

('cancel', 'Cancelled'),

('waiting', 'Waiting Another Operation'),

('confirmed', 'Waiting Availability'),

('partially_available', 'Partially Available'),

('assigned', 'Ready to Transfer'),

('done', 'Transferred'),

('printed', 'Printed'),

], string='Status', readonly=True, select=True, track_visibility='onchange',


* Draft: not confirmed yet and will not be scheduled until confirmed\n

* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n

* Waiting Availability: still waiting for the availability of products\n

* Partially Available: some products are available and reserved\n

* Ready to Transfer: products reserved, simply waiting for confirmation.\n

* Transferred: has been processed, can't be modified or cancelled anymore\n

* Cancelled: has been cancelled, can't be confirmed anymore"""



Now xml if you want to see visible in your status bar

<xpath expr="//field[@name='state']" position="attributes"><attribute name="statusbar_visible">"draft,printed,assigned,done" </attribute></xpath>

Greetings, I hope to help you.

Yeah, I've done this, but I did'nt want to write all code in my answer. The problem is when I want to add a button to change state to the new I've created. I can add a button and even write associated function in python. But updating the state through self.write does not work, While updating another field I've created for testing purpose does.

Aurélien Rivet
on 4/14/16, 4:22 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/13/16, 7:45 AM
Seen: 754 times
Last updated: 4/13/16, 10:22 AM