Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

mistotebe
Copy link

To provide an upgrade path from crm_claim_rma from 7.0:

  • The constraint needs to be relaxed to per company only
  • 'number' field used as fallback
  • Provide name_get()

@@ -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')
Copy link
Member

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()
@mistotebe
Copy link
Author

Re @api.depends: this is how it works in v8, it is a field display_name with function name_get(). Quite a few v9 modules use it, event.event in the event module is an example that uses it in v8. See odoo/odoo@cbe2dbb6 for more information.

@@ -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')
Copy link
Member

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.

Copy link
Author

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().

Copy link
Member

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.

Copy link
Author

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

Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

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.

@pedrobaeza
Copy link
Member

Can you please rebase and update your code accordingly?

@max3903 max3903 modified the milestone: 7.0 Mar 10, 2016
@rafaelbn
Copy link
Member

rafaelbn commented Oct 4, 2016

This is one year old PR without anwwer, closing

@rafaelbn rafaelbn closed this Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants