[MGR] Migrated product_customer_code to version 10#236
[MGR] Migrated product_customer_code to version 10#236
Conversation
|
Please check Travis status |
e656ead to
1e86c2b
Compare
|
Fixes to pass all tests added |
|
fix issue with product search (PCatinean#1) |
|
@invitu thanks for the fix. I also thought about what was the intention, showing only the code, only the product, or a mix of both (I would have wanted to go this route). But it's up for debate I guess |
|
I think it needs product_code.mapped('product').name_get()? |
|
BTW, I think it would be useful to show both product and customer_code in display_name (in sale_order for example) |
|
@invitu I thought of the exact same pattern. If others agree I will make it like that np |
|
I believe something similar exists (unported from 7 or 8): https://github.com/OCA/sale-workflow/blob/10.0/product_customer_code_sale/__manifest__.py Not exactly the same as you described but quite close. |
|
I think that we don't need product_customer_code_sale anymore if we append customer_code by overwriting ProductProduct.name_get() |
|
Well, you still need to get somehow (with the context) the customer involved, so a minimum change in sale is needed. |
|
@pedrobaeza self._context.get('partner_id') in ProductProduct does the job doesn't it ? |
|
@invitu it does not, that implies the partner_id has been sent via the context which does not happen by default. One semi-solution would be to browse the active_id (whichever model it is) and scan for relational fields towards res.partner and use that (if there is just one or such). But this approach is messy and can have bad consequences |
|
I just saw that another PR is pending here #122 @pedrobaeza suggested to use product_supplierinfo_for_customer #122 (comment) in order not to create a new model and it never happened Another PR for product_customer_code_sale is here OCA/sale-workflow#345 |
|
@PCatinean I think that we only need customer code in a sale_order context so partner_id can be retrieved. In other case, we don't need customer_code, so it's not a problem if we don't have it |
|
@PCatinean could you check PCatinean#4 ? It seems to work for me... |
|
Runbot is not working even after rebuilt 😕 |
|
@PCatinean I would rename the fields as defined in #122, for instance We can make a PR |
|
@eLBati I followed the contributing guideline from OCA: https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#variable-names If this is required/needed by OCA maintainers then I will rename of course. What else is needed to merge this PR? |
|
@PCatinean variable names are different from field names, see |
b324939 to
8857651
Compare
|
@eLBati right you are, my bad I mixed thing up. Updating now |
d4c1d84 to
db8870c
Compare
| ) | ||
|
|
||
| _sql_constraints = [ | ||
| ('unique_code', 'unique(product_code,company,partner)', |
There was a problem hiding this comment.
Check the runbot warning related to this:
WARNING openerp_test odoo.models.schema: Table 'product_customer_code': unable to add constraint 'unique(product_code,company,partner)'!
If you want to have it, you should update the records and execute manually:
|
I'm not familiar with That said, it does need a rename - |
|
@lasley no the context is already bound. In fact in my functional review I noted that the context is potentially problematic as it is set in views other than sale related ones. partner_id is a very common context key. All customer_code_sale does is add the column to sale order line, which I guess was kind of my point about the name_get return. I don't really care, but it seems pointless to have a module which stores customer partcodes, then another to display them. What other module would make use of such a base module? Why would you not just have as a security option like uom or discount? But in any case the main thrust was the fact that we have PR's for 2 modules doing the same thing more or less being the supplierinfo one and this. |
|
@gdgellatly @lasley I don't know about Recap on the main functionalities
About menu we would move it to
Agree |
|
@gdgellatly I can't see the problem with |
|
@eLBati @lasley I wasn't overly clear. The 2 modules do roughly the same as the supplierinfo_customer modules. As I say I don't care whether you keep these as one or two, but its hard to converse if no one even wants to look at the other module to see if they are functionally similar or the same. See https://github.com/OCA/product-attribute/tree/8.0/product_supplierinfo_for_customer and #271 The potential problem with partner_id in context is every other model that isn't customer related. For example, purchase orders. In the context of purchases, is the partner a partner, a customer or a supplier? Should customer codes be searched on purchases? What if supplierinfo is also set? If functionally the answer is yes, no problem, it was just to me when I saw customer_code I guess I expected it used only in customer related contexts. What about manufacturing, pickings etc? |
|
@gdgellatly - I see your point. Maybe what we need to do instead is abstract the terminology into more of a partner code instead. In the context of sales, it's a customer code. In the context of purchases, it's a vendor code. In the context of manufacturing, maybe a supplier code or something. Basically we're trying to maintain a code for Product A against Partners A, B, and C regardless of context. Then whatever glue modules simply add the context. Am I oversimplifying this? |
|
@lasley It wasn't what I was thinking but yes. Ultimately there is a need to maintain partners codes and they wouldn't differ depending on the users context. That said, I do wonder how big the case is that a vendor buys its own products from its customers, and those codes happen to overlap with internal codes, and those codes would be stored. Only time I really see it is when vendor runs out of stock and needs to supply so rounds it up from their customers. Maybe it doesn't matter, not every possible corner case or strange implementation is able to be mitigated. My point was more was that using a very common context key for a specific purpose in a very common ORM method may have unintended side effects. More a warning, than a recommendation. However, I still urge you to look at the supplierinfo_for_customer module. Having looked at both in detail now, functionally I think they serve almost identical use cases (in fact their readme's are nearly the same), but supplierinfo is very DRY in its approach and would additionally support pricing, qty breaks, descriptions. I guess its full featured, enhancing the existing model, whereas this adds customer codes as a seperate model to emulate some of supplierinfo model but not all. Not saying either approach is better or worse, just we potentially have two functionally very similar modules with very different technical approaches in the same repo. |
|
@gdgellatly I looked at I think we should drop |
|
Hi @PCatinean! Thank you for this proposal. In my opinion it makes sense to keep both modules, this one and the proposed here: #122 That one can be an extension of the product_customer_code. What do you think @eLBati ? |
|
Hi @aheficent, the module proposed in this PR and the one proposed in PR #122 are the same module. Instead, |
|
@eLBati Yes, it's the same module name, but as you said, it allows to define prices and pricelists based on them. So it adds some extra features that wasn't there before. If you think that the approach in your PR is correct, then the PR in v10 should also incorporate those additional features. BTW, I'm planning to add this to v9. |
No, |
|
@eLBati so I guess both modules cannot coexist, right? |
|
@aheficent they overlap providing the same functionality "defining product codes depending on customers". This is why I propose to drop |
|
@eLBati All right, as product_supplierinfo_for_customer is already in OCA/8.0 I agree to keep using that module |
|
We need to decide which module is going to be ported either this or product_supplierinfo_for_customer. @eLBati @PCatinean |
|
@aheficent I was not sure what to say, there a quite a few differences of opinion. Can't say I have a definitive one myself. If further changes are needed to the module I'll be glad to carry them out. Regarding organisation of modules in OCA I don't have such a broad perspective as others to decide [ EDIT ] |
|
Take this for a grain of salt, because I don't use either of these. I looked at the two and agree that one should be deprecated. I am thinking that |
|
@lasley @PCatinean @aheficent Sorry, I didn't really mean to kick all this off, thought it would take a couple of days to sort through, not months. Just saw 2 modules with largely the same functionality and thought 1 would be better that combines best of both. I'm not invested either way as like @lasley I don't use either, but if I did it would be the product_supplierinfo_for_customer module. |
|
Well then it's settled, the other module will be used and this will be dropped. |
|
@gdgellatly - no need to be sorry, these types of discussions 100% have to happen. Sometimes it takes a while because we're all volunteers here, but it's all for the greater goal of having the ultra-supreme modules as the ones we support. Nobody said ultra-supreme was easy 😉 |
No description provided.