日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python实现快速创建订单_从销售订单和Od中的产品订单创建新记录

發布時間:2023/12/20 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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中的产品订单创建新记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。