From 7948193fe09e9866a535bdf8c36735e613cd2bea Mon Sep 17 00:00:00 2001 From: David Beal Date: Fri, 11 Nov 2016 21:58:03 +0100 Subject: [PATCH] FIX only get supplier code, not default code to avoid confusing --- stock_usability/i18n/fr.po | 19 ++++++++++--------- stock_usability/i18n/stock_usability.pot | 10 +++++----- stock_usability/stock.py | 16 +++++++++------- stock_usability/stock_view.xml | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/stock_usability/i18n/fr.po b/stock_usability/i18n/fr.po index 839c362..9283f04 100644 --- a/stock_usability/i18n/fr.po +++ b/stock_usability/i18n/fr.po @@ -1,19 +1,21 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * stock_usability +# * stock_usability # msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-10 13:46+0000\n" -"PO-Revision-Date: 2016-11-10 13:46+0000\n" +"POT-Creation-Date: 2016-11-11 20:54+0000\n" +"PO-Revision-Date: 2016-11-11 21:56+0100\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" +"Language: fr\n" +"X-Generator: Poedit 1.8.7.1\n" #. module: stock_usability #: view:stock.picking:stock_usability.view_picking_internal_search @@ -215,14 +217,14 @@ msgid "Stock Moves" msgstr "Mouvements de stock" #. module: stock_usability -#: field:stock.move,product_code:0 +#: field:stock.move,product_supplier_code:0 msgid "Supplier Code" msgstr "Code Fournisseur" #. module: stock_usability -#: help:stock.move,product_code:0 -msgid "Supplier product code if exist else product Internal Reference if exist" -msgstr "Code article fournisseur si existant sinon référence interne de l'article si existant" +#: help:stock.move,product_supplier_code:0 +msgid "Supplier product code if Partner is the supplier" +msgstr "Code produit du fournisseur si le partenaire est le fournisseur" #. module: stock_usability #: model:ir.model,name:stock_usability.model_stock_picking_type @@ -254,4 +256,3 @@ msgstr "Unité de Mesure" #: view:stock.move:stock_usability.view_move_picking_tree msgid "Unreserve" msgstr "Déréserver" - diff --git a/stock_usability/i18n/stock_usability.pot b/stock_usability/i18n/stock_usability.pot index 9940310..c3a045f 100644 --- a/stock_usability/i18n/stock_usability.pot +++ b/stock_usability/i18n/stock_usability.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-11 17:22+0000\n" -"PO-Revision-Date: 2016-11-11 17:22+0000\n" +"POT-Creation-Date: 2016-11-11 20:54+0000\n" +"PO-Revision-Date: 2016-11-11 20:54+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -215,13 +215,13 @@ msgid "Stock Moves" msgstr "" #. module: stock_usability -#: field:stock.move,product_code:0 +#: field:stock.move,product_supplier_code:0 msgid "Supplier Code" msgstr "" #. module: stock_usability -#: help:stock.move,product_code:0 -msgid "Supplier product code if exist else product Internal Reference if exist" +#: help:stock.move,product_supplier_code:0 +msgid "Supplier product code if Partner is the supplier" msgstr "" #. module: stock_usability diff --git a/stock_usability/stock.py b/stock_usability/stock.py index 12d5da3..4354be4 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -77,11 +77,10 @@ class StockWarehouseOrderpoint(models.Model): class StockMove(models.Model): _inherit = 'stock.move' - product_code = fields.Char( - string='Supplier Code', compute='_compute_product_code', + product_supplier_code = fields.Char( + string='Supplier Code', compute='_compute_supplier_code', store=True, readonly=True, - help="Supplier product code if exist else product " - "Internal Reference if exist") + help="Supplier product code if Partner is the supplier") # It seems that it is not necessary any more to # have the digits= on these 2 fields to fix the bug @@ -93,11 +92,14 @@ class StockMove(models.Model): @api.multi @api.depends('product_id', 'picking_id.partner_id') - def _compute_product_code(self): + def _compute_supplier_code(self): for rec in self: + supplier_code = False if rec.picking_id.partner_id and rec.product_id: - rec.product_code = rec.with_context( - partner_id=rec.picking_id.partner_id.id).product_id.code + for supplier_info in rec.product_id.seller_ids: + if supplier_info.name == rec.picking_id.partner_id: + supplier_code = supplier_info.product_code + rec.product_supplier_code = supplier_code def name_get(self, cr, uid, ids, context=None): '''name_get of stock_move is important for the reservation of the diff --git a/stock_usability/stock_view.xml b/stock_usability/stock_view.xml index 4ca021d..e23c828 100644 --- a/stock_usability/stock_view.xml +++ b/stock_usability/stock_view.xml @@ -162,7 +162,7 @@ states="confirmed,assigned"/> - +