Skip to content

Commit

Permalink
Merge 66b6118 into bdd6666
Browse files Browse the repository at this point in the history
  • Loading branch information
cubells committed Dec 16, 2016
2 parents bdd6666 + 66b6118 commit 0fd7ef9
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 68 deletions.
19 changes: 10 additions & 9 deletions sale_order_price_recalculation/README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===================================================
Recalculation of sales order lines prices on demand
===================================================

.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

This module add 2 buttons on sale orders (below sale order lines) that:

* recalculates the prices of the order lines that contain a product in them.
Expand All @@ -28,7 +29,7 @@ loosing custom descriptions.

.. 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
:target: https://runbot.odoo-community.org/runbot/167/9.0

Known issues / Roadmap
======================
Expand All @@ -40,11 +41,10 @@ Known issues / Roadmap
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_order_price_recalculation%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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.

Credits
=======
Expand All @@ -56,6 +56,7 @@ Contributors
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pierre Verkest <pverkest@anybox.fr>
* Vicent Cubells <vicent.cubells@tecnativa.com>

Maintainer
----------
Expand Down
4 changes: 4 additions & 0 deletions sale_order_price_recalculation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2016 Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
25 changes: 14 additions & 11 deletions sale_order_price_recalculation/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# -*- coding: utf-8 -*-
# (c) 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# (c) 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# (c) 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2016 Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Price recalculation in sales orders",
"version": "8.0.1.0.0",
"depends": [
"sale",
],
'license': 'AGPL-3',
"version": "9.0.1.0.0",
"category": "Sales Management",
"website": "http://github.com/OCA/sale-workflow",
"author": "AvanzOSC,"
"Serv. Tecnol. Avanzados - Pedro M. Baeza,"
"Grupo Vermon,"
"Tecnativa,"
"Odoo Community Association (OCA)",
"category": "Sales Management",
"website": "http://github.com/OCA/sale-workflow",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"sale",
],
"data": [
"views/sale_order_view.xml",
],
'installable': False,
}
11 changes: 6 additions & 5 deletions sale_order_price_recalculation/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
# * sale_order_price_recalculation
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-02 17:59+0000\n"
"PO-Revision-Date: 2015-09-28 12:51+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"POT-Creation-Date: 2015-10-23 08:14+0000\n"
"PO-Revision-Date: 2015-10-21 10:21+0000\n"
"Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand All @@ -20,12 +21,12 @@ msgstr ""
#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr ""
msgstr "Recalcular precioss"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Reset descriptions"
msgstr ""
msgstr "Restablecer descripciones"

#. module: sale_order_price_recalculation
#: model:ir.model,name:sale_order_price_recalculation.model_sale_order
Expand Down
34 changes: 34 additions & 0 deletions sale_order_price_recalculation/i18n/es_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_price_recalculation
#
# Translators:
# Javi Melendez <javimelex@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-04 13:41+0000\n"
"PO-Revision-Date: 2016-09-29 08:07+0000\n"
"Last-Translator: Javi Melendez <javimelex@gmail.com>\n"
"Language-Team: Spanish (Spain) (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/es_ES/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es_ES\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr "Recalcular precios"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Reset descriptions"
msgstr "Restablecer descripciones"

#. module: sale_order_price_recalculation
#: model:ir.model,name:sale_order_price_recalculation.model_sale_order
msgid "Sales Order"
msgstr "Pedido de venta"
33 changes: 33 additions & 0 deletions sale_order_price_recalculation/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_price_recalculation
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-22 23:35+0000\n"
"PO-Revision-Date: 2015-09-03 07:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: Croatian (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/hr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: hr\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr ""

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Reset descriptions"
msgstr ""

#. module: sale_order_price_recalculation
#: model:ir.model,name:sale_order_price_recalculation.model_sale_order
msgid "Sales Order"
msgstr "Prodajni nalog"
9 changes: 5 additions & 4 deletions sale_order_price_recalculation/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
# * sale_order_price_recalculation
#
# Translators:
# Paolo Valier, 2016
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-02 17:59+0000\n"
"PO-Revision-Date: 2015-09-28 12:51+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"POT-Creation-Date: 2016-04-29 00:55+0000\n"
"PO-Revision-Date: 2016-04-27 20:00+0000\n"
"Last-Translator: Paolo Valier\n"
"Language-Team: Italian (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand All @@ -20,7 +21,7 @@ msgstr ""
#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr ""
msgstr "Ricalcola prezzi"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
Expand Down
33 changes: 33 additions & 0 deletions sale_order_price_recalculation/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_price_recalculation
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-23 08:14+0000\n"
"PO-Revision-Date: 2015-09-03 07:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: Dutch (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/nl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr ""

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Reset descriptions"
msgstr ""

