[IMP] util.ensure_xmlid_match_record: allow setting the noupdate flag - #499
[IMP] util.ensure_xmlid_match_record: allow setting the noupdate flag#499luisg123v wants to merge 1 commit into
Conversation
|
Hi @aj-fuentes, What do you think? Regards, |
|
FYI @isaako34 |
The external IDs were always created as `noupdate`, now the flag can be specified: - If it doesn't exist, it's created with the given flag, `True` by default (as before) - If it already exists, the flag is only updated if it's explicitly set
4efc611 to
5efb9f0
Compare
|
Hi @luisg123v, What's the use case for this? Why is this better1 than forcing the flag after calling this util? util.ensure_xmlid_match_record(cr, xmlid, values):
util.force_noudate(cr, xmlid, noupdate=no_update_value)We prefer to have a clear use case before altering the API of the utility functions. Footnotes
|
|
@aj-fuentes, If the external ID already exists, your way would be clearer and preferred. But if a new one is being created, It would be created as noupdate, to then being immediately updated. In other words, it would need to be fixed just after creation. But that's the only advantage, I agree nothing is broken, it's just an improvement. If you prefer, I could just add a note in the docstring mentioning the external ID is created as noupdate. BTW, I didn't fully get the Regards, |
|
Hi @luisg123v
Why are they necessarily immediately udpated? In most of our internal usage of this utility we never force the flag after. The point is that this tool ensures an xmlid points to a "valid" record. But if the xmlid didn't exist it is risky, without a case by case analysis, to let it be updated by the ORM. If you anyway had to do a case by case analysis, adding an extra line after for the Here is the main use case of this utility: in many parts in Odoo certain record is expected to always exists and without a duplicate, otherwise something completely fails. Thus, by ensuring the xmlid exists and points to a "valid enough"1 record we can avoid that failure. Updating the record via its xmlid later is out of scope here.
I meant that if the purpose is only to avoid the extra call to
Indeed, that's missing. Thanks! Regards, Footnotes
|

The external IDs were always created as
noupdate, now the flag can be specified:Trueby default (as before)