Odoo Help


1 Answer
Anton Chepurov
16‏/5‏/2014 10:23 ص

There seem to be 2 problems involved here: (1) the one you've put into the title of your question, and (2) what you actually want to achieve.

Regarding (2), If you want to change the prodlot, just use the prodlot_id field directly (make it editable, if it's not). It will allow you to, both, change the current Lot and  create a new one if you wish. Also, you can add another many2one field of type stock.production.lot if you need a separate, additional Lot in your stock.moves.

Regarding (1) (i.e. sending data on button click), a possible solution is shown in the stock module (stock.py#action_partial_move()). You change button's type to "object":

<button name="action_production_lots_form" groups="base.group_extended" string="NewLot" type="object" icon="terp-stock_effects-object-colorize" colspan="1"/>

And convert act_window's declaration in XML into a Python method action_production_lots_form:

    def action_production_lots_form(self, cr, uid, ids, context=None):
        if context is None: context = {}
        if context.get('active_model') != self._name:
            context.update(active_ids=ids, active_model=self._name)
        partial_id = self.pool.get("stock.partial.move").create(
            cr, uid, {}, context=context)
        return {
            'name':_("Products to Process"),
            'view_mode': 'form',
            'view_id': False,
            'view_type': 'form',
            'res_model': 'stock.partial.move',
            'res_id': partial_id,
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'domain': '[]',
            'context': context

This method is a copy of stock.py#action_partial_move(), but the general idea should be clear.

In this method, you can pass data from active stock.move to the new object (here - stock.partial.move). From that new object you can send data back to initial stock.move object.

Ask a Question
Keep Informed
5 follower(s)
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