← Back to team overview

openerp-community-reviewer team mailing list archive

Re: [Merge] lp:~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7 into lp:sale-wkfl

 

Review: Approve

Thanks Alex, just 1 diff remark

Diff comments:

> === added directory 'sale_line_quantity_properties_based'
> === added file 'sale_line_quantity_properties_based/__init__.py'
> --- sale_line_quantity_properties_based/__init__.py	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/__init__.py	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,22 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    Author: Alex Comba <alex.comba@xxxxxxxxxxx>
> +#    Copyright (C) 2014 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
> 
> === added file 'sale_line_quantity_properties_based/__openerp__.py'
> --- sale_line_quantity_properties_based/__openerp__.py	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/__openerp__.py	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,100 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    Author: Alex Comba <alex.comba@xxxxxxxxxxx>
> +#    Copyright (C) 2014 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': '0.1',
> +    'category': 'Sales Management',
> +    'description': """
> +Sale line quantity based on line properties
> +===========================================
> +
> +*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:
> +
> +before starting, s/he has to belong to **sale.group_mrp_properties** by
> +selecting the option "Invoice products in a different unit of measure than the
> +sales order" in the following menu: **Settings --> Configration --> Warehouse** 
> +
> +Then s/he shall create properties such as ‘length 4’, ‘width 0.5’. 
> +
> +Properties must respond the following criteria:
> +
> +    * Name: ‘length 1’, ‘length 4’, ‘width 0.5’
> +    * Property Group : either ‘length’ or ‘width’
> +    * Description : the corresponding quantity (1, 4, 0.5...)
> +
> +Property 'length 4' 
> +    * Name: ‘length 4’
> +    * Property Group : ‘length’
> +    * Description : 4
> +
> +Property 'width 0.5' 
> +    * Name: ‘width 0.5’
> +    * Property Group : ‘width’
> +    * Description : 0.5
> +
> +After this, the formula 'surface' must be created:
> +
> +**P['length'] * P['width']**
> +whereas P is a mandatory element and 'length' and 'width' must be provided
> +in square brackets **[ ]**
> +
> +This is possible by using the menu:
> +**Manufacturing --> Configuration--> Formulas**
> +
> +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).
> +
> +Contributors
> +------------
> +* Alex Comba <alex.comba@xxxxxxxxxxx>
> +* Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx> 
> +""",
> +    'author': 'Agile Business Group',
> +    'website': 'http://www.agilebg.com',
> +    'license': 'AGPL-3',
> +    'depends': [
> +        'sale_mrp',
> +    ],
> +    'data': [
> +        'sale_view.xml',
> +        'mrp_view.xml',
> +        'security/ir.model.access.csv',
> +    ],
> +    'test': [
> +        'test/sale_line_quantity_properties_based.yml',
> +    ],
> +    'installable': True
> +}
> 
> === added directory 'sale_line_quantity_properties_based/i18n'
> === added file 'sale_line_quantity_properties_based/i18n/it.po'
> --- sale_line_quantity_properties_based/i18n/it.po	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/i18n/it.po	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,100 @@
> +# 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:36+0000\n"
> +"PO-Revision-Date: 2014-06-18 14:40+0100\n"
> +"Last-Translator: Alex Comba <alex.comba@xxxxxxxxxxx>\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_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 "Formule"
> +
> +#. 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 "La proprietà %s ha il campo descrizione non compilato"
> +
> +#. module: sale_line_quantity_properties_based
> +#: field:sale.order.line.quantity.formula,name:0
> +msgid "Name"
> +msgstr "Nome"
> +
> +#. module: sale_line_quantity_properties_based
> +#: code:addons/sale_line_quantity_properties_based/sale.py:38
> +#, python-format
> +msgid "Formula Error!"
> +msgstr "Errore Formula!"
> +
> +#. 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 ""
> +"<p class=\"oe_view_nocontent_create\">\n"
> +"                Clicca per creare una nuova formula.\n"
> +"              </p><p>\n"
> +"                Le formule vengono usate per calcolare in modo automatico la "
> +"quantità del prodotto in base alle proprietà specificate dall'utente\n"
> +"                sulla riga dell'ordine di vendita e in base alla quantità "
> +"(Unità di Vendita)\n"
> +"              </p>\n"
> +"            "
> +
> +#. 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 "sale.order.line.quantity.formula"
> +
> +#. 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 ""
> +"La formula %s non può funzionare perchè sono presenti più di una proprietà "
> +"apparteneti allo stesso gruppo"
> +
> +#. 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 "Formula"
> +
> +#. 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 "%s non è valida. Motivo: %s"
> +
> +#. 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 "%s non è un valore valido per la proprietà %s, deve essere un numero"
> +
> +#. module: sale_line_quantity_properties_based
> +#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
> +msgid "Sales Order Line"
> +msgstr "Linea d'ordine di vendita"
> 
> === added file 'sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot'
> --- sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot	2014-06-18 12:43:45 +0000
> @@ -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 ""
> +
> 
> === added file 'sale_line_quantity_properties_based/mrp_view.xml'
> --- sale_line_quantity_properties_based/mrp_view.xml	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/mrp_view.xml	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,29 @@
> +<?xml version="1.0" encoding="utf-8"?>
> +<openerp>
> +    <data>
> +
> +        <record id="mrp_formula_action" model="ir.actions.act_window">
> +            <field name="name">Formulas</field>
> +            <field name="type">ir.actions.act_window</field>
> +            <field name="res_model">sale.order.line.quantity.formula</field>
> +            <field name="view_type">form</field>
> +            <field name="view_mode">tree,form</field>
> +            <field name="help" type="html">
> +              <p class="oe_view_nocontent_create">
> +                Click to create a new formula.
> +              </p><p>
> +                The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user
> +                on the sale order line and on the quantity (UoS)
> +              </p>
> +            </field>
> +        </record>
> +        
> +        <menuitem
> +            action="mrp_formula_action"
> +            parent="mrp.menu_mrp_configuration"
> +            groups="base.group_no_one,product.group_mrp_properties"
> +            id="menu_mrp_formula_group_action"
> +            sequence="40"/>
> +
> +    </data>
> +</openerp>
> 
> === added file 'sale_line_quantity_properties_based/sale.py'
> --- sale_line_quantity_properties_based/sale.py	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/sale.py	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,121 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    Author: Alex Comba <alex.comba@xxxxxxxxxxx>
> +#    Copyright (C) 2014 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
> +from openerp.tools.translate import _
> +import traceback
> +
> +
> +class sale_order_line(orm.Model):
> +    _inherit = 'sale.order.line'
> +
> +    def onchange_formula(
> +            self, cr, uid, ids,
> +            formula_id, property_ids, product_uos_qty, context=None
> +    ):
> +        res = {}
> +        properties = {}
> +        warning_msg = ''
> +        warning = {'title': _('Formula Error!')}
> +        if formula_id and property_ids:
> +            formula = self.pool.get('sale.order.line.quantity.formula').browse(
> +                cr, uid, formula_id, context=context)
> +            formula_text = formula.formula_text
> +            mrp_property_obj = self.pool.get('mrp.property')
> +            for mrp_property_id in property_ids[0][2]:
> +                mrp_property = mrp_property_obj.browse(
> +                    cr, uid, mrp_property_id, context=context)
> +                if not mrp_property.description:
> +                    warning_msg = _(
> +                        u"The property %s has the field description "
> +                        u"not filled" % mrp_property.name
> +                    )
> +                    break
> +                if mrp_property.group_id.name in properties:
> +                    warning_msg = _(
> +                        u"The formula %s cannot work since "
> +                        u"there are more than one property belong "
> +                        u"to the same group" % formula_text
> +                    )
> +                    break
> +                try:
> +                    properties[mrp_property.group_id.name] = float(
> +                        mrp_property.description)
> +                except ValueError:
> +                    warning_msg = _(
> +                        u"%s is not a valid value for the "
> +                        u"property %s, it must be a number"
> +                        % (
> +                            mrp_property.description,
> +                            mrp_property.group_id.name
> +                        )
> +                    )
> +                    break
> +            if warning_msg:
> +                warning.update({'message': warning_msg})
> +                return {'warning': warning}
> +            try:
> +                res['product_uom_qty'] = eval(formula_text.replace(
> +                    'P', 'properties')) * product_uos_qty
> +            except Exception:
> +                formatted_lines = traceback.format_exc().splitlines()
> +                warning_msg = _(
> +                    u"%s is not a valid formula. Reason: %s"
> +                    % (
> +                        formula_text,
> +                        formatted_lines[-1]
> +                    )
> +                )
> +                warning.update({'message': warning_msg})
> +                return {'warning': warning}
> +        return {'value': res}
> +
> +    _columns = {
> +        'formula_id': fields.many2one(
> +            'sale.order.line.quantity.formula', 'Formula',),
> +    }
> +
> +    def product_id_change(

Could you add a comment about why overriding product_id_change and removing product_uos_qty is needed?

> +            self, cr, uid, ids, pricelist, product, 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, qty=qty,
> +            uom=uom, qty_uos=qty_uos, uos=uos, name=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 'value' in res and 'product_uos_qty' in res['value']:
> +            del res['value']['product_uos_qty']
> +        return res
> +
> +
> +class sale_order_line_quantity_formula(orm.Model):
> +    _name = "sale.order.line.quantity.formula"
> +
> +    _columns = {
> +        'name': fields.char('Name', size=32),
> +        'formula_text': fields.text('Formula'),
> +    }
> 
> === added file 'sale_line_quantity_properties_based/sale_view.xml'
> --- sale_line_quantity_properties_based/sale_view.xml	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/sale_view.xml	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,43 @@
> +<?xml version="1.0" encoding="utf-8"?>
> +<openerp>
> +    <data>
> +
> +        <record id="view_order_form_inherit" model="ir.ui.view">
> +            <field name="name">sale.order.form.sale.stock</field>
> +            <field name="model">sale.order</field>
> +            <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
> +            <field name="arch" type="xml">
> +                <xpath expr="//field[@name='property_ids']" position="replace"/>
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
> +                    <field name="property_ids" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" widget="many2many_tags"/>                    
> +                </xpath>
> +            </field>
> +        </record>
> +
> +        <record id="view_order_form" model="ir.ui.view">
> +            <field name="name">sale.order.form</field>
> +            <field name="model">sale.order</field>
> +            <field name="inherit_id" ref="sale.view_order_form"/>
> +            <field name="arch" type="xml">
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/label[@for='product_uos_qty']" position="replace">
> +                </xpath>
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/div[@groups='product.group_uos']" position="replace">
> +                </xpath>
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='price_unit']" position="replace">
> +                </xpath>
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
> +                    <field name="formula_id" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)"/>
> +                    <label for="product_uos_qty"/>
> +                    <div>
> +                        <field name="product_uos_qty" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" class="oe_inline"/>
> +                        <field name="product_uos" class="oe_inline"/>
> +                    </div>
> +                </xpath>
> +                <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='address_allotment_id']" position="after">
> +                    <field name="price_unit"/>
> +                </xpath>
> +            </field>
> +        </record>
> +
> +    </data>
> +</openerp>
> 
> === added directory 'sale_line_quantity_properties_based/security'
> === added file 'sale_line_quantity_properties_based/security/ir.model.access.csv'
> --- sale_line_quantity_properties_based/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/security/ir.model.access.csv	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,3 @@
> +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
> +access_sale_order_line_quantity_formula_user,sale.order.line.quantity.formula.user,model_sale_order_line_quantity_formula,base.group_sale_salesman,1,0,0,0
> +access_sale_order_line_quantity_formula_manager,sale.order.line.quantity.formula salemanager,model_sale_order_line_quantity_formula,base.group_sale_manager,1,1,1,1
> 
> === added directory 'sale_line_quantity_properties_based/test'
> === added file 'sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml'
> --- sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml	1970-01-01 00:00:00 +0000
> +++ sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml	2014-06-18 12:43:45 +0000
> @@ -0,0 +1,68 @@
> +-
> +    In order to test the sale_line_quantity_properties_based,
> +    I start by creating a new unit of measure category 'Surface'
> +-
> +    !record {model: product.uom.categ, id:  product_uom_categ_area}:
> +        name: Surface
> +-
> +    I create the unit of measure square meter
> +-
> +    !record {model: product.uom, id:  product_uom_m2}:
> +        name: m²
> +        category_id: product_uom_categ_area
> +-
> +    I create a product 'shelf'
> +-
> +    !record {model: product.product, id:  product_product_shelf}:
> +        categ_id: product.product_category_all
> +        name: shelf
> +        type: product
> +        uom_id: product_uom_m2
> +        list_price: 1.0
> +-
> +    I create a property group 'length'
> +-
> +    !record {model: mrp.property.group, id:  mrp_property_group_length}:
> +        name: length
> +-
> +    I create a property group 'width'
> +-
> +    !record {model: mrp.property.group, id:  mrp_property_group_width}:
> +        name: width
> +-
> +    I create a property 'length 4'
> +-
> +    !record {model: mrp.property, id:  mrp_property_length_4}:
> +        name: length 4
> +        group_id: mrp_property_group_length
> +        description: 4
> +-
> +    I create a property 'width 0.5'
> +-
> +    !record {model: mrp.property, id:  mrp_property_length_width_05}:
> +        name: width 0.5
> +        group_id: mrp_property_group_width
> +        description: 0.5
> +-
> +    I create the formula surface
> +-
> +    !record {model: sale.order.line.quantity.formula, id:  sale_order_line_quantity_formula_surface}:
> +        name: surface
> +        formula_text: P['width'] * P['length']
> +-
> +    Now i create a sale order with an order line that uses properties and formula previously created
> +-
> +    !record {model: sale.order, id: sale_order_formula}:
> +        partner_id: base.res_partner_1
> +        order_line:
> +          - product_id: product_product_shelf
> +            property_ids: 
> +                - mrp_property_length_4
> +                - mrp_property_length_width_05
> +            formula_id: sale_order_line_quantity_formula_surface
> +            product_uos_qty: 6
> +-
> +  I verify that the quantity product has been correctly calculated using the formula
> +-
> +    !assert {model: sale.order, id: sale_order_formula, string: The formula was not correctly calculated}:
> +        - order_line[0].product_uom_qty == 4 * 0.5 * 6
> 


-- 
https://code.launchpad.net/~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7/+merge/223538
Your team Sale Core Editors is requested to review the proposed merge of lp:~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7 into lp:sale-wkfl.


References