Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Send and return values in action window button

Avatar
odoo
Avatar
Discard
1 Answer
0
Avatar
odoo
Best Answer

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.

Avatar
Discard