Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
11322 Vizualizări

Hello All,

I have Facing One problem related to One2many field Active Model .

For Example: 

i am in sale order and i am create any record in sale order line than i am get active_model = sale.order. So any one help me how to get active_model = sale.order.line. I am try to pass this value using context and for this i am using get_default method.

And

How to Change One2many field language according to partner(Customer) language.

Thanks In Advanced


Imagine profil
Abandonează

Could you share piece of code so that people will understand what you are exactly trying to do ?

Autor

Hello Nitin,

I am added one2many field in sale order and below my class.

class CustomerForm(models.Model):

_name = 'customer.from'

_rec_name = 'customer_name'

@api.model

def default_get(self, fields):

rec = super(CustomerForm, self).default_get(fields)

context = dict(self._context or {})

active_model = self.env.context.get('active_model', False)

return rec

My problem is when i am try to print Active Model than It's show 'sale.order' but can you tell me how to get active model name 'customer.from'.

anything wrong in above code ?

Cel mai bun răspuns

Hi Manish,

Pass any value in context in the One2many field in XML file.

Ex:

<field name="my_o2m_lines" context="{'o2m_active_model': 'customer.form'}">
...
</field>

Now, in the default_get method of the customer.form object, you will see "o2m_active_model" key and its value in the context.

Hope this will solve your problem.

Imagine profil
Abandonează

Already default_get method available on customer.form

now my question is why we need to pass in context, by using self we can get it.

am i right?

Autor

Thanks Sudhir, i'm getting this. But my problem is that i want to change language of o2many table according to sale order partner_id(customer). So, can i do this? Means my sale order form should be in english language and my o2many model should open in chinese(according to partner).

Thanks for your reply.

Cel mai bun răspuns

If you want customer.form means, it's available on self

self._name  is  customer.form

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
10
mar. 23
39881
1
ian. 20
5032
2
nov. 19
6824
1
ian. 25
1819
2
oct. 23
6490