diff --git a/sale_order_price_recalculation/README.rst b/sale_order_price_recalculation/README.rst index fbb3d685456..598d65315e8 100644 --- a/sale_order_price_recalculation/README.rst +++ b/sale_order_price_recalculation/README.rst @@ -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. @@ -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 ====================== @@ -40,11 +41,10 @@ Known issues / Roadmap Bug Tracker =========== -Bugs are tracked on `GitHub 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 `_. - +Bugs are tracked on `GitHub 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 ======= @@ -56,6 +56,7 @@ Contributors * Pedro M. Baeza * Oihane Crucelaegui * Pierre Verkest +* Vicent Cubells Maintainer ---------- diff --git a/sale_order_price_recalculation/__init__.py b/sale_order_price_recalculation/__init__.py index 4d8ae82d6d7..f61c1b35525 100644 --- a/sale_order_price_recalculation/__init__.py +++ b/sale_order_price_recalculation/__init__.py @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +# Copyright 2014 Carlos Sánchez Cifuentes +# Copyright 2015 Pedro M. Baeza +# Copyright 2015 Oihane Crucelaegui +# Copyright 2016 Vicent Cubells # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import models diff --git a/sale_order_price_recalculation/__openerp__.py b/sale_order_price_recalculation/__openerp__.py index 505286ec9e0..53843ef5c58 100644 --- a/sale_order_price_recalculation/__openerp__.py +++ b/sale_order_price_recalculation/__openerp__.py @@ -1,24 +1,27 @@ # -*- coding: utf-8 -*- -# (c) 2014 Carlos Sánchez Cifuentes -# (c) 2015 Pedro M. Baeza -# (c) 2015 Oihane Crucelaegui +# Copyright 2014 Carlos Sánchez Cifuentes +# Copyright 2015 Pedro M. Baeza +# Copyright 2015 Oihane Crucelaegui +# Copyright 2016 Vicent Cubells # 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, } diff --git a/sale_order_price_recalculation/models/__init__.py b/sale_order_price_recalculation/models/__init__.py index 35c6d2ff3d6..3edaeaed97b 100644 --- a/sale_order_price_recalculation/models/__init__.py +++ b/sale_order_price_recalculation/models/__init__.py @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +# Copyright 2014 Carlos Sánchez Cifuentes +# Copyright 2015 Pedro M. Baeza +# Copyright 2015 Oihane Crucelaegui +# Copyright 2016 Vicent Cubells # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import sale_order diff --git a/sale_order_price_recalculation/models/sale_order.py b/sale_order_price_recalculation/models/sale_order.py index ae07cbd8195..4ad9a079a9e 100644 --- a/sale_order_price_recalculation/models/sale_order.py +++ b/sale_order_price_recalculation/models/sale_order.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -# (c) 2014 Carlos Sánchez Cifuentes -# (c) 2015 Pedro M. Baeza -# (c) 2015 Oihane Crucelaegui +# Copyright 2014 Carlos Sánchez Cifuentes +# Copyright 2015 Pedro M. Baeza +# Copyright 2015 Oihane Crucelaegui +# Copyright 2016 Vicent Cubells # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from openerp import models, api @@ -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 diff --git a/sale_order_price_recalculation/tests/test_sale_order_price_recalculation.py b/sale_order_price_recalculation/tests/test_sale_order_price_recalculation.py index ad620ed0e51..b62eb28bc1f 100644 --- a/sale_order_price_recalculation/tests/test_sale_order_price_recalculation.py +++ b/sale_order_price_recalculation/tests/test_sale_order_price_recalculation.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# (c) 2015 Pedro M. Baeza +# Copyright 2015 Pedro M. Baeza +# Copyright 2016 Vicent Cubells # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html import openerp.tests.common as common @@ -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, } @@ -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") diff --git a/sale_order_price_recalculation/views/sale_order_view.xml b/sale_order_price_recalculation/views/sale_order_view.xml index f906adcd3e9..ea4a01759be 100644 --- a/sale_order_price_recalculation/views/sale_order_view.xml +++ b/sale_order_price_recalculation/views/sale_order_view.xml @@ -1,6 +1,5 @@ - - + sale.order.form @@ -20,5 +19,4 @@ - - +