Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api.onchange('wm_purchase_id')
- def purchase_order_change(self):
- import pdb
- list_move_ids = self.move_lines.ids # Guardo IDS lineas ya cargadas
- if not self.wm_purchase_id:
- return {}
- if not self.partner_id: # ACTUALIZO PARTNER
- self.partner_id = self.wm_purchase_id.partner_id.id
- # Nuevas lineas
- new_lines = self.env['stock.move']
- date = fields.Datetime.now()
- for line in self.wm_purchase_id.order_line - self.move_lines.mapped(
- 'purchase_line_id'):
- # pdb.set_trace()
- data = {
- 'name': line.order_id.name + ': ' + line.name,
- 'purchase_line_id': line.id,
- 'product_id': line.product_id.id,
- 'product_uom': line.product_uom.id,
- 'product_uom_qty': line.product_qty - line.qty_received,
- 'quantity_done': 0.0,
- 'date': date,
- 'date_expected': date,
- 'location_id': self.location_id.id,
- 'location_dest_id': self.location_dest_id.id,
- 'company_id': self.company_id.id,
- 'procure_method': "make_to_stock",
- }
- new_line = new_lines.create(data)
- list_move_ids.append(new_line.id)
- self.move_lines = [(6, 0, list_move_ids)]
- # self.move_lines[0].purchase_line_id.order_id #
- # RELACION CON Orden de Compra #
- # pdb.set_trace()
- self.wm_purchase_id = False
- return {}
Advertisement
Add Comment
Please, Sign In to add comment