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

Hello! How to set a custom or default values on a m2m tag widget?

for example:

In a tax types field, there are 3 types, "income", "value" and "excise"

i want that 3 to be the default value and there is no edit or create.


please help thanks! 

アバター
破棄

Hello! thank you for fast reply. Sorry noob here but I don't understand what does def get_taxes do. Can you explain it to me please? and i want my field to like a combo box but in a m2m tag form/widget

get_taxes method will be called when you are creating a record. This method will return the IDs of those taxes which are of given type.

最善の回答

Hello Nissan,

You can call a method in default and can set the taxes by searching the records.

Ex:

@api.model
def get_taxes(self):
return self.env['my.tax.tax'].search([('type', 'in', ['income', 'value', 'excise'])]).ids

my_taxes = fields.Many2many(default=get_taxes, ...)

Hope this help you.

アバター
破棄
関連投稿 返信 ビュー 活動
2
10月 21
5046
1
4月 17
6145
1
1月 22
5616
1
1月 22
10477
2
6月 25
6164