Skip to content

Commit

Permalink
Merge 2f37af0 into 3639077
Browse files Browse the repository at this point in the history
  • Loading branch information
tafaRU committed Jun 11, 2015
2 parents 3639077 + 2f37af0 commit b709444
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 0 deletions.
74 changes: 74 additions & 0 deletions sale_line_quantity_properties_based/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Sale line quantity properties based
===================================

*This module allows the calculation of the product quantity on the basis of a
formula that considers the properties specified by the user on the sale order
line and on the quantity (UoS).*

Example
--------

Provided the sale of a given number of pieces (shelves), that may be
’x’ meter long and ’y’ meter large, the formula enables the calculation of the
total area sold expressed in square meters:
10 [pcs of] (4 m x 0.5 m) shelves = 20 m² of wood

In order to have this function working, it is necessary to have the user
proceeding as follows:

Then s/he shall create properties such as ‘length 4’, ‘width 0.5’.
(Note: this can be more easily achieved by using the modules
'sale_properties_easy_creation' and/or 'sale_properties_dynamic_fields')

Properties must respond the following criteria:
* Name: ‘length 1’, ‘length 4’, ‘width 0.5’
* Property Group : either ‘length’ or ‘width’
* Value : the corresponding quantity (1, 4, 0.5...)

Property 'length 4'
* Name: ‘length 4’
* Property Group : ‘length’
* Value : 4

Property 'width 0.5'
* Name: ‘width 0.5’
* Property Group : ‘width’
* Value : 0.5

After this, the formula 'surface' must be created and associated
to the product:

```
result = float(properties['length']) * float(properties['width']) * qty_uos
```

Upon the registering of the order, the user will apply in the properties field
the desired properties (in this example the ‘lenght 4’ and ‘width 2’), the
needed formula (in this example 'surface') and last the quantity (UoS).

Credits
=======

Contributors
------------

* Alex Comba <alex.comba@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://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 http://odoo-community.org.
22 changes: 22 additions & 0 deletions sale_line_quantity_properties_based/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014-15 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 . import sale_order_line
from . import product
40 changes: 40 additions & 0 deletions sale_line_quantity_properties_based/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014-15 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/>.
#
##############################################################################
{
'name': "Sale line quantity properties based",
'version': '1.0',
'category': 'Sales Management',
'author': "Agile Business Group,Odoo Community Association (OCA)",
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': [
'sale_properties_easy_creation',
'web_context_tunnel',
],
'data': [
'sale_order_view.xml',
'product_view.xml',
],
'test': [
'test/sale_line_quantity_properties_based.yml',
],
'installable': True
}
61 changes: 61 additions & 0 deletions sale_line_quantity_properties_based/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_line_quantity_properties_based
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-19 09:43+0000\n"
"PO-Revision-Date: 2014-08-19 09:43+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_quantity_properties_based
#: code:_description:0
#: model:ir.model,name:sale_line_quantity_properties_based.model_product_product
#, python-format
msgid "Product"
msgstr "Prodotto"

#. module: sale_line_quantity_properties_based
#: field:product.product,quantity_formula_id:0
msgid "Quantity formula"
msgstr "Formula quantità"

#. module: sale_line_quantity_properties_based
#: code:_description:0
#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
#, python-format
msgid "Sales Order Line"
msgstr "Linea d'ordine di vendita"

#. module: sale_line_quantity_properties_based
#: help:product.product,quantity_formula_id:0
msgid "You can use the variables\n"
" - self\n"
" - cr\n"
" - uid\n"
" - properties (dictionary of properties)\n"
"You have to put the result in the 'result' variable"
msgstr "E' possibile usare le variabili\n"
" - self\n"
" - cr\n"
" - uid\n"
" - properties (dizionario di proprietà)\n"
"Bisogna mettere il risultato nella variabile 'result'"

#. module: sale_line_quantity_properties_based
#: view:sale.order:0
msgid "product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,False,False,parent.partner_id, False, False, parent.date_order, False, False, False, context)"
msgstr "product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,False,False,parent.partner_id, False, False, parent.date_order, False, False, False, context)"

#. module: sale_line_quantity_properties_based
#: view:sale.order:0
msgid "{'property_ids': property_ids}"
msgstr "{'property_ids': property_ids}"

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_line_quantity_properties_based
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-18 12:43+0000\n"
"PO-Revision-Date: 2014-06-18 12:43+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_quantity_properties_based
#: model:ir.actions.act_window,name:sale_line_quantity_properties_based.mrp_formula_action
#: model:ir.ui.menu,name:sale_line_quantity_properties_based.menu_mrp_formula_group_action
msgid "Formulas"
msgstr ""

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale.py:48
#, python-format
msgid "The property %s has the field description not filled"
msgstr ""

#. module: sale_line_quantity_properties_based
#: field:sale.order.line.quantity.formula,name:0
msgid "Name"
msgstr ""

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale.py:38
#, python-format
msgid "Formula Error!"
msgstr ""

#. module: sale_line_quantity_properties_based
#: model:ir.actions.act_window,help:sale_line_quantity_properties_based.mrp_formula_action
msgid "<p class=\"oe_view_nocontent_create\">\n"
" Click to create a new formula.\n"
" </p><p>\n"
" The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user\n"
" on the sale order line and on the quantity (UoS)\n"
" </p>\n"
" "
msgstr ""

#. module: sale_line_quantity_properties_based
#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line_quantity_formula
msgid "sale.order.line.quantity.formula"
msgstr ""

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale.py:54
#, python-format
msgid "The formula %s cannot work since there are more than one property belong to the same group"
msgstr ""

#. module: sale_line_quantity_properties_based
#: field:sale.order.line,formula_id:0
#: field:sale.order.line.quantity.formula,formula_text:0
msgid "Formula"
msgstr ""

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale.py:83
#, python-format
msgid "%s is not a valid formula. Reason: %s"
msgstr ""

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale.py:67
#, python-format
msgid "%s is not a valid value for the property %s, it must be a number"
msgstr ""

#. module: sale_line_quantity_properties_based
#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

38 changes: 38 additions & 0 deletions sale_line_quantity_properties_based/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014-15 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, fields


class ProductProduct(orm.Model):
_inherit = "product.product"

_columns = {
'quantity_formula_id': fields.many2one(
'mrp.property.formula', 'Quantity formula',
help="You can use the variables\n"
" - self\n"
" - cr\n"
" - uid\n"
" - product_id\n"
" - properties (dictionary of properties)\n"
"You have to put the result in the 'result' variable"),
}
15 changes: 15 additions & 0 deletions sale_line_quantity_properties_based/product_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_normal_form_formula_view" model="ir.ui.view">
<field name="name">product.normal.formula.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"></field>
<field name="arch" type="xml">
<field name="lst_price" position="after">
<field name="quantity_formula_id"></field>
</field>
</field>
</record>
</data>
</openerp>

0 comments on commit b709444

Please sign in to comment.