跳至內容
選單
此問題已被標幟
1 回覆
5615 瀏覽次數

I'm creating a new record in "stock.picking" model , in order field has "onchange logic".

If order selected then it will add order lines in 'stock.move' upto this working good.

My problem is when am saving a record in 'stock.picking' , getting error

           Following fields invalid: "Stock Moves"

My Code:

    @api.onchange('po_id')

    def onchange_po_id(self):

        print self.id

        if self.po_id:

            pur_line = self.env['purchase.order.line'].search(

                                     [('order_id', '=', self.po_id.id)])

            move_lines = []

            for line in pur_line:

                date_planned = datetime.today().strftime(

                                        DEFAULT_SERVER_DATETIME_FORMAT)

                move_line = {

                    'name': line.product_id.name,

                    'price_unit': line.price_unit,

                    'product_uom': line.product_uom.id,

                    'product_uom_qty': line.product_qty,

                    'product_qty': line.product_qty,

                    'date': date_planned,

                    'date_expected': date_planned,

                    'product_id': line.product_id.id,

                    'state': 'draft',

                    'origin': line.order_id.name,

                    'location_id': line.product_id.property_stock_production.id,

                    'location_dest_id': self.location_dest_id.id,

                }

           move_lines += [(0, 0, move_line)]

            self.move_lines = move_lines


please anyone help us to resolve this issue.



頭像
捨棄
最佳答案

Hi,

If you are writing a one2many like self.movelines = , it should be in this format stock.move(1,2,3). It is not in your case

else you can try like this

self.update({
'move_lines': [(0, 0, {values})],
})


頭像
捨棄
作者

yes i have changes the format of model new_lines = self.env['stock.move'] new_line = new_lines.new(data)

new_lines += new_line but still same error . cant found what is issue

I don't think "new_lines += new_line" will give you the required format.

Try self.update

相關帖文 回覆 瀏覽次數 活動
0
3月 21
6610
3
7月 20
20975
2
1月 19
7072
1
12月 18
3012
1
7月 18
7413