python实现快速创建订单_从销售订单和Od中的产品订单创建新记录
我想在調用事件后用sale order自定義類中的產品創建記錄集。我將在中創建一個記錄銷售訂單和創建發票一樣,我將在我的自定義模塊中創建記錄。在
我所做的是:
在我的自定義類中:class LoadingSlip(models.Model):
_name = 'loading.slip'
_description = 'loading information'
partner_id = fields.Char("Customer Name")
order_date = fields.Date("Order Date")
expiration_date = fields.Date("Expiration Date")
# order_line = fields.One2many('sale.order.line', 'order_id', string="Order Lines")
product_line = fields.One2many('loading.product.line', 'loading_product', string="Loading Products")
class LoadingProduct(models.Model):
_name = 'loading.product.line'
_description = "Loading Product Informations"
products_id = fields.Many2one('product.product', string='Product',
ondelete='restrict', index=True)
quantity = fields.Float(string='Quantity', default=1)
loading_product = fields.Many2one('loading.slip', string="Loading Reference", ondelete='cascade', index='True')
在銷售訂單
^{pr2}$
在銷售訂單行class sales_order(models.Model):
_inherit="sale.order.line"
@api.multi
def _prepare_slip_line(self):
test.set_trace()
self.ensure_one()
res={}
pprint(res)
res={
'products_id': self.product_id.id or False,
'quantity': self.product_uom_qty
}
pprint(res)
@api.multi
def slip_line_create(self, loading_product):
test.set_trace()
prdct_order = self.env['loading.product.line']
for line in self:
vals = line._prepare_slip_line()
prdct_order.create(vals)
我的錯誤是:> /home/diwap/odoo-dev/custom-addons/sales_ext_agni/models/models.py(196)slip_line_create()
195 vals = line._prepare_slip_line()
--> 196 prdct_order.create(vals)
197
ipdb> n
TypeError: "argument of type 'NoneType' is not iterable"
我嘗試過update-and-write方法而不是create在第196行中,但是我沒有得到任何結果,它只是出現了一個空字段,也沒有錯誤。但是,當我嘗試實際的東西,即write()時,我得到了這個錯誤。我的代碼中有什么錯誤嗎?還是我正在做一件可怕的事情。在
總結
以上是生活随笔為你收集整理的python实现快速创建订单_从销售订单和Od中的产品订单创建新记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql分隔符声明_MySQL分隔符发
- 下一篇: 本地数据库与mysql同步软件下载_Sy