Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of sale_line_quantity_properties_based #146

Merged
merged 23 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
489d026
Add code using by 'git checkout origin/7.0 -- sale_line_quantity_prop…
tafaRU May 5, 2015
aabdbb8
Fix field name, changed in V8
tafaRU May 5, 2015
304d5ff
Inherit view from sale_mrp instead of sale_stock
tafaRU May 5, 2015
3f60999
Update copyright year
tafaRU May 5, 2015
7f0e03a
Extract the description in README.rst
tafaRU May 5, 2015
ee9b3b3
Add OCA icon
tafaRU May 5, 2015
d915871
Rem sale_mrp from depends because sale_properties_easy_creation alrea…
tafaRU Jun 11, 2015
ad23bd2
[FIX] using new API for property_ids onchange
eLBati Jun 15, 2015
54590a3
Fix onchange method name and remove brackets from exec
tafaRU Jun 17, 2015
d31003d
Add product_id_change to avoid product_uos_qty recomputation in the s…
tafaRU Jun 25, 2015
d930b1e
Fix wrong interoperability among onchange (v8) and on_change (v7).
tafaRU Jun 30, 2015
42c8921
Delete sale_order_view.xml since is useless now
tafaRU Jun 30, 2015
a543321
Add product_uos_qty as parameter of onchange to recompute quantity
tafaRU Jun 30, 2015
dfba982
Quantity recalculation has to be done when property_ids or product_uo…
tafaRU Jul 1, 2015
59060f7
Calculate quantity by using compute_formula method
tafaRU Nov 16, 2015
3b02591
Improve README and update module version according to last OCA conven…
tafaRU Nov 16, 2015
97e6bc9
Modify .travis to test sale__line_quantity_properties_based separately
tafaRU Nov 25, 2015
ce3b860
Fix typos in README file
tafaRU Feb 12, 2016
b843de3
Improve quantity_property_ids_changed: use .ids instead of comprehens…
tafaRU Feb 12, 2016
02d1ede
Return warning instead of add it to the log, so that the user gets so…
tafaRU Feb 12, 2016
ea38ce4
Update it.po
tafaRU Feb 12, 2016
dcab80a
Add uos_id to localdict
tafaRU Apr 11, 2016
f4ada6e
[FIX] KeyError: 'product_uom_qty'
tafaRU Oct 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ env:
matrix:
- LINT_CHECK="1"
- TRANSIFEX="1"
- TESTS="1" ODOO_REPO="odoo/odoo" EXCLUDE="sale_quotation_sourcing,sale_sourced_by_line,sale_quotation_sourcing_stock_route_transit,sale_sourced_by_line_sale_transport_multi_address,sale_properties_dynamic_fields" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE="sale_quotation_sourcing,sale_sourced_by_line,sale_quotation_sourcing_stock_route_transit,sale_sourced_by_line_sale_transport_multi_address,sale_properties_dynamic_fields" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="odoo/odoo" EXCLUDE="sale_quotation_sourcing,sale_sourced_by_line,sale_quotation_sourcing_stock_route_transit,sale_sourced_by_line_sale_transport_multi_address,sale_properties_dynamic_fields,sale_line_quantity_properties_based" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE="sale_quotation_sourcing,sale_sourced_by_line,sale_quotation_sourcing_stock_route_transit,sale_sourced_by_line_sale_transport_multi_address,sale_properties_dynamic_fields,sale_line_quantity_properties_based" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="sale_sourced_by_line" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE="sale_sourced_by_line" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="sale_quotation_sourcing" LINT_CHECK="0"
Expand All @@ -35,6 +35,8 @@ env:
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE="sale_sourced_by_line_sale_transport_multi_address" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="sale_properties_dynamic_fields" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE="sale_properties_dynamic_fields" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="sale_line_quantity_properties_based" LINT_CHECK="0"
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE="sale_line_quantity_properties_based" LINT_CHECK="0"

virtualenv:
system_site_packages: true
Expand Down
89 changes: 89 additions & 0 deletions sale_line_quantity_properties_based/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. 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
proceed 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 respect 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).

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_line_quantity_properties_based%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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
38 changes: 38 additions & 0 deletions sale_line_quantity_properties_based/__openerp__.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/>.
#
##############################################################################
{
'name': "Sale line quantity properties based",
'version': '8.0.1.0.0',
'category': 'Sales Management',
'author': "Agile Business Group,Odoo Community Association (OCA)",
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
'depends': [
'sale_properties_dynamic_fields',
],
'data': [
'product_view.xml',
],
'test': [
'test/sale_line_quantity_properties_based.yml',
],
'installable': True
}
76 changes: 76 additions & 0 deletions sale_line_quantity_properties_based/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_line_quantity_properties_based
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-12 15:25+0000\n"
"PO-Revision-Date: 2016-02-12 16:31+0100\n"
"Last-Translator: Alex Comba <alex.comba@agilebg.com>\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"
"Language: it\n"
"X-Generator: Poedit 1.8.4\n"

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale_order_line.py:49
#, python-format
msgid "Error"
msgstr "Error"

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale_order_line.py:73
#, python-format
msgid "Evaluation error in formula %s: "
msgstr "Errore durante il computo nella formula %s: "

#. module: sale_line_quantity_properties_based
#: model:ir.model,name:sale_line_quantity_properties_based.model_product_product
msgid "Product"
msgstr "Prodotto"

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale_order_line.py:50
#, python-format
msgid "Property of group %s already present"
msgstr "Gruppo proprietà %s già presente"

#. 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
#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
msgid "Sales Order Line"
msgstr "Linea d'ordine di vendita"

#. module: sale_line_quantity_properties_based
#: code:addons/sale_line_quantity_properties_based/sale_order_line.py:76
#, python-format
msgid "Warning"
msgstr "Warning"

#. 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"
" - product_id\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"
" - product_id\n"
" - properties (dictionary of properties)\n"
"Bisogna mettere il risultato nella variabile 'result'"
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>
Loading