This question has been flagged

there is a long outstanding related field (new API in Odoo 8.0) issue reported on github https://github.com/odoo/odoo/issues/4349,

we have exactly the same issue, Our business case for using related field is as following

there is product (master data) in which the product name and cost (standard price) defined,

we have our business object purchase application(transaction) refer to product, also 2 stored related fields: description(product.name) and price_unit(product.standard_price), in each purchase application, we would like to get the related product name and standard cost from product(master) as default value , but allow authorized users to change the description and standard price for specific purchase application, in this case, we do not want to update the product master!

anyone can explain why currently standard Odoo write back to the original model(master) when related field changed on target model(transaction)? if there is other use cases need this kind of functionality, is there any way  to disable the inverse function on related field, I do think the business case mentioned above should be more common on using related field!

Avatar
Discard
Author

the related source code is as following from fields.py def _inverse_related(self, records): """ Inverse the related field `self` on `records`. """ # for record in records: # other = record # # traverse the intermediate fields, and keep at most one record # for name in self.related[:-1]: # other = other[name][:1] # if other: # other[self.related[-1]] = record[self.name]

Author Best Answer

I have a simple hack on this by the following code in a customized module.


from openerp import fields

def fix_related_field_inverse_related(self, records):

pass

fields.Field._inverse_related = fix_related_field_inverse_related

Avatar
Discard