Skip to content

Commit

Permalink
[ADD] sale_order_recalculate_prices: Module to allow to recalculate o…
Browse files Browse the repository at this point in the history
…n demand sale order line prices
  • Loading branch information
pedrobaeza committed Oct 31, 2014
1 parent 49a9181 commit 3a5e5e8
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sale_order_recalculate_prices/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Recalculation of sale order lines prices on demand
==================================================

This module adds a button on sale orders below pricelist that recalculates the
prices of the order lines that contain a product in them.

It is launched manually as a button to get the user decide if he/she wants to
recalculate prices when pricelist is changed.
23 changes: 23 additions & 0 deletions sale_order_recalculate_prices/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
# #
# OpenERP, Open Source Management Solution. #
# #
# @author Carlos Sánchez Cifuentes <csanchez@grupovermon.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 models
43 changes: 43 additions & 0 deletions sale_order_recalculate_prices/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- encoding: utf-8 -*-
##############################################################################
# #
# OpenERP, Open Source Management Solution. #
# #
# @author Carlos Sánchez Cifuentes <csanchez@grupovermon.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 Order Recalculate Prices",
"version": "1.0",
"depends": [
"sale",
],
"author": "OdooMRP team",
"contributors": [
"Carlos Sánchez Cifuentes <csanchez@grupovermon.com>",
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <ajuaristio@gmail.com>",
],
"category": "Sales Management",
"website": "http://www.odoomrp.com",
"summary": "",
"data": [
"views/sale_order_view.xml",
],
"installable": True,
}
29 changes: 29 additions & 0 deletions sale_order_recalculate_prices/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_order_recalculate_prices
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-05 13:14+0000\n"
"PO-Revision-Date: 2014-08-05 13:14+0000\n"
"Last-Translator: Carlos Sánchez Cifuentes <csanchez@grupovermon.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"

#. module: sale_order_recalculate_prices
#: view:sale.order:0
msgid "(Recalculate prices)"
msgstr "(Recalcular precios)"

#. module: sale_order_recalculate_prices
#: code:_description:0
#: model:ir.model,name:sale_order_recalculate_prices.model_sale_order
#, python-format
msgid "Sales Order"
msgstr "Pedido de venta"

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * sale_order_recalculate_prices
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-05 13:14+0000\n"
"PO-Revision-Date: 2014-08-05 13:14+0000\n"
"Last-Translator: Carlos Sánchez Cifuentes <csanchez@grupovermon.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"

#. module: sale_order_recalculate_prices
#: view:sale.order:0
msgid "(Recalculate prices)"
msgstr ""

#. module: sale_order_recalculate_prices
#: code:_description:0
#: model:ir.model,name:sale_order_recalculate_prices.model_sale_order
#, python-format
msgid "Sales Order"
msgstr ""

23 changes: 23 additions & 0 deletions sale_order_recalculate_prices/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
# #
# OpenERP, Open Source Management Solution. #
# #
# @author Carlos Sánchez Cifuentes <csanchez@grupovermon.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
42 changes: 42 additions & 0 deletions sale_order_recalculate_prices/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- encoding: utf-8 -*-
##############################################################################
# #
# OpenERP, Open Source Management Solution. #
# #
# @author Carlos Sánchez Cifuentes <csanchez@grupovermon.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 import models, api


class SaleOrder(models.Model):
_inherit = 'sale.order'

@api.multi
def recalculate_prices(self):
for record in self:
if record.order_line:
for line in record.order_line:
res = line.product_id_change(
record.pricelist_id.id, line.product_id.id,
line.product_uom_qty, False, line.product_uos_qty,
False, line.name, record.partner_id.id, False,
True, record.date_order, False,
record.fiscal_position.id, False,
context=self.env.context)
line.write(res['value'])
return True
17 changes: 17 additions & 0 deletions sale_order_recalculate_prices/views/sale_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="sorp_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">
<field name="pricelist_id" position="after">
<button name="recalculate_prices" string="(Recalculate prices)" type="object" colspan="4" class="oe_link"/>
</field>
</field>
</record>

</data>
</openerp>

0 comments on commit 3a5e5e8

Please sign in to comment.