Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5783 Lượt xem

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')

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Time field in odoo Đã xử lý
3
thg 3 20
43005
0
thg 11 19
2724
1
thg 12 16
6000
2
thg 5 24
3970
1
thg 2 24
1873