Pedro Manuel Baeza has proposed merging lp:~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price into lp:openerp-product-attributes.
Requested reviews: Product Core Editors (product-core-editors) For more details, see: https://code.launchpad.net/~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price/+merge/205045 This is the module product_pricelist_fixed_price, rewritten from scratch, with another different approach than the current one. Derived from the discussion on this MP: https://code.launchpad.net/~therp-nl/openerp-product-attributes/7.0_lp1272282_fixed_price/+merge/203348 This only has one drawback: if you install it when you have some pricelists created, when you go to the pricelist form, based on field will be empty for these pricelists (although the behaviour won't break). -- https://code.launchpad.net/~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price/+merge/205045 Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== removed file 'product_pricelist_fixed_price/AUTHORS.txt' --- product_pricelist_fixed_price/AUTHORS.txt 2011-04-01 10:14:05 +0000 +++ product_pricelist_fixed_price/AUTHORS.txt 1970-01-01 00:00:00 +0000 @@ -1,1 +0,0 @@ -Lorenzo Battistini <[email protected]> === modified file 'product_pricelist_fixed_price/__init__.py' --- product_pricelist_fixed_price/__init__.py 2011-04-01 10:14:05 +0000 +++ product_pricelist_fixed_price/__init__.py 2014-02-05 20:45:47 +0000 @@ -1,13 +1,10 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.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. +# 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 @@ -18,5 +15,4 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## - -import pricelist +from . import model === modified file 'product_pricelist_fixed_price/__openerp__.py' --- product_pricelist_fixed_price/__openerp__.py 2013-01-21 06:49:06 +0000 +++ product_pricelist_fixed_price/__openerp__.py 2014-02-05 20:45:47 +0000 @@ -1,13 +1,14 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>). +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza <[email protected]> # # 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. +# 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 @@ -19,20 +20,26 @@ # ############################################################################## - { - "name": "Price List Fixed Price", - "version": "1.0", - 'category': 'Generic Modules/Inventory Control', - "depends": ["product"], - "author": "Agile Business Group & Domsense", - "description": """This module allows to specify a fixed price for price list rules. So, if the rule is based on 'fixed price', this price will be used without any computation""", - 'website': 'http://www.agilebg.com', - 'init_xml': [], - 'update_xml': [ - 'pricelist_view.xml', - ], - 'demo_xml': [], - 'installable': False, - 'active': False, + "name" : "Fixed price in pricelists", + "version" : "1.0", + "author" : "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "category" : "Sales Management", + "description" : """ +Fixed price on pricelist rule +============================= + +Adds a new option on pricelist rules to set a fixed price. + """, + "website" : "www.serviciosbaeza.com", + "license" : "AGPL-3", + "depends" : [ + "product", + ], + "demo" : [], + "data" : [ + 'view/product_pricelist_item_view.xml', + ], + "installable" : True, + "active" : False, } === removed file 'product_pricelist_fixed_price/i18n/ca.po' --- product_pricelist_fixed_price/i18n/ca.po 2012-12-05 05:42:11 +0000 +++ product_pricelist_fixed_price/i18n/ca.po 1970-01-01 00:00:00 +0000 @@ -1,65 +0,0 @@ -# Catalan translation for openobject-addons -# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 -# This file is distributed under the same license as the openobject-addons package. -# FIRST AUTHOR <EMAIL@ADDRESS>, 2012. -# -msgid "" -msgstr "" -"Project-Id-Version: openobject-addons\n" -"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" -"POT-Creation-Date: 2011-03-25 10:08+0000\n" -"PO-Revision-Date: 2012-04-18 23:39+0000\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: Catalan <[email protected]>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n" -"X-Generator: Launchpad (build 16335)\n" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Max. Margin" -msgstr "Marge màxim" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Min. Margin" -msgstr "Marge mínim" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Rounding Method" -msgstr "Mètode arrodoniment" - -#. module: product_pricelist_fixed_price -#: constraint:product.pricelist.item:0 -msgid "" -"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList " -"Item!" -msgstr "" -"Error! No podeu assignar la tarifa principal com una altre tarifa en un " -"element de la tarifa." - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist -msgid "Pricelist" -msgstr "Tarifa" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:97 -#, python-format -msgid "Warning !" -msgstr "Atenció!" - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item -msgid "Pricelist item" -msgstr "Element de la tarifa" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:32 -#: field:product.pricelist.item,fixed_price:0 -#, python-format -msgid "Fixed Price" -msgstr "Preu fix" === removed file 'product_pricelist_fixed_price/i18n/de.po' --- product_pricelist_fixed_price/i18n/de.po 2012-12-05 05:42:11 +0000 +++ product_pricelist_fixed_price/i18n/de.po 1970-01-01 00:00:00 +0000 @@ -1,65 +0,0 @@ -# German translation for openobject-addons -# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011 -# This file is distributed under the same license as the openobject-addons package. -# FIRST AUTHOR <EMAIL@ADDRESS>, 2011. -# -msgid "" -msgstr "" -"Project-Id-Version: openobject-addons\n" -"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" -"POT-Creation-Date: 2011-03-25 10:08+0000\n" -"PO-Revision-Date: 2011-05-02 07:47+0000\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: German <[email protected]>\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n" -"X-Generator: Launchpad (build 16335)\n" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Max. Margin" -msgstr "Max. Spanne" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Min. Margin" -msgstr "Min. Spanne" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Rounding Method" -msgstr "Rundungsverfahren" - -#. module: product_pricelist_fixed_price -#: constraint:product.pricelist.item:0 -msgid "" -"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList " -"Item!" -msgstr "" -"Fehler! Sie können die Basispreisliste nicht als alternative Preisliste in " -"einem Preislisteneintrag zuweisen." - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist -msgid "Pricelist" -msgstr "Preisliste" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:97 -#, python-format -msgid "Warning !" -msgstr "Warnung!" - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item -msgid "Pricelist item" -msgstr "Preisliste Einzelposition" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:32 -#: field:product.pricelist.item,fixed_price:0 -#, python-format -msgid "Fixed Price" -msgstr "Festpreis" === modified file 'product_pricelist_fixed_price/i18n/es.po' --- product_pricelist_fixed_price/i18n/es.po 2012-12-05 05:42:11 +0000 +++ product_pricelist_fixed_price/i18n/es.po 2014-02-05 20:45:47 +0000 @@ -1,65 +1,48 @@ -# Spanish translation for openobject-addons -# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011 -# This file is distributed under the same license as the openobject-addons package. -# FIRST AUTHOR <EMAIL@ADDRESS>, 2011. +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * product_pricelist_fixed_price # msgid "" msgstr "" -"Project-Id-Version: openobject-addons\n" -"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" -"POT-Creation-Date: 2011-03-25 10:08+0000\n" -"PO-Revision-Date: 2011-08-26 23:18+0000\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: Spanish <[email protected]>\n" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-05 20:35+0000\n" +"PO-Revision-Date: 2014-02-05 21:36+0100\n" +"Last-Translator: Pedro Manuel Baeza <[email protected]>\n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n" -"X-Generator: Launchpad (build 16335)\n" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Max. Margin" -msgstr "Margen máximo" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Min. Margin" -msgstr "Margen mínimo" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Rounding Method" -msgstr "Método redondeo" - -#. module: product_pricelist_fixed_price -#: constraint:product.pricelist.item:0 -msgid "" -"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList " -"Item!" -msgstr "" -"¡Error! No puede asignar la tarifa principal como otra tarifa en un " -"elemento de la tarifa." - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist -msgid "Pricelist" -msgstr "Lista de Precios" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:97 -#, python-format -msgid "Warning !" -msgstr "¡Atención!" +"Plural-Forms: \n" + +#. module: product_pricelist_fixed_price +#: view:product.pricelist.item:0 +msgid "Base Price" +msgstr "Precio base" + +#. module: product_pricelist_fixed_price +#: help:product.pricelist.item,base_ext:0 +msgid "Base price for computation." +msgstr "Precio base para el cálculo." + +#. module: product_pricelist_fixed_price +#: field:product.pricelist.item,base_ext:0 +msgid "Based on" +msgstr "Basado en" #. module: product_pricelist_fixed_price #: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item msgid "Pricelist item" -msgstr "Elemento de la tarifa" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:32 -#: field:product.pricelist.item,fixed_price:0 +msgstr "Elemento de tarifa" + +#. module: product_pricelist_fixed_price +#: view:product.pricelist.item:0 +msgid "Price Computation" +msgstr "Cálculo del precio" + +#. module: product_pricelist_fixed_price +#: code:addons/product_pricelist_fixed_price/model/product_pricelist_item.py:32 #, python-format msgid "Fixed Price" msgstr "Precio fijo" + === removed file 'product_pricelist_fixed_price/i18n/it.po' --- product_pricelist_fixed_price/i18n/it.po 2012-12-05 05:42:11 +0000 +++ product_pricelist_fixed_price/i18n/it.po 1970-01-01 00:00:00 +0000 @@ -1,64 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * product_pricelist_fixed_price -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 6.0.1\n" -"Report-Msgid-Bugs-To: [email protected]\n" -"POT-Creation-Date: 2011-03-25 10:08+0000\n" -"PO-Revision-Date: 2011-03-31 12:02+0000\n" -"Last-Translator: Lorenzo Battistini <[email protected]>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n" -"X-Generator: Launchpad (build 16335)\n" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Max. Margin" -msgstr "Margine Massimo" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Min. Margin" -msgstr "Margine Minimo" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Rounding Method" -msgstr "Metodo Arrotondamento" - -#. module: product_pricelist_fixed_price -#: constraint:product.pricelist.item:0 -msgid "" -"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList " -"Item!" -msgstr "" -"Errore ! Non è possibile assegnare il listino principale come 'altro " -"listino' nell'elemento di listino!" - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist -msgid "Pricelist" -msgstr "Listino Prezzi" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:97 -#, python-format -msgid "Warning !" -msgstr "attenzione !" - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item -msgid "Pricelist item" -msgstr "Oggetto Listino" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:32 -#: field:product.pricelist.item,fixed_price:0 -#, python-format -msgid "Fixed Price" -msgstr "Prezzo fisso" === modified file 'product_pricelist_fixed_price/i18n/product_pricelist_fixed_price.pot' --- product_pricelist_fixed_price/i18n/product_pricelist_fixed_price.pot 2011-04-01 10:14:05 +0000 +++ product_pricelist_fixed_price/i18n/product_pricelist_fixed_price.pot 2014-02-05 20:45:47 +0000 @@ -4,46 +4,30 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 6.0.1\n" -"Report-Msgid-Bugs-To: [email protected]\n" -"POT-Creation-Date: 2011-03-25 10:08+0000\n" -"PO-Revision-Date: 2011-03-25 10:08+0000\n" -"Last-Translator: <>\n" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-05 20:35+0000\n" +"PO-Revision-Date: 2014-02-05 21:35+0100\n" +"Last-Translator: Pedro Manuel Baeza <[email protected]>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" #. module: product_pricelist_fixed_price #: view:product.pricelist.item:0 -msgid "Max. Margin" -msgstr "" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Min. Margin" -msgstr "" - -#. module: product_pricelist_fixed_price -#: view:product.pricelist.item:0 -msgid "Rounding Method" -msgstr "" - -#. module: product_pricelist_fixed_price -#: constraint:product.pricelist.item:0 -msgid "Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!" -msgstr "" - -#. module: product_pricelist_fixed_price -#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist -msgid "Pricelist" -msgstr "" - -#. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:97 -#, python-format -msgid "Warning !" +msgid "Base Price" +msgstr "" + +#. module: product_pricelist_fixed_price +#: help:product.pricelist.item,base_ext:0 +msgid "Base price for computation." +msgstr "" + +#. module: product_pricelist_fixed_price +#: field:product.pricelist.item,base_ext:0 +msgid "Based on" msgstr "" #. module: product_pricelist_fixed_price @@ -52,8 +36,12 @@ msgstr "" #. module: product_pricelist_fixed_price -#: code:addons/product_pricelist_fixed_price/pricelist.py:32 -#: field:product.pricelist.item,fixed_price:0 +#: view:product.pricelist.item:0 +msgid "Price Computation" +msgstr "" + +#. module: product_pricelist_fixed_price +#: code:addons/product_pricelist_fixed_price/model/product_pricelist_item.py:32 #, python-format msgid "Fixed Price" msgstr "" === removed file 'product_pricelist_fixed_price/pricelist.py' --- product_pricelist_fixed_price/pricelist.py 2011-04-01 10:14:05 +0000 +++ product_pricelist_fixed_price/pricelist.py 1970-01-01 00:00:00 +0000 @@ -1,211 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.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 osv import fields,osv -from tools.translate import _ -import decimal_precision as dp -import time -from product._common import rounding - -class product_pricelist_item(osv.osv): - - def _price_field_get(self, cr, uid, context=None): - result = super(product_pricelist_item, self)._price_field_get(cr, uid, context) - result.append((-3, _('Fixed Price'))) - return result - - _inherit = "product.pricelist.item" - - _columns = { - 'fixed_price': fields.float('Fixed Price', - digits_compute= dp.get_precision('Sale Price')), - 'base': fields.selection(_price_field_get, 'Based on', required=True, size=-1, help="The mode for computing the price for this rule."), - } - -product_pricelist_item() - -class product_pricelist(osv.osv): - _inherit = "product.pricelist" - - def price_get_multi(self, cr, uid, pricelist_ids, products_by_qty_by_partner, context=None): - - def _create_parent_category_list(id, lst): - if not id: - return [] - parent = product_category_tree.get(id) - if parent: - lst.append(parent) - return _create_parent_category_list(parent, lst) - else: - return lst - # _create_parent_category_list - - if context is None: - context = {} - - date = time.strftime('%Y-%m-%d') - if 'date' in context: - date = context['date'] - - currency_obj = self.pool.get('res.currency') - product_obj = self.pool.get('product.product') - product_category_obj = self.pool.get('product.category') - product_uom_obj = self.pool.get('product.uom') - supplierinfo_obj = self.pool.get('product.supplierinfo') - price_type_obj = self.pool.get('product.price.type') - product_pricelist_version_obj = self.pool.get('product.pricelist.version') - - # product.pricelist.version: - if pricelist_ids: - pricelist_version_ids = pricelist_ids - else: - # all pricelists: - pricelist_version_ids = self.pool.get('product.pricelist').search(cr, uid, [], context=context) - - pricelist_version_ids = list(set(pricelist_version_ids)) - plversions_search_args = [ - ('pricelist_id', 'in', pricelist_version_ids), - '|', - ('date_start', '=', False), - ('date_start', '<=', date), - '|', - ('date_end', '=', False), - ('date_end', '>=', date), - ] - - plversion_ids = product_pricelist_version_obj.search(cr, uid, plversions_search_args) - if len(pricelist_version_ids) != len(plversion_ids): - msg = "At least one pricelist has no active version !\nPlease create or activate one." - raise osv.except_osv(_('Warning !'), _(msg)) - - # product.product: - product_ids = [i[0] for i in products_by_qty_by_partner] - #products = dict([(item['id'], item) for item in product_obj.read(cr, uid, product_ids, ['categ_id', 'product_tmpl_id', 'uos_id', 'uom_id'])]) - products = product_obj.browse(cr, uid, product_ids, context=context) - products_dict = dict([(item.id, item) for item in products]) - - # product.category: - product_category_ids = product_category_obj.search(cr, uid, []) - product_categories = product_category_obj.read(cr, uid, product_category_ids, ['parent_id']) - product_category_tree = dict([(item['id'], item['parent_id'][0]) for item in product_categories if item['parent_id']]) - - results = {} - for product_id, qty, partner in products_by_qty_by_partner: - for pricelist_id in pricelist_version_ids: - price = False - - tmpl_id = products_dict[product_id].product_tmpl_id and products_dict[product_id].product_tmpl_id.id or False - - categ_id = products_dict[product_id].categ_id and products_dict[product_id].categ_id.id or False - categ_ids = _create_parent_category_list(categ_id, [categ_id]) - if categ_ids: - categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))' - else: - categ_where = '(categ_id IS NULL)' - - cr.execute( - 'SELECT i.*, pl.currency_id ' - 'FROM product_pricelist_item AS i, ' - 'product_pricelist_version AS v, product_pricelist AS pl ' - 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) ' - 'AND (product_id IS NULL OR product_id = %s) ' - 'AND (' + categ_where + ' OR (categ_id IS NULL)) ' - 'AND price_version_id = %s ' - 'AND (min_quantity IS NULL OR min_quantity <= %s) ' - 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id ' - 'ORDER BY sequence', - (tmpl_id, product_id, plversion_ids[0], qty)) - res1 = cr.dictfetchall() - uom_price_already_computed = False - for res in res1: - if res: - if res['base'] == -1: - if not res['base_pricelist_id']: - price = 0.0 - else: - price_tmp = self.price_get(cr, uid, - [res['base_pricelist_id']], product_id, - qty, context=context)[res['base_pricelist_id']] - ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id - price = currency_obj.compute(cr, uid, ptype_src, res['currency_id'], price_tmp, round=False) - elif res['base'] == -2: - # this section could be improved by moving the queries outside the loop: - where = [] - if partner: - where = [('name', '=', partner) ] - sinfo = supplierinfo_obj.search(cr, uid, - [('product_id', '=', tmpl_id)] + where) - price = 0.0 - if sinfo: - qty_in_product_uom = qty - product_default_uom = product_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0] - seller_uom = supplierinfo_obj.read(cr, uid, sinfo, ['product_uom'])[0]['product_uom'][0] - if seller_uom and product_default_uom and product_default_uom != seller_uom: - uom_price_already_computed = True - qty_in_product_uom = product_uom_obj._compute_qty(cr, uid, product_default_uom, qty, to_uom_id=seller_uom) - cr.execute('SELECT * ' \ - 'FROM pricelist_partnerinfo ' \ - 'WHERE suppinfo_id IN %s' \ - 'AND min_quantity <= %s ' \ - 'ORDER BY min_quantity DESC LIMIT 1', (tuple(sinfo),qty_in_product_uom,)) - res2 = cr.dictfetchone() - if res2: - price = res2['price'] - elif res['base'] == -3: - price = res['fixed_price'] - else: - price_type = price_type_obj.browse(cr, uid, int(res['base'])) - price = currency_obj.compute(cr, uid, - price_type.currency_id.id, res['currency_id'], - product_obj.price_get(cr, uid, [product_id], - price_type.field,context=context)[product_id], round=False, context=context) - - if price: - price_limit = price - - price = price * (1.0+(res['price_discount'] or 0.0)) - price = rounding(price, res['price_round']) - price += (res['price_surcharge'] or 0.0) - if res['price_min_margin']: - price = max(price, price_limit+res['price_min_margin']) - if res['price_max_margin']: - price = min(price, price_limit+res['price_max_margin']) - break - - else: - # False means no valid line found ! But we may not raise an - # exception here because it breaks the search - price = False - - if price: - if 'uom' in context and not uom_price_already_computed: - product = products_dict[product_id] - uom = product.uos_id or product.uom_id - price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, price, context['uom']) - - if results.get(product_id): - results[product_id][pricelist_id] = price - else: - results[product_id] = {pricelist_id: price} - - return results - -product_pricelist() === removed file 'product_pricelist_fixed_price/pricelist_view.xml' --- product_pricelist_fixed_price/pricelist_view.xml 2011-04-01 10:14:05 +0000 +++ product_pricelist_fixed_price/pricelist_view.xml 1970-01-01 00:00:00 +0000 @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<openerp> - <data> - <record model="ir.ui.view" id="product_pricelist_item_form_view_fixed"> - <field name="name">product.pricelist.item.form.fixed</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_max_margin" position="after"> - <field name="fixed_price" colspan="3" attrs="{'readonly': [('base','!=', -3)]}"/> - </field> - </field> - </record> - - <record model="ir.ui.view" id="product_pricelist_item_form_view_price_discount"> - <field name="name">product.pricelist.item.form.price_discount</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_discount" position="replace"> - <field name="price_discount" nolabel="1" attrs="{'readonly': [('base','==', -3)]}"/> - </field> - </field> - </record> - - <record model="ir.ui.view" id="product_pricelist_item_form_view_price_surcharge"> - <field name="name">product.pricelist.item.form.price_surcharge</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_surcharge" position="replace"> - <field name="price_surcharge" nolabel="1" attrs="{'readonly': [('base','==', -3)]}"/> - </field> - </field> - </record> - - <record model="ir.ui.view" id="product_pricelist_item_form_view_price_round"> - <field name="name">product.pricelist.item.form.price_round</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_round" position="replace"> - <field name="price_round" string="Rounding Method" attrs="{'readonly': [('base','==', -3)]}"/> - </field> - </field> - </record> - - <record model="ir.ui.view" id="product_pricelist_item_form_view_price_min_margin"> - <field name="name">product.pricelist.item.form.price_min_margin</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_min_margin" position="replace"> - <field name="price_min_margin" string="Min. Margin" attrs="{'readonly': [('base','==', -3)]}"/> - </field> - </field> - </record> - - <record model="ir.ui.view" id="product_pricelist_item_form_view_price_max_margin"> - <field name="name">product.pricelist.item.form.price_max_margin</field> - <field name="model">product.pricelist.item</field> - <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> - <field name="type">form</field> - <field name="arch" type="xml"> - <field name="price_max_margin" position="replace"> - <field name="price_max_margin" string="Max. Margin" attrs="{'readonly': [('base','==', -3)]}"/> - </field> - </field> - </record> - </data> -</openerp>
_______________________________________________ Mailing list: https://launchpad.net/~openerp-community Post to : [email protected] Unsubscribe : https://launchpad.net/~openerp-community More help : https://help.launchpad.net/ListHelp

