How To Override Copy
Function in Odoo 17
Enterprise
Introduction
Enterprise
In this slide we’ll discuss on how to override copy function in
Odoo 17. This helps to customize how records are duplicated.
This allows us to control the behavior when duplicating records,
such as modifying specific fields or applying custom logic.
Enterprise
We can override the copy function in our custom module. Here
along with the field ‘parent_name’, we will add a copy string to
identify the record as a duplicated one.
Enterprise
Similarly, for the field ‘date_of_birth’, we will add the parameter
copy=False, so that while duplicating the record, this field wont
be copied. By default, copy=True for all fields.
Enterprise
In the copy function, we are adding a string ‘copy’ to the
parent_name, and also standard field is set null value always
when copying.
Enterprise
In our custom module we can can duplicate the record by
clicking on Duplicate button.
Enterprise
In this duplicated record, parent name contains the ‘copy’ string.
And ‘standard’ field is null after duplicating as it is set to null in
the copy function. Also DOB field is null because in the field
definition, it is given as copy=False.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

How To Override Copy Function in Odoo 17

  • 1.
    How To OverrideCopy Function in Odoo 17 Enterprise
  • 2.
    Introduction Enterprise In this slidewe’ll discuss on how to override copy function in Odoo 17. This helps to customize how records are duplicated. This allows us to control the behavior when duplicating records, such as modifying specific fields or applying custom logic.
  • 3.
    Enterprise We can overridethe copy function in our custom module. Here along with the field ‘parent_name’, we will add a copy string to identify the record as a duplicated one.
  • 4.
    Enterprise Similarly, for thefield ‘date_of_birth’, we will add the parameter copy=False, so that while duplicating the record, this field wont be copied. By default, copy=True for all fields.
  • 5.
    Enterprise In the copyfunction, we are adding a string ‘copy’ to the parent_name, and also standard field is set null value always when copying.
  • 6.
    Enterprise In our custommodule we can can duplicate the record by clicking on Duplicate button.
  • 7.
    Enterprise In this duplicatedrecord, parent name contains the ‘copy’ string. And ‘standard’ field is null after duplicating as it is set to null in the copy function. Also DOB field is null because in the field definition, it is given as copy=False.
  • 8.
    For More Info. Checkour company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com