Skip to Content
मेन्यू
This question has been flagged
1 Reply
5652 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')

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
3
मार्च 20
42839
0
नव॰ 19
2667
1
दिस॰ 16
5924
2
मई 24
3851
1
फ़र॰ 24
1796