Skip to Content
Menu
This question has been flagged
1 Atsakyti
3330 Rodiniai

In odoo there is the possibility to automatically copy what you put in another field ?. For example, a document depends on a date but the detail of the document must also have the same date and I do not want to put it manually every time but I want the one I put to be automatically copied. Is there any way to do that?   link exampple: \https://ibb.co/WzLCWrW

Use this code to copy the date from one table to another but it is not copied. 

@ api.onchange ('document_id')       

def _check_date (self):           

self.date = self.document_id.date 


Portretas
Atmesti
Best Answer

Hello Azchileno,

Need to pass the context in document object to document line from the xml file.
Write the default get method in the document line object to get the date from the context which is passed in xml file of document object.
Eg:

pass context in document line object of document form view
<field name="document_line_ids" context="{'document_date': date}">

Add the below code in document line object default get method:
@api.model
def default_get(self, fields):
context = self._context or {}
res = super(Class, self).default_get(fields)
if context.get('document_date'):
res['date'] = context.get('document_date')
return res


Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
3
vas. 25
3372
0
geg. 24
46
1
bal. 24
3280
4
rugs. 23
4755
2
rugs. 23
6974