跳至内容
菜单
此问题已终结
1 回复
1015 查看

I have a custom model 'customer.account' and one of the field it has is named 'username'.

username = fields.Char(

        string='Username',

        required=True,

        copy=True

    )

In sale.order, I have added a many2one field and in the view i reference it like this:

<field name="customer_account_id"

                    options="{'no_quick_create': True}"

                    context="{'default_customer_id': partner_id, 'default_is_customer_readonly': True}"

                    invisible="partner_id"/>

The problem is that I want whatever the user typed in before clicking the 'create and edit' option to be set as the username for this customer account. I tried using _rec_name = 'username' inside the customer.account model but no luck. What am i missing?

形象
丢弃
最佳答案

Hello Daniel Bashev,

I Hope You are doing well,

​Please add that highlighted condition inside the context:
​context="{'default_customer_id': partner_id, 'default_is_customer_readonly': True, 'default_username': name}"

Hope this information helps you.

Thanks & Regards,
Kunjan Patel

形象
丢弃
相关帖文 回复 查看 活动
1
6月 25
5080
3
7月 20
11716
4
10月 24
5264
0
11月 16
4079
1
8月 15
4616