Skip to content

Commit

Permalink
[MRG] [ADD] module sale_line_description
Browse files Browse the repository at this point in the history
  • Loading branch information
tafaRU authored and jgrandguillaume committed Nov 15, 2013
2 parents 3fb6151 + 427cd54 commit e0e69ef
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sale_line_description/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl
# (<http://www.agilebg.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/>.
#
##############################################################################
import res_config
import sale
45 changes: 45 additions & 0 deletions sale_line_description/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl
# (<http://www.agilebg.com>)
# @author Alex Comba <[email protected]>
#
# 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/>.
#
##############################################################################
{
'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
}
51 changes: 51 additions & 0 deletions sale_line_description/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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-11 10:02+0000\n"
"PO-Revision-Date: 2013-10-11 12:04+0100\n"
"Last-Translator: Lorenzo Battistini <[email protected]>\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
#: 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
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
#: 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 ""
"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"
44 changes: 44 additions & 0 deletions sale_line_description/i18n/sale_line_description.pot
Original file line number Diff line number Diff line change
@@ -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 ""

37 changes: 37 additions & 0 deletions sale_line_description/res_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl
# (<http://www.agilebg.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/>.
#
##############################################################################

from openerp.osv import fields, osv


class sale_configuration(osv.TransientModel):
_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."""
),
}
20 changes: 20 additions & 0 deletions sale_line_description/res_config_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_sales_config" model="ir.ui.view">
<field name="name">sale settings</field>
<field name="model">sale.config.settings</field>
<field name="inherit_id" ref="sale.view_sales_config"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='module_sale_margin']" position="after">
<div>
<field name="group_use_product_description_per_so_line" class="oe_inline"/>
<label for="group_use_product_description_per_so_line"/>
</div>
</xpath>
</field>
</record>

</data>
</openerp>
61 changes: 61 additions & 0 deletions sale_line_description/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl
# (<http://www.agilebg.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/>.
#
##############################################################################

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
)
if product_id:
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'
)
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 'value' in res
):
res['value']['name'] = product.description
return res
13 changes: 13 additions & 0 deletions sale_line_description/security/sale_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>

<data noupdate="0">

<record id="group_use_product_description_per_so_line" model="res.groups">
<field name="name">Use only product sale description on order lines</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>

</data>

</openerp>

0 comments on commit e0e69ef

Please sign in to comment.