Skip to Content
Menu
This question has been flagged
1 Reply
2987 Views

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 


Avatar
Discard
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

   

Avatar
Discard
Related Posts Replies Views Activity
3
Feb 25
1642
0
May 24
46
1
Apr 24
2193
4
Sep 23
3418
2
Sep 23
5824