#. module: sale_order_price_recalculation
#: model:ir.model,name:sale_order_price_recalculation.model_sale_order
msgid "Sales Order"
msgstr "Verkooporder"
33 changes: 33 additions & 0 deletions sale_order_price_recalculation/i18n/tr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_price_recalculation
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: sale-workflow (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-05 23:35+0000\n"
"PO-Revision-Date: 2015-09-03 07:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: Turkish (http://www.transifex.com/oca/OCA-sale-workflow-8-0/language/tr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: tr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Recalculate prices"
msgstr ""

#. module: sale_order_price_recalculation
#: view:sale.order:sale_order_price_recalculation.sorp_view_order_form
msgid "Reset descriptions"
msgstr ""

#. module: sale_order_price_recalculation
#: model:ir.model,name:sale_order_price_recalculation.model_sale_order
msgid "Sales Order"
msgstr "Sipariş Emri"
4 changes: 4 additions & 0 deletions sale_order_price_recalculation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2016 Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import sale_order
37 changes: 11 additions & 26 deletions sale_order_price_recalculation/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# (c) 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# (c) 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# (c) 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2014 Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
# Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2015 Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
# Copyright 2016 Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import models, api
Expand All @@ -12,31 +13,15 @@ class SaleOrder(models.Model):

@api.multi
def recalculate_prices(self):
return self.reset_lines(price=True)
for line in self.mapped('order_line'):
line.product_uom_change()
return True

@api.multi
def recalculate_names(self):
return self.reset_lines(price=False)

@api.multi
def reset_lines(self, price=False):
"""
Reset lines according informations on products and price list
:param price: boolean to indicate if we are resetting price or
descriptions
"""
for line in self.mapped('order_line'):
order = line.order_id
res = line.product_id_change(
order.pricelist_id.id, line.product_id.id,
qty=line.product_uom_qty, uom=line.product_uom.id,
qty_uos=line.product_uos_qty, uos=line.product_uos.id,
name=line.name, partner_id=order.partner_id.id, lang=False,
update_tax=True, date_order=order.date_order, packaging=False,
fiscal_position=order.fiscal_position.id, flag=price)
if price:
line.write(res['value'])
else:
if 'name' in res['value']:
line.write({'name': res['value']['name']})
name = line.product_id.name_get()[0][1]
if line.product_id.description_sale:
name += '\n' + line.product_id.description_sale
line.name = name
return True
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# (c) 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright 2016 Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import openerp.tests.common as common
Expand All @@ -13,19 +14,18 @@ def setUp(self):
self.sale_order_line_model = self.env['sale.order.line']
self.partner = self.env.ref('base.res_partner_3')
self.product = self.env.ref('product.product_product_4')
order_vals = self.sale_order_model.onchange_partner_id(
self.partner.id)['value']
order_vals['partner_id'] = self.partner.id
self.sale_order = self.sale_order_model.create(order_vals)
self.sale_order = self.sale_order_model.create({
'partner_id': self.partner.id,
'partner_invoice_id': self.partner.id,
'partner_shipping_id': self.partner.id,
'pricelist_id': self.env.ref('product.list0').id,
})
self.product.uos_id = self.env.ref('product.product_uom_kgm')
self.product.uos_coeff = 12.0
line_vals = {
'product_id': self.product.id,
'name': self.product.name,
'product_uom_qty': 1.0,
'product_uom': self.product.uom_id.id,
'product_uos_qty': 12.0,
'product_uos': self.product.uos_id.id,
'price_unit': self.product.lst_price,
'order_id': self.sale_order.id,
}
Expand All @@ -45,7 +45,6 @@ def test_price_recalculation(self):
self.sale_order_line.price_unit, self.product.lst_price)
# Check if quantities have changed
self.assertEqual(self.sale_order_line.product_uom_qty, 1.0)
self.assertEqual(self.sale_order_line.product_uos_qty, 12.0)
# Check the description still unchanged
self.assertEqual(self.sale_order_line.name, u"My product description")

Expand Down
Loading

0 comments on commit 0fd7ef9

Please sign in to comment.