Odoo Help

0

How to get value from stock.pack.operation to stock.quant?

By
wizardz
on 11/24/16, 10:57 AM 480 views

I have made a new field here in stock.pack.operation model:


Now how can I give the value to the field of model stock.quant? =



Here I have the field test. like this in my code:

How can I give the value to this field in quants??

no ideas?

# -*- coding: utf-8 -*-
from openerp import models, fields, api

class gio_stock_pack_picking(models.Model):
    _inherit = ["stock.pack.operation"]
    field1 = fields.Float('Stückpreis')

class gio_stock_quant(models.Model):
    _inherit = ["stock.quant"]
    field2 = fields.Float(string='Stückpreis')

0
Douglas Barbosa
On 8/21/17, 6:31 PM

class StockPackOperation(models.Model):

    _inherit = 'stock.pack.operation'

field1 = fields.Float('Stückpreis')	


@api.multi

@api.constrains("field1")

    def _update_quant(self):

        line = None

        Lines = None   

        for move in self:

            line = ({

                'field1': move. field1,

            })

            lines = self.env['stock.quant'].search([('order_id.name','=', move.picking_id.origin),('product_id.id','=', move.product_id.id)]).update(line)

        return True



You can use the example below, I'm using order_id as an example plus you can use other fields so that stock.quant receives the value typed in stock.pack.operation



Do not forget to give a little tip there! went

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.

Register

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)

Stats

Asked: 11/24/16, 10:57 AM
Seen: 480 times
Last updated: 8/21/17, 6:31 PM