-
-
Notifications
You must be signed in to change notification settings - Fork 805
[MGR] Migrated product_customer_code to version 10 #236
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
|
|
||
| ========================== | ||
| Customer codes in product | ||
| ========================== | ||
|
|
||
| This module does just like the product.supplierinfo but for customers instead. | ||
| For instance it allows to have different references for the same product | ||
| according to the customer. | ||
|
|
||
| .. figure:: product_customer_code/static/src/img/screenshot1.png | ||
| :alt: alternative description | ||
| :width: 600 px | ||
|
|
||
| Installation | ||
| ============ | ||
|
|
||
| To install this module, you need to: | ||
|
|
||
| Install some of the Apps which enable the product menu to | ||
| see this module in action, like Sales, Purchase or Warehouse Management | ||
|
|
||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| None | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues | ||
| <https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please | ||
| check there if your issue has already been reported. If you spotted it first, | ||
| help us smash it by providing detailed and welcomed feedback. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Images | ||
| ------ | ||
|
|
||
| * Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| * Vauxoo - http://www.vauxoo.com | ||
| * el_rodo_1 <rodo@vauxoo.com> | ||
| * Paul Catinean <pca@pledra.com> | ||
|
|
||
| Maintainer | ||
| ---------- | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| To contribute to this module, please visit https://odoo-community.org. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| import product_customer_code | ||
| import product | ||
| # -*- encoding: utf-8 -*- | ||
|
|
||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,23 @@ | ||
| # -*- encoding: utf-8 -*- | ||
| ########################################################################### | ||
| # Module Writen to OpenERP, Open Source Management Solution | ||
| # | ||
| # Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/ | ||
| # All Rights Reserved. | ||
| # info Vauxoo (info@vauxoo.com) | ||
| ############################################################################ | ||
| # Coded by: el_rodo_1 (rodo@vauxoo.com) | ||
| ############################################################################ | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License as | ||
| # published by the Free Software Foundation, either version 3 of the | ||
| # License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Affero General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Affero General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| # | ||
| ############################################################################## | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2012 Vauxoo - http://www.vauxoo.com | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
| { | ||
| "name": "Products Customer Code", | ||
| "version": "1.0", | ||
| 'version': '10.0.1.0.0', | ||
| "author": "Vauxoo,Odoo Community Association (OCA)", | ||
| "website": "http://www.vauxoo.com/", | ||
| "license": "AGPL-3", | ||
| "category": "Generic Modules/Product", | ||
| "summary": "Add many Customers' Codes in product", | ||
| "depends": [ | ||
| "base", | ||
| "product", | ||
| "product", | ||
| ], | ||
| "description": """ | ||
| Customer' codes in product | ||
| ========================== | ||
|
|
||
| This module does just like the product.supplierinfo but for customers instead. For instance it | ||
| allows to have different references for the same product according to the customer. | ||
|
|
||
| .. image:: product_customer_code/static/src/img/screenshot1.png | ||
|
|
||
| .. tip:: | ||
|
|
||
| You will need install some of the Apps which enable the product menu to see this module in | ||
| action, like Sales, Purchase or Warehouse Management | ||
| """, | ||
| "data": [ | ||
| "security/product_customer_code_security.xml", | ||
| "security/ir.model.access.csv", | ||
| "product_customer_code_view.xml", | ||
| "product_product_view.xml", | ||
| "views/product_customer_code_view.xml", | ||
| "views/product_product_view.xml", | ||
| "views/res_partner_view.xml", | ||
| ], | ||
| "active": False, | ||
| 'installable': False, | ||
| 'installable': True, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # -*- encoding: utf-8 -*- | ||
|
|
||
| from . import product_customer_code | ||
| from . import product | ||
| from . import res_partner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2012 Vauxoo - http://www.vauxoo.com | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class ProductProduct(models.Model): | ||
| _inherit = "product.product" | ||
|
|
||
| product_customer_code_ids = fields.One2many( | ||
| comodel_name='product.customer.code', | ||
| inverse_name='product_id', | ||
| string='Customer Codes', | ||
| copy=False | ||
| ) | ||
|
|
||
| @api.model | ||
| def name_search(self, name='', args=None, operator='ilike', limit=100): | ||
| res = super(ProductProduct, self).name_search( | ||
| name=name, args=args, operator=operator, limit=limit) | ||
| if (len(res) < limit): | ||
| partner_id = self._context.get('partner_id') | ||
| if partner_id: | ||
| product_customer_code_obj = self.env['product.customer.code'] | ||
| product_codes = product_customer_code_obj.search([ | ||
| ('product_code', operator, name), | ||
| ('partner_id', '=', partner_id) | ||
| ], limit=limit) | ||
| res.extend(product_codes.mapped('product_id').name_get()) | ||
| return res | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2012 Vauxoo - http://www.vauxoo.com | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ProductCustomerCode(models.Model): | ||
| _name = "product.customer.code" | ||
| _description = "Add multiple product customer codes" | ||
|
|
||
| _rec_name = 'product_code' | ||
|
|
||
| product_code = fields.Char( | ||
| string='Customer Product Code', | ||
| required=True, | ||
| help="This customer's product code will be used when searching into" | ||
| "a request for quotation.", | ||
| ) | ||
|
|
||
| product_name = fields.Char( | ||
| string='Customer Product Name', | ||
| help="This customer's product name will be used when searching into" | ||
| "a request for quotation.", | ||
| ) | ||
|
|
||
| product_id = fields.Many2one( | ||
| comodel_name='product.product', | ||
| string='Product', | ||
| required=True, | ||
| ) | ||
|
|
||
| partner_id = fields.Many2one( | ||
| comodel_name='res.partner', | ||
| string='Customer', | ||
| required=True, | ||
| index=True, | ||
| ) | ||
|
|
||
| company_id = fields.Many2one( | ||
| comodel_name='res.company', | ||
| string='Company', | ||
| required=False, | ||
| default=lambda self: self.env['res.company']._company_default_get(), | ||
| ) | ||
|
|
||
| _sql_constraints = [ | ||
| ('unique_code', 'unique(product_code,company_id,partner_id)', | ||
| 'Product customer code must be unique'), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResPartner(models.Model): | ||
| _inherit = 'res.partner' | ||
|
|
||
| product_code_ids = fields.One2many( | ||
| comodel_name='product.customer.code', | ||
| inverse_name='partner_id', | ||
| string='Products', | ||
| ) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Is this what we want? The behaviour before this commit was the customer code. Now I assume it is the [product_code] product name if the display_default_code context key is set.
Would something like
or adjusting name_get be better. Its not great code but hopefully it gives an idea what I mean. Its just from a user perspective I think this will be confusing. Type a product code and get a different one back. Note I've not looked at product_customer_code_sale so maybe its handled there better.
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.
@gdgellatly - This code looks functionally equivalent to the previously merged version IMO, just using the new API. For ease, the previous version: