コンテンツへスキップ
メニュー
この質問にフラグが付けられました
4 返信
12247 ビュー

How can I create a section i sale order line using code(programatically) in odoo. Please provide your valuable answers

アバター
破棄
最善の回答

A section is actually a dummy sale order line with a display type section. 
so you need to create new sale order line with `display_type` line_section and  adjust the position with sequence value

ref: https://github.com/odoo/odoo/blob/12.0/addons/sale/models/sale.py#L1219

アバター
破棄
著作者

How could I can create it in onchange?

How can the duumy sale order line be show in the list view after entered? Right now it is only seen in reports or the preview online function?

最善の回答

Hi,

You can create section programatically by using the following code                

class SaleOrder(models.Model):
_inherit = 'sale.order'

def custom_function(self):
order_lines = []
val = (0, 0, {
'display_type': 'line_section',
'name': 'SECTION NAME',
})
order_lines.append(val)
self.update({'order_line': order_lines})
アバター
破棄

How can the duumy sale order line be show in the list view after entered? Right now it is only seen in reports or the preview online function?

関連投稿 返信 ビュー 活動
1
1月 25
3310
2
8月 24
5805
6
12月 22
8722
1
2月 22
2842
0
9月 20
3583