-
-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] More compatible with 7.0 crm_claim_rma #48
Conversation
@@ -29,3 +30,12 @@ def copy(self, default=None): | |||
default = {} | |||
default['code'] = self.env['ir.sequence'].get('crm.claim') | |||
return super(CrmClaim, self).copy(default) | |||
|
|||
@api.multi | |||
@api.depends('code', 'name') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@api.depends is for computed fields, not for this one.
You should also call super and prefix the code instead hardcoding it for allowing other personalizations.
To provide an upgrade path: * the constraint needs to be relaxed to per company only * 'number' field used as fallback * provide name_get()
323c9a0
to
1dcce88
Compare
Re |
@@ -29,3 +30,14 @@ def copy(self, default=None): | |||
default = {} | |||
default['code'] = self.env['ir.sequence'].get('crm.claim') | |||
return super(CrmClaim, self).copy(default) | |||
|
|||
@api.multi | |||
@api.depends('code') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment has been lost, but again I insist depends is not needed. It's not a computed field, it's a method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, since v8 it is a computed field called display_name with function name_get().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it isn't a new API computed field, which is the one that needs depends. If it was a new computed field, it won't return a value, but assign it. Old style computed fields require triggers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely Fabien would know what he's doing :)
odoo/odoo@b254dad80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not saying it's 100% needed, just that this is how the new API works and the decorator uses it exactly as intended (and unlike the v7/v8 compatibility layer which actually slows things down, this will not have negative perf. impact, the opposite if I understand what the next steps in this area will be). As such, I'm not sure why it's bothering you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I'm totally shocked now by this use that I haven't found, but it seems that both uses (depends and triggers) are interoperable in new and old API fields, so cool, let's keep it. Thanks for opening my eyes in this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! I'm still finding cool new use cases with the new API even now. Makes some things so much easier to express.
Can you please rebase and update your code accordingly? |
This is one year old PR without anwwer, closing |
To provide an upgrade path from crm_claim_rma from 7.0:
'number'
field used as fallbackname_get()