我试图覆盖销售订单中的创建方法,以使用销售订单中的当前数据制作采购订单,但我的代码不起作用我试试这个:
@api.multi
def creat(self): # for order in self: # order.state = 'sale' # order.confirmation_date = fields.Datetime.now() # if self.env.context.get('send_email'): # self. force_quotation_send() # order.order_line._action_procurement_create() # if self.env['ir.values'].get_default('sale.config.settings', 'auto_done_setting'): # self.action_done()
self.env['purchase.order'].create({'partner_id': partner_id.id,
'location_id':location_id.id,
'pricelist_id': pricelist_id.id,
'order_line': [(0, 0, {'product_id': product_id.id,
'name': name.id,
'date_planned': date_planned.id,
'price_unit': price_unit.id})]})
return True