Guest User

Untitled

a guest
May 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. @api.onchange('wm_purchase_id')
  2.     def purchase_order_change(self):
  3.         import pdb
  4.         list_move_ids = self.move_lines.ids # Guardo IDS lineas ya cargadas
  5.         if not self.wm_purchase_id:
  6.             return {}
  7.         if not self.partner_id:  # ACTUALIZO PARTNER
  8.             self.partner_id = self.wm_purchase_id.partner_id.id
  9.         # Nuevas lineas
  10.         new_lines = self.env['stock.move']
  11.         date = fields.Datetime.now()
  12.         for line in self.wm_purchase_id.order_line - self.move_lines.mapped(
  13.                 'purchase_line_id'):
  14.             # pdb.set_trace()
  15.             data = {
  16.                 'name': line.order_id.name + ': ' + line.name,
  17.                 'purchase_line_id': line.id,
  18.                 'product_id': line.product_id.id,
  19.                 'product_uom': line.product_uom.id,
  20.                 'product_uom_qty': line.product_qty - line.qty_received,
  21.                 'quantity_done': 0.0,
  22.                 'date': date,
  23.                 'date_expected': date,
  24.                 'location_id': self.location_id.id,
  25.                 'location_dest_id': self.location_dest_id.id,
  26.                 'company_id': self.company_id.id,
  27.                 'procure_method': "make_to_stock",
  28.             }
  29.             new_line = new_lines.create(data)
  30.             list_move_ids.append(new_line.id)
  31.         self.move_lines = [(6, 0, list_move_ids)]
  32.         # self.move_lines[0].purchase_line_id.order_id #
  33.         # RELACION CON Orden de Compra #
  34.         # pdb.set_trace()
  35.         self.wm_purchase_id = False
  36.         return {}
Advertisement
Add Comment
Please, Sign In to add comment