From 4e9c4efc68a030be71ee0ca10cebcf8815579970 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Fri, 11 Oct 2013 10:10:49 +0200 Subject: [PATCH 1/7] [ADD] module sale_line_description --- sale_line_description/__init__.py | 22 +++++++ sale_line_description/__openerp__.py | 45 +++++++++++++ sale_line_description/i18n/it.mo | Bin 0 -> 1084 bytes sale_line_description/i18n/it.po | 51 +++++++++++++++ sale_line_description/res_config.py | 42 ++++++++++++ sale_line_description/res_config_view.xml | 20 ++++++ sale_line_description/sale.py | 61 ++++++++++++++++++ .../security/sale_security.xml | 13 ++++ 8 files changed, 254 insertions(+) create mode 100644 sale_line_description/__init__.py create mode 100644 sale_line_description/__openerp__.py create mode 100644 sale_line_description/i18n/it.mo create mode 100644 sale_line_description/i18n/it.po create mode 100644 sale_line_description/res_config.py create mode 100644 sale_line_description/res_config_view.xml create mode 100644 sale_line_description/sale.py create mode 100644 sale_line_description/security/sale_security.xml diff --git a/sale_line_description/__init__.py b/sale_line_description/__init__.py new file mode 100644 index 00000000000..4ce46f8ba31 --- /dev/null +++ b/sale_line_description/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl +# () +# +# 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 . +# +############################################################################## +import res_config +import sale diff --git a/sale_line_description/__openerp__.py b/sale_line_description/__openerp__.py new file mode 100644 index 00000000000..ba7ec16cd98 --- /dev/null +++ b/sale_line_description/__openerp__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl +# () +# @author Alex Comba +# +# 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 . +# +############################################################################## +{ + 'name': "Sale line description", + 'version': '0.1', + 'category': 'Sales Management', + 'description': """ +This module allows to use only the product description on the sale order lines. +To do so, the user has to belong to group_use_product_description_per_so_line. +This is possible by selecting the related option in the following menu: + +Settings --> Configuration --> Sale --> Sale Features + """, + 'author': 'Agile Business Group', + 'website': 'http://www.agilebg.com', + 'license': 'AGPL-3', + "depends": [ + 'sale', + ], + "data": [ + 'security/sale_security.xml', + 'res_config_view.xml', + ], + "active": False, + "installable": True +} diff --git a/sale_line_description/i18n/it.mo b/sale_line_description/i18n/it.mo new file mode 100644 index 0000000000000000000000000000000000000000..12fcade17dd9e8a9238a54e2d0c5d737df670ecd GIT binary patch literal 1084 zcmb7C!A=xG6l@hetQTXvn0V+L2h!t=K!6dAh(IvluFIk(o_c2sJ03uy-4p7cQsoHSm`U|r5PG@bHII~q#9 z4*#cE0KcEeN@*Ha@$?vfGF2lh5(APWxZ2;{-@4c)gZ)iw0vRZu)vy@oG~BPXROTTs zj-|t8JUSd~i`5HWbZ|sYY?;EAxTu`34pr#%bmOEJ+t!Ud2E7qGWXPR6?O7^S;90Vq zEOl6q+z5A!=qTO\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.5.4\n" + +#. module: sale_line_description +#: field:sale.config.settings,group_use_product_description_per_so_line:0 +msgid "" +"Allow using only product sale description\n" +" on the sales order lines" +msgstr "" +"Permette di utilizzare solo la descrizione del prodotto\n" +" sulle righe dell'ordine di vendita" + +#. module: sale_line_description +#: model:res.groups,name:sale_line_description.group_use_product_description_per_so_line +msgid "Use only product sale description on order lines" +msgstr "" +"Usa solo la descrizione del prodotto sulle righe dell'ordine di vendita" + +#. module: sale_line_description +#: help:sale.config.settings,group_use_product_description_per_so_line:0 +msgid "" +"Allows you to use only product sale description per\n" +" sales order line." +msgstr "" +"Permette di utilizzare solo la descrizione del prodotto per\n" +" linea di ordine di vendita." + +#. module: sale_line_description +#: model:ir.model,name:sale_line_description.model_sale_config_settings +msgid "sale.config.settings" +msgstr "sale.config.settings" + +#. module: sale_line_description +#: model:ir.model,name:sale_line_description.model_sale_order_line +msgid "Sales Order Line" +msgstr "Linea d'ordine di vendita" diff --git a/sale_line_description/res_config.py b/sale_line_description/res_config.py new file mode 100644 index 00000000000..c725f913756 --- /dev/null +++ b/sale_line_description/res_config.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl +# () +# +# 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 . +# +############################################################################## + +import logging + +from openerp.osv import fields, orm +from openerp.tools.translate import _ + +_logger = logging.getLogger(__name__) + + +class sale_configuration(orm.Model): + _inherit = 'sale.config.settings' + + _columns = { + 'group_use_product_description_per_so_line': fields.boolean( + """Allow using only the product sale description + on the sales order lines""", + implied_group="sale_line_description." + "group_use_product_description_per_so_line", + help="""Allows you to use only product sale description on the + sales order line.""" + ), + } diff --git a/sale_line_description/res_config_view.xml b/sale_line_description/res_config_view.xml new file mode 100644 index 00000000000..69de28f4689 --- /dev/null +++ b/sale_line_description/res_config_view.xml @@ -0,0 +1,20 @@ + + + + + + sale settings + sale.config.settings + + + +
+ +
+
+
+
+ +
+
\ No newline at end of file diff --git a/sale_line_description/sale.py b/sale_line_description/sale.py new file mode 100644 index 00000000000..37db173e32c --- /dev/null +++ b/sale_line_description/sale.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl +# () +# +# 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 . +# +############################################################################## + +from openerp.osv import orm + + +class sale_order_line(orm.Model): + _inherit = "sale.order.line" + + def product_id_change( + self, cr, uid, ids, pricelist, product_id, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, packaging=False, + fiscal_position=False, flag=False, context=None + ): + res = super(sale_order_line, self).product_id_change( + cr, uid, ids, pricelist, product_id, qty=qty, uom=uom, + qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, + lang=lang, update_tax=update_tax, date_order=date_order, + packaging=packaging, fiscal_position=fiscal_position, + flag=flag, context=context + ) + try: + user = self.pool.get('res.users').browse( + cr, uid, uid, context=context) + user_groups = [g.id for g in user.groups_id] + group_id = self.pool.get('ir.model.data').get_object_reference( + cr, uid, 'sale_line_description', + 'group_use_product_description_per_so_line' + )[1] + except: + return False + if group_id in user_groups and product_id: + product_obj = self.pool.get('product.product') + product = product_obj.browse(cr, uid, product_id, context=context) + if ( + product + and product.description + and res['value'] + and res['value'].get('name', False) + ): + res['value']['name'] = product.description + return res diff --git a/sale_line_description/security/sale_security.xml b/sale_line_description/security/sale_security.xml new file mode 100644 index 00000000000..4520288304b --- /dev/null +++ b/sale_line_description/security/sale_security.xml @@ -0,0 +1,13 @@ + + + + + + + Use only product sale description on order lines + + + + + + From 71020f40f57cab19f7cf9f6ae0a3f35cf3be2572 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Fri, 11 Oct 2013 10:22:48 +0200 Subject: [PATCH 2/7] [REM] i18n/it.mo --- sale_line_description/i18n/it.mo | Bin 1084 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 sale_line_description/i18n/it.mo diff --git a/sale_line_description/i18n/it.mo b/sale_line_description/i18n/it.mo deleted file mode 100644 index 12fcade17dd9e8a9238a54e2d0c5d737df670ecd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1084 zcmb7C!A=xG6l@hetQTXvn0V+L2h!t=K!6dAh(IvluFIk(o_c2sJ03uy-4p7cQsoHSm`U|r5PG@bHII~q#9 z4*#cE0KcEeN@*Ha@$?vfGF2lh5(APWxZ2;{-@4c)gZ)iw0vRZu)vy@oG~BPXROTTs zj-|t8JUSd~i`5HWbZ|sYY?;EAxTu`34pr#%bmOEJ+t!Ud2E7qGWXPR6?O7^S;90Vq zEOl6q+z5A!=qTO Date: Fri, 11 Oct 2013 11:58:02 +0200 Subject: [PATCH 3/7] [FIX] sale_line_description: replaced orm.Model by osv.TransientModel; improved a bit sale_order_line --- sale_line_description/res_config.py | 4 +-- sale_line_description/sale.py | 56 +++++++++++++++-------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/sale_line_description/res_config.py b/sale_line_description/res_config.py index c725f913756..040a893f769 100644 --- a/sale_line_description/res_config.py +++ b/sale_line_description/res_config.py @@ -21,13 +21,13 @@ import logging -from openerp.osv import fields, orm +from openerp.osv import fields, osv from openerp.tools.translate import _ _logger = logging.getLogger(__name__) -class sale_configuration(orm.Model): +class sale_configuration(osv.TransientModel): _inherit = 'sale.config.settings' _columns = { diff --git a/sale_line_description/sale.py b/sale_line_description/sale.py index 37db173e32c..b9a01cb0890 100644 --- a/sale_line_description/sale.py +++ b/sale_line_description/sale.py @@ -31,31 +31,33 @@ def product_id_change( lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None ): - res = super(sale_order_line, self).product_id_change( - cr, uid, ids, pricelist, product_id, qty=qty, uom=uom, - qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, - lang=lang, update_tax=update_tax, date_order=date_order, - packaging=packaging, fiscal_position=fiscal_position, - flag=flag, context=context - ) - try: - user = self.pool.get('res.users').browse( - cr, uid, uid, context=context) - user_groups = [g.id for g in user.groups_id] - group_id = self.pool.get('ir.model.data').get_object_reference( - cr, uid, 'sale_line_description', - 'group_use_product_description_per_so_line' - )[1] - except: - return False - if group_id in user_groups and product_id: - product_obj = self.pool.get('product.product') - product = product_obj.browse(cr, uid, product_id, context=context) - if ( - product - and product.description - and res['value'] - and res['value'].get('name', False) - ): - res['value']['name'] = product.description + if product_id: + res = super(sale_order_line, self).product_id_change( + cr, uid, ids, pricelist, product_id, qty=qty, uom=uom, + qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, + lang=lang, update_tax=update_tax, date_order=date_order, + packaging=packaging, fiscal_position=fiscal_position, + flag=flag, context=context + ) + try: + user = self.pool.get('res.users').browse( + cr, uid, uid, context=context) + user_groups = [g.id for g in user.groups_id] + group_id = self.pool.get('ir.model.data').get_object_reference( + cr, uid, 'sale_line_description', + 'group_use_product_description_per_so_line' + )[1] + except: + return False + if group_id in user_groups: + product_obj = self.pool.get('product.product') + product = product_obj.browse( + cr, uid, product_id, context=context) + if ( + product + and product.description + and res['value'] + and res['value'].get('name', False) + ): + res['value']['name'] = product.description return res From f5d4a4c3df4392ba3d8c4e76715c95915ee29cbf Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Fri, 11 Oct 2013 12:04:56 +0200 Subject: [PATCH 4/7] [IMP] translation --- sale_line_description/i18n/it.po | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sale_line_description/i18n/it.po b/sale_line_description/i18n/it.po index 26ff9aae708..c42db715b6e 100644 --- a/sale_line_description/i18n/it.po +++ b/sale_line_description/i18n/it.po @@ -6,9 +6,9 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-10-11 07:39+0000\n" -"PO-Revision-Date: 2013-10-11 09:45+0100\n" -"Last-Translator: Alex Comba \n" +"POT-Creation-Date: 2013-10-11 10:02+0000\n" +"PO-Revision-Date: 2013-10-11 12:04+0100\n" +"Last-Translator: Lorenzo Battistini \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -17,13 +17,9 @@ msgstr "" "X-Generator: Poedit 1.5.4\n" #. module: sale_line_description -#: field:sale.config.settings,group_use_product_description_per_so_line:0 -msgid "" -"Allow using only product sale description\n" -" on the sales order lines" -msgstr "" -"Permette di utilizzare solo la descrizione del prodotto\n" -" sulle righe dell'ordine di vendita" +#: model:ir.model,name:sale_line_description.model_sale_config_settings +msgid "sale.config.settings" +msgstr "sale.config.settings" #. module: sale_line_description #: model:res.groups,name:sale_line_description.group_use_product_description_per_so_line @@ -32,20 +28,24 @@ msgstr "" "Usa solo la descrizione del prodotto sulle righe dell'ordine di vendita" #. module: sale_line_description -#: help:sale.config.settings,group_use_product_description_per_so_line:0 +#: field:sale.config.settings,group_use_product_description_per_so_line:0 msgid "" -"Allows you to use only product sale description per\n" -" sales order line." +"Allow using only the product sale description\n" +" on the sales order lines" msgstr "" -"Permette di utilizzare solo la descrizione del prodotto per\n" -" linea di ordine di vendita." - -#. module: sale_line_description -#: model:ir.model,name:sale_line_description.model_sale_config_settings -msgid "sale.config.settings" -msgstr "sale.config.settings" +"Permette di usare solamente la descrizione di vendita del prodotto\n" +"nelle righe dell'ordine di vendita" #. module: sale_line_description #: model:ir.model,name:sale_line_description.model_sale_order_line msgid "Sales Order Line" msgstr "Linea d'ordine di vendita" + +#. module: sale_line_description +#: help:sale.config.settings,group_use_product_description_per_so_line:0 +msgid "" +"Allows you to use only product sale description on the\n" +" sales order line." +msgstr "" +"Permette di usare solamente la descrizione di vendita del prodotto\n" +"nelle righe dell'ordine di vendita" From f796b540286f300b640ec60195324cfdc4494f27 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Fri, 11 Oct 2013 12:22:51 +0200 Subject: [PATCH 5/7] [FIX] sale_line_description: fixed and improved sale_order_line --- sale_line_description/res_config.py | 5 --- sale_line_description/sale.py | 53 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/sale_line_description/res_config.py b/sale_line_description/res_config.py index 040a893f769..e3b804006a0 100644 --- a/sale_line_description/res_config.py +++ b/sale_line_description/res_config.py @@ -19,12 +19,7 @@ # ############################################################################## -import logging - from openerp.osv import fields, osv -from openerp.tools.translate import _ - -_logger = logging.getLogger(__name__) class sale_configuration(osv.TransientModel): diff --git a/sale_line_description/sale.py b/sale_line_description/sale.py index b9a01cb0890..fb1863e7d51 100644 --- a/sale_line_description/sale.py +++ b/sale_line_description/sale.py @@ -31,33 +31,32 @@ def product_id_change( lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None ): + res = super(sale_order_line, self).product_id_change( + cr, uid, ids, pricelist, product_id, qty=qty, uom=uom, + qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, + lang=lang, update_tax=update_tax, date_order=date_order, + packaging=packaging, fiscal_position=fiscal_position, + flag=flag, context=context + ) if product_id: - res = super(sale_order_line, self).product_id_change( - cr, uid, ids, pricelist, product_id, qty=qty, uom=uom, - qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, - lang=lang, update_tax=update_tax, date_order=date_order, - packaging=packaging, fiscal_position=fiscal_position, - flag=flag, context=context + user = self.pool.get('res.users').browse( + cr, uid, uid, context=context) + user_groups = [g.id for g in user.groups_id] + ref = self.pool.get('ir.model.data').get_object_reference( + cr, uid, 'sale_line_description', + 'group_use_product_description_per_so_line' ) - try: - user = self.pool.get('res.users').browse( - cr, uid, uid, context=context) - user_groups = [g.id for g in user.groups_id] - group_id = self.pool.get('ir.model.data').get_object_reference( - cr, uid, 'sale_line_description', - 'group_use_product_description_per_so_line' - )[1] - except: - return False - if group_id in user_groups: - product_obj = self.pool.get('product.product') - product = product_obj.browse( - cr, uid, product_id, context=context) - if ( - product - and product.description - and res['value'] - and res['value'].get('name', False) - ): - res['value']['name'] = product.description + if ref and len(ref) > 1 and ref[1]: + group_id = ref[1] + if group_id in user_groups: + product_obj = self.pool.get('product.product') + product = product_obj.browse( + cr, uid, product_id, context=context) + if ( + product + and product.description + and res['value'] + and res['value'].get('name', False) + ): + res['value']['name'] = product.description return res From a41e92ed971eac6fb525a4a7ceddf183544d0f28 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Mon, 14 Oct 2013 17:39:27 +0200 Subject: [PATCH 6/7] [FIX] way to check key existence in dictionary --- sale_line_description/sale.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sale_line_description/sale.py b/sale_line_description/sale.py index fb1863e7d51..43a12b004d3 100644 --- a/sale_line_description/sale.py +++ b/sale_line_description/sale.py @@ -55,8 +55,7 @@ def product_id_change( if ( product and product.description - and res['value'] - and res['value'].get('name', False) + and 'value' in res ): res['value']['name'] = product.description return res From 427cd5430c9bbb208e00908434646c12934e01fb Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Mon, 14 Oct 2013 18:09:07 +0200 Subject: [PATCH 7/7] [ADD] sale_line_description: added the pot file --- .../i18n/sale_line_description.pot | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sale_line_description/i18n/sale_line_description.pot diff --git a/sale_line_description/i18n/sale_line_description.pot b/sale_line_description/i18n/sale_line_description.pot new file mode 100644 index 00000000000..b8d0f22c5e5 --- /dev/null +++ b/sale_line_description/i18n/sale_line_description.pot @@ -0,0 +1,44 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_line_description +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-10-14 15:56+0000\n" +"PO-Revision-Date: 2013-10-14 15:56+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_line_description +#: model:ir.model,name:sale_line_description.model_sale_config_settings +msgid "sale.config.settings" +msgstr "" + +#. module: sale_line_description +#: model:res.groups,name:sale_line_description.group_use_product_description_per_so_line +msgid "Use only product sale description on order lines" +msgstr "" + +#. module: sale_line_description +#: field:sale.config.settings,group_use_product_description_per_so_line:0 +msgid "Allow using only the product sale description\n" +" on the sales order lines" +msgstr "" + +#. module: sale_line_description +#: model:ir.model,name:sale_line_description.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_line_description +#: help:sale.config.settings,group_use_product_description_per_so_line:0 +msgid "Allows you to use only product sale description on the\n" +" sales order line." +msgstr "" +