Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
5741 Visualizzazioni

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.



Avatar
Abbandona
Risposta migliore

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})],
})


Avatar
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
0
mar 21
6695
3
lug 20
21076
2
gen 19
7188
1
dic 18
3090
1
lug 18
7461