Merge lp:~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price into lp:~product-core-editors/openerp-product-attributes/7.0

Proposed by Pedro Manuel Baeza
Status: Merged
Approved by: Ronald Portier (Therp)
Approved revision: 232
Merged at revision: 234
Proposed branch: lp:~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price
Merge into: lp:~product-core-editors/openerp-product-attributes/7.0
Diff against target: 918 lines (+197/-598)
13 files modified
product_pricelist_fixed_price/AUTHORS.txt (+0/-1)
product_pricelist_fixed_price/__init__.py (+5/-9)
product_pricelist_fixed_price/__openerp__.py (+29/-20)
product_pricelist_fixed_price/i18n/ca.po (+0/-65)
product_pricelist_fixed_price/i18n/de.po (+0/-65)
product_pricelist_fixed_price/i18n/es.po (+35/-52)
product_pricelist_fixed_price/i18n/it.po (+0/-64)
product_pricelist_fixed_price/i18n/product_pricelist_fixed_price.pot (+23/-35)
product_pricelist_fixed_price/model/__init__.py (+19/-0)
product_pricelist_fixed_price/model/product_pricelist_item.py (+51/-0)
product_pricelist_fixed_price/pricelist.py (+0/-211)
product_pricelist_fixed_price/pricelist_view.xml (+0/-76)
product_pricelist_fixed_price/view/product_pricelist_item_view.xml (+35/-0)
To merge this branch: bzr merge lp:~pedro.baeza/openerp-product-attributes/7.0-product_pricelist_fixed_price
Reviewer Review Type Date Requested Status
Ronald Portier (Therp) (community) Approve
Yannick Vaucher @ Camptocamp code review, no tests Approve
Lorenzo Battistini (community) code review Approve
Niels Huylebroeck (community) Approve
Lionel Sausin - Initiatives/Numérigraphe (community) Needs Information
Review via email: mp+205045@code.launchpad.net

Description of the change

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).

To post a comment you must log in.
231. By Pedro Manuel Baeza

[ADD] product_pricelist_fixed_price: New module for fixed prices on pricelists, rewritten from scratch with a new approach.

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

Dear Pedro Manuel Baeza,
Thanks for your proposal, it's simpler than I expected.

Reading the code I understand that you're still using the "-100% + Price" trick, aren't you?

What happens if on_change() is not executed (for example records are added through XML-RPC)? The 100% discount will not be applied will it?

I'll test it in more depth tomorrow is I can.

Lionel.

review: Needs Information
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Lionel,

Indeed, you have to adjust all fields by XML-RPC, but that's the same flaw of all OpenERP objects (for example, on invoices, you don't get automatically filled all the account related fields when you write partner_id as if you were introducing it on web client).

You have two options:

- Fill complete dictionary with base=1, base_ext=-3, price_discount=-1 and price_surchage=<fixed price>.
- Fill base_ext=-3 and price_surchage=<fixed_price>, and then call XML-RPC on_change method and update dictionary with the returned value.

As you have seen, the "New Price = Base Price * (1 - 1) + price" trick is used.

Regards.

Revision history for this message
Marc Pierlot (mpierlot) wrote :

Bonjour

Est ce que quelqu'un peu me dire ce que je dos faire pour ne plus recevoir
ces messages de Open ERP qui m embetetent merci de ne plus me les envoyer

Tcau.

2014-02-06 11:08 GMT+01:00 Pedro Manuel Baeza <email address hidden>:

> Hi, Lionel,
>
> Indeed, you have to adjust all fields by XML-RPC, but that's the same flaw
> of all OpenERP objects (for example, on invoices, you don't get
> automatically filled all the account related fields when you write
> partner_id as if you were introducing it on web client).
>
> You have two options:
>
> - Fill complete dictionary with base=1, base_ext=-3, price_discount=-1 and
> price_surchage=<fixed price>.
> - Fill base_ext=-3 and price_surchage=<fixed_price>, and then call XML-RPC
> on_change method and update dictionary with the returned value.
>
> As you have seen, the "New Price = Base Price * (1 - 1) + price" trick is
> used.
>
> Regards.
> --
>
> 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.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~openerp-community
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Niels Huylebroeck (red15) wrote :

Looks very good to me, this is a clean restructuring of this module that avoids copying large chunks of openerp code to change some behaviour.

review: Approve
Revision history for this message
Niels Huylebroeck (red15) wrote :

> What happens if on_change() is not executed (for example records are added
> through XML-RPC)? The 100% discount will not be applied will it?

It's the responsibility of the client to call on_change over XML-RPC (or whatever channel your client is currently using) to get proper behaviour. This is something OpenERP has never been shy about using it in this way (just look at all the voucher and accounting tricks they use)

Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Linked bug report

LGTM

Good work

As it was completely refactored we will need to change version in __openerp__.py to 2.0

I add Ronald Portier as reviewer so he can have a look at it. As it superseed https://code.launchpad.net/~therp-nl/openerp-product-attributes/7.0_lp1272282_fixed_price/+merge/203348

review: Approve (code review, no tests)
232. By Pedro Manuel Baeza

[IMP] product_pricelist_fixed_price: New version and improved description.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I have changed version number and improve the module description.

Regards.

Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

Hello,

I think it is a pity the code does not work through xml-rpc because in its present form it completely depends on the on-change event. This problem did not exist in my original proposal.

On the other hand, the way a new fixed price type is added by Pedro is quite elegant.

In my proposal there was also a special view for fixed price types. This view is definitely not needed for everyone.

I agree to proceed with merging Pedro's code.

In a later stage - as soon as I have the time - I will propose an update that will take care of xml-rpc calls. But based on Pedro's method.

I also would like to propose a separate module that will add some special views for fixed prices, complete with the functionality requested by some to set the prices from the list.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
1Lorenzo Battistini <lorenzo.battistini@domsense.com>
20
=== 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-24 14:37:37 +0000
@@ -1,13 +1,10 @@
1# -*- encoding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
6#
7# This program is free software: you can redistribute it and/or modify4# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as5# it under the terms of the GNU Affero General Public License as published
9# published by the Free Software Foundation, either version 3 of the6# by the Free Software Foundation, either version 3 of the License, or
10# License, or (at your option) any later version.7# (at your option) any later version.
11#8#
12# This program is distributed in the hope that it will be useful,9# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,5 +15,4 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#16#
20##############################################################################17##############################################################################
2118from . import model
22import pricelist
2319
=== 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-24 14:37:37 +0000
@@ -1,13 +1,14 @@
1# -*- encoding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# OpenERP, Open Source Management Solution4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).5# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
6# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
6#7#
7# This program is free software: you can redistribute it and/or modify8# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as9# it under the terms of the GNU Affero General Public License as published
9# published by the Free Software Foundation, either version 3 of the10# by the Free Software Foundation, either version 3 of the License, or
10# License, or (at your option) any later version.11# (at your option) any later version.
11#12#
12# This program is distributed in the hope that it will be useful,13# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,20 +20,28 @@
19#20#
20##############################################################################21##############################################################################
2122
22
23{23{
24 "name": "Price List Fixed Price",24 "name": "Fixed price in pricelists",
25 "version": "1.0",25 "version": "2.0",
26 'category': 'Generic Modules/Inventory Control',26 "author": "Serv. Tecnol. Avanzados - Pedro M. Baeza",
27 "depends": ["product"],27 "category": "Sales Management",
28 "author": "Agile Business Group & Domsense",28 "description": """
29 "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""",29Fixed price on pricelist rule
30 'website': 'http://www.agilebg.com',30=============================
31 'init_xml': [],31
32 'update_xml': [32Adds a new option on pricelist rules to set a fixed price. This is made using
33 'pricelist_view.xml',33a trick that writes on the back 100% in the discount to the base price to get
34 ],34a zero base that will add only the price we put in the surcharge price.
35 'demo_xml': [],35 """,
36 'installable': False,36 "website": "www.serviciosbaeza.com",
37 'active': False,37 "license": "AGPL-3",
38 "depends": [
39 "product",
40 ],
41 "demo": [],
42 "data": [
43 'view/product_pricelist_item_view.xml',
44 ],
45 "installable": True,
46 "active": False,
38}47}
3948
=== 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 @@
1# Catalan translation for openobject-addons
2# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012
3# This file is distributed under the same license as the openobject-addons package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: openobject-addons\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2011-03-25 10:08+0000\n"
11"PO-Revision-Date: 2012-04-18 23:39+0000\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: Catalan <ca@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n"
18"X-Generator: Launchpad (build 16335)\n"
19
20#. module: product_pricelist_fixed_price
21#: view:product.pricelist.item:0
22msgid "Max. Margin"
23msgstr "Marge màxim"
24
25#. module: product_pricelist_fixed_price
26#: view:product.pricelist.item:0
27msgid "Min. Margin"
28msgstr "Marge mínim"
29
30#. module: product_pricelist_fixed_price
31#: view:product.pricelist.item:0
32msgid "Rounding Method"
33msgstr "Mètode arrodoniment"
34
35#. module: product_pricelist_fixed_price
36#: constraint:product.pricelist.item:0
37msgid ""
38"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList "
39"Item!"
40msgstr ""
41"Error! No podeu assignar la tarifa principal com una altre tarifa en un "
42"element de la tarifa."
43
44#. module: product_pricelist_fixed_price
45#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist
46msgid "Pricelist"
47msgstr "Tarifa"
48
49#. module: product_pricelist_fixed_price
50#: code:addons/product_pricelist_fixed_price/pricelist.py:97
51#, python-format
52msgid "Warning !"
53msgstr "Atenció!"
54
55#. module: product_pricelist_fixed_price
56#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item
57msgid "Pricelist item"
58msgstr "Element de la tarifa"
59
60#. module: product_pricelist_fixed_price
61#: code:addons/product_pricelist_fixed_price/pricelist.py:32
62#: field:product.pricelist.item,fixed_price:0
63#, python-format
64msgid "Fixed Price"
65msgstr "Preu fix"
660
=== 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 @@
1# German translation for openobject-addons
2# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
3# This file is distributed under the same license as the openobject-addons package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: openobject-addons\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2011-03-25 10:08+0000\n"
11"PO-Revision-Date: 2011-05-02 07:47+0000\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: German <de@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n"
18"X-Generator: Launchpad (build 16335)\n"
19
20#. module: product_pricelist_fixed_price
21#: view:product.pricelist.item:0
22msgid "Max. Margin"
23msgstr "Max. Spanne"
24
25#. module: product_pricelist_fixed_price
26#: view:product.pricelist.item:0
27msgid "Min. Margin"
28msgstr "Min. Spanne"
29
30#. module: product_pricelist_fixed_price
31#: view:product.pricelist.item:0
32msgid "Rounding Method"
33msgstr "Rundungsverfahren"
34
35#. module: product_pricelist_fixed_price
36#: constraint:product.pricelist.item:0
37msgid ""
38"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList "
39"Item!"
40msgstr ""
41"Fehler! Sie können die Basispreisliste nicht als alternative Preisliste in "
42"einem Preislisteneintrag zuweisen."
43
44#. module: product_pricelist_fixed_price
45#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist
46msgid "Pricelist"
47msgstr "Preisliste"
48
49#. module: product_pricelist_fixed_price
50#: code:addons/product_pricelist_fixed_price/pricelist.py:97
51#, python-format
52msgid "Warning !"
53msgstr "Warnung!"
54
55#. module: product_pricelist_fixed_price
56#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item
57msgid "Pricelist item"
58msgstr "Preisliste Einzelposition"
59
60#. module: product_pricelist_fixed_price
61#: code:addons/product_pricelist_fixed_price/pricelist.py:32
62#: field:product.pricelist.item,fixed_price:0
63#, python-format
64msgid "Fixed Price"
65msgstr "Festpreis"
660
=== 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-24 14:37:37 +0000
@@ -1,65 +1,48 @@
1# Spanish translation for openobject-addons1# Translation of OpenERP Server.
2# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 20112# This file contains the translation of the following modules:
3# This file is distributed under the same license as the openobject-addons package.3# * product_pricelist_fixed_price
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
5#4#
6msgid ""5msgid ""
7msgstr ""6msgstr ""
8"Project-Id-Version: openobject-addons\n"7"Project-Id-Version: OpenERP Server 7.0\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"8"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2011-03-25 10:08+0000\n"9"POT-Creation-Date: 2014-02-05 20:35+0000\n"
11"PO-Revision-Date: 2011-08-26 23:18+0000\n"10"PO-Revision-Date: 2014-02-05 21:36+0100\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"11"Last-Translator: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>\n"
13"Language-Team: Spanish <es@li.org>\n"12"Language-Team: \n"
14"MIME-Version: 1.0\n"13"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"14"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"15"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n"16"Plural-Forms: \n"
18"X-Generator: Launchpad (build 16335)\n"17
1918#. module: product_pricelist_fixed_price
20#. module: product_pricelist_fixed_price19#: view:product.pricelist.item:0
21#: view:product.pricelist.item:020msgid "Base Price"
22msgid "Max. Margin"21msgstr "Precio base"
23msgstr "Margen máximo"22
2423#. module: product_pricelist_fixed_price
25#. module: product_pricelist_fixed_price24#: help:product.pricelist.item,base_ext:0
26#: view:product.pricelist.item:025msgid "Base price for computation."
27msgid "Min. Margin"26msgstr "Precio base para el cálculo."
28msgstr "Margen mínimo"27
2928#. module: product_pricelist_fixed_price
30#. module: product_pricelist_fixed_price29#: field:product.pricelist.item,base_ext:0
31#: view:product.pricelist.item:030msgid "Based on"
32msgid "Rounding Method"31msgstr "Basado en"
33msgstr "Método redondeo"
34
35#. module: product_pricelist_fixed_price
36#: constraint:product.pricelist.item:0
37msgid ""
38"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList "
39"Item!"
40msgstr ""
41"¡Error! No puede asignar la tarifa principal como otra tarifa en un "
42"elemento de la tarifa."
43
44#. module: product_pricelist_fixed_price
45#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist
46msgid "Pricelist"
47msgstr "Lista de Precios"
48
49#. module: product_pricelist_fixed_price
50#: code:addons/product_pricelist_fixed_price/pricelist.py:97
51#, python-format
52msgid "Warning !"
53msgstr "¡Atención!"
5432
55#. module: product_pricelist_fixed_price33#. module: product_pricelist_fixed_price
56#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item34#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item
57msgid "Pricelist item"35msgid "Pricelist item"
58msgstr "Elemento de la tarifa"36msgstr "Elemento de tarifa"
5937
60#. module: product_pricelist_fixed_price38#. module: product_pricelist_fixed_price
61#: code:addons/product_pricelist_fixed_price/pricelist.py:3239#: view:product.pricelist.item:0
62#: field:product.pricelist.item,fixed_price:040msgid "Price Computation"
41msgstr "Cálculo del precio"
42
43#. module: product_pricelist_fixed_price
44#: code:addons/product_pricelist_fixed_price/model/product_pricelist_item.py:32
63#, python-format45#, python-format
64msgid "Fixed Price"46msgid "Fixed Price"
65msgstr "Precio fijo"47msgstr "Precio fijo"
48
6649
=== 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 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * product_pricelist_fixed_price
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.1\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-03-25 10:08+0000\n"
10"PO-Revision-Date: 2011-03-31 12:02+0000\n"
11"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"X-Launchpad-Export-Date: 2012-12-05 05:42+0000\n"
17"X-Generator: Launchpad (build 16335)\n"
18
19#. module: product_pricelist_fixed_price
20#: view:product.pricelist.item:0
21msgid "Max. Margin"
22msgstr "Margine Massimo"
23
24#. module: product_pricelist_fixed_price
25#: view:product.pricelist.item:0
26msgid "Min. Margin"
27msgstr "Margine Minimo"
28
29#. module: product_pricelist_fixed_price
30#: view:product.pricelist.item:0
31msgid "Rounding Method"
32msgstr "Metodo Arrotondamento"
33
34#. module: product_pricelist_fixed_price
35#: constraint:product.pricelist.item:0
36msgid ""
37"Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList "
38"Item!"
39msgstr ""
40"Errore ! Non è possibile assegnare il listino principale come 'altro "
41"listino' nell'elemento di listino!"
42
43#. module: product_pricelist_fixed_price
44#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist
45msgid "Pricelist"
46msgstr "Listino Prezzi"
47
48#. module: product_pricelist_fixed_price
49#: code:addons/product_pricelist_fixed_price/pricelist.py:97
50#, python-format
51msgid "Warning !"
52msgstr "attenzione !"
53
54#. module: product_pricelist_fixed_price
55#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist_item
56msgid "Pricelist item"
57msgstr "Oggetto Listino"
58
59#. module: product_pricelist_fixed_price
60#: code:addons/product_pricelist_fixed_price/pricelist.py:32
61#: field:product.pricelist.item,fixed_price:0
62#, python-format
63msgid "Fixed Price"
64msgstr "Prezzo fisso"
650
=== 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-24 14:37:37 +0000
@@ -4,46 +4,30 @@
4#4#
5msgid ""5msgid ""
6msgstr ""6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.1\n"7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2011-03-25 10:08+0000\n"9"POT-Creation-Date: 2014-02-05 20:35+0000\n"
10"PO-Revision-Date: 2011-03-25 10:08+0000\n"10"PO-Revision-Date: 2014-02-05 21:35+0100\n"
11"Last-Translator: <>\n"11"Last-Translator: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>\n"
12"Language-Team: \n"12"Language-Team: \n"
13"MIME-Version: 1.0\n"13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"16"Plural-Forms: \n"
1717
18#. module: product_pricelist_fixed_price18#. module: product_pricelist_fixed_price
19#: view:product.pricelist.item:019#: view:product.pricelist.item:0
20msgid "Max. Margin"20msgid "Base Price"
21msgstr ""21msgstr ""
2222
23#. module: product_pricelist_fixed_price23#. module: product_pricelist_fixed_price
24#: view:product.pricelist.item:024#: help:product.pricelist.item,base_ext:0
25msgid "Min. Margin"25msgid "Base price for computation."
26msgstr ""26msgstr ""
2727
28#. module: product_pricelist_fixed_price28#. module: product_pricelist_fixed_price
29#: view:product.pricelist.item:029#: field:product.pricelist.item,base_ext:0
30msgid "Rounding Method"30msgid "Based on"
31msgstr ""
32
33#. module: product_pricelist_fixed_price
34#: constraint:product.pricelist.item:0
35msgid "Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!"
36msgstr ""
37
38#. module: product_pricelist_fixed_price
39#: model:ir.model,name:product_pricelist_fixed_price.model_product_pricelist
40msgid "Pricelist"
41msgstr ""
42
43#. module: product_pricelist_fixed_price
44#: code:addons/product_pricelist_fixed_price/pricelist.py:97
45#, python-format
46msgid "Warning !"
47msgstr ""31msgstr ""
4832
49#. module: product_pricelist_fixed_price33#. module: product_pricelist_fixed_price
@@ -52,8 +36,12 @@
52msgstr ""36msgstr ""
5337
54#. module: product_pricelist_fixed_price38#. module: product_pricelist_fixed_price
55#: code:addons/product_pricelist_fixed_price/pricelist.py:3239#: view:product.pricelist.item:0
56#: field:product.pricelist.item,fixed_price:040msgid "Price Computation"
41msgstr ""
42
43#. module: product_pricelist_fixed_price
44#: code:addons/product_pricelist_fixed_price/model/product_pricelist_item.py:32
57#, python-format45#, python-format
58msgid "Fixed Price"46msgid "Fixed Price"
59msgstr ""47msgstr ""
6048
=== added directory 'product_pricelist_fixed_price/model'
=== added file 'product_pricelist_fixed_price/model/__init__.py'
--- product_pricelist_fixed_price/model/__init__.py 1970-01-01 00:00:00 +0000
+++ product_pricelist_fixed_price/model/__init__.py 2014-02-24 14:37:37 +0000
@@ -0,0 +1,19 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as published
6# by the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17##############################################################################
18from . import product_pricelist_item
19
020
=== added file 'product_pricelist_fixed_price/model/product_pricelist_item.py'
--- product_pricelist_fixed_price/model/product_pricelist_item.py 1970-01-01 00:00:00 +0000
+++ product_pricelist_fixed_price/model/product_pricelist_item.py 2014-02-24 14:37:37 +0000
@@ -0,0 +1,51 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
6# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22from openerp.osv import orm, fields
23from openerp.tools.translate import _
24
25
26class product_pricelist_item(orm.Model):
27 _inherit = 'product.pricelist.item'
28
29 def _price_field_get_ext(self, cr, uid, context=None):
30 result = super(product_pricelist_item, self)._price_field_get(
31 cr, uid, context=context)
32 result.append((-3, _('Fixed Price')))
33 return result
34
35 _columns = {
36 'base_ext': fields.selection(_price_field_get_ext, 'Based on',
37 required=True, size=-1,
38 help="Base price for computation."),
39 }
40 _defaults = {
41 'base_ext': -1,
42 }
43
44 def onchange_base_ext(self, cr, uid, ids, base_ext, context=None):
45 if base_ext == -3:
46 # Simulate be based on first found price that allows the trick
47 return {
48 'value': {'base': 1,
49 'price_discount': -1,}
50 }
51 return {'value': {'base': base_ext}}
052
=== 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 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import fields,osv
23from tools.translate import _
24import decimal_precision as dp
25import time
26from product._common import rounding
27
28class product_pricelist_item(osv.osv):
29
30 def _price_field_get(self, cr, uid, context=None):
31 result = super(product_pricelist_item, self)._price_field_get(cr, uid, context)
32 result.append((-3, _('Fixed Price')))
33 return result
34
35 _inherit = "product.pricelist.item"
36
37 _columns = {
38 'fixed_price': fields.float('Fixed Price',
39 digits_compute= dp.get_precision('Sale Price')),
40 'base': fields.selection(_price_field_get, 'Based on', required=True, size=-1, help="The mode for computing the price for this rule."),
41 }
42
43product_pricelist_item()
44
45class product_pricelist(osv.osv):
46 _inherit = "product.pricelist"
47
48 def price_get_multi(self, cr, uid, pricelist_ids, products_by_qty_by_partner, context=None):
49
50 def _create_parent_category_list(id, lst):
51 if not id:
52 return []
53 parent = product_category_tree.get(id)
54 if parent:
55 lst.append(parent)
56 return _create_parent_category_list(parent, lst)
57 else:
58 return lst
59 # _create_parent_category_list
60
61 if context is None:
62 context = {}
63
64 date = time.strftime('%Y-%m-%d')
65 if 'date' in context:
66 date = context['date']
67
68 currency_obj = self.pool.get('res.currency')
69 product_obj = self.pool.get('product.product')
70 product_category_obj = self.pool.get('product.category')
71 product_uom_obj = self.pool.get('product.uom')
72 supplierinfo_obj = self.pool.get('product.supplierinfo')
73 price_type_obj = self.pool.get('product.price.type')
74 product_pricelist_version_obj = self.pool.get('product.pricelist.version')
75
76 # product.pricelist.version:
77 if pricelist_ids:
78 pricelist_version_ids = pricelist_ids
79 else:
80 # all pricelists:
81 pricelist_version_ids = self.pool.get('product.pricelist').search(cr, uid, [], context=context)
82
83 pricelist_version_ids = list(set(pricelist_version_ids))
84 plversions_search_args = [
85 ('pricelist_id', 'in', pricelist_version_ids),
86 '|',
87 ('date_start', '=', False),
88 ('date_start', '<=', date),
89 '|',
90 ('date_end', '=', False),
91 ('date_end', '>=', date),
92 ]
93
94 plversion_ids = product_pricelist_version_obj.search(cr, uid, plversions_search_args)
95 if len(pricelist_version_ids) != len(plversion_ids):
96 msg = "At least one pricelist has no active version !\nPlease create or activate one."
97 raise osv.except_osv(_('Warning !'), _(msg))
98
99 # product.product:
100 product_ids = [i[0] for i in products_by_qty_by_partner]
101 #products = dict([(item['id'], item) for item in product_obj.read(cr, uid, product_ids, ['categ_id', 'product_tmpl_id', 'uos_id', 'uom_id'])])
102 products = product_obj.browse(cr, uid, product_ids, context=context)
103 products_dict = dict([(item.id, item) for item in products])
104
105 # product.category:
106 product_category_ids = product_category_obj.search(cr, uid, [])
107 product_categories = product_category_obj.read(cr, uid, product_category_ids, ['parent_id'])
108 product_category_tree = dict([(item['id'], item['parent_id'][0]) for item in product_categories if item['parent_id']])
109
110 results = {}
111 for product_id, qty, partner in products_by_qty_by_partner:
112 for pricelist_id in pricelist_version_ids:
113 price = False
114
115 tmpl_id = products_dict[product_id].product_tmpl_id and products_dict[product_id].product_tmpl_id.id or False
116
117 categ_id = products_dict[product_id].categ_id and products_dict[product_id].categ_id.id or False
118 categ_ids = _create_parent_category_list(categ_id, [categ_id])
119 if categ_ids:
120 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
121 else:
122 categ_where = '(categ_id IS NULL)'
123
124 cr.execute(
125 'SELECT i.*, pl.currency_id '
126 'FROM product_pricelist_item AS i, '
127 'product_pricelist_version AS v, product_pricelist AS pl '
128 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
129 'AND (product_id IS NULL OR product_id = %s) '
130 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
131 'AND price_version_id = %s '
132 'AND (min_quantity IS NULL OR min_quantity <= %s) '
133 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
134 'ORDER BY sequence',
135 (tmpl_id, product_id, plversion_ids[0], qty))
136 res1 = cr.dictfetchall()
137 uom_price_already_computed = False
138 for res in res1:
139 if res:
140 if res['base'] == -1:
141 if not res['base_pricelist_id']:
142 price = 0.0
143 else:
144 price_tmp = self.price_get(cr, uid,
145 [res['base_pricelist_id']], product_id,
146 qty, context=context)[res['base_pricelist_id']]
147 ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id
148 price = currency_obj.compute(cr, uid, ptype_src, res['currency_id'], price_tmp, round=False)
149 elif res['base'] == -2:
150 # this section could be improved by moving the queries outside the loop:
151 where = []
152 if partner:
153 where = [('name', '=', partner) ]
154 sinfo = supplierinfo_obj.search(cr, uid,
155 [('product_id', '=', tmpl_id)] + where)
156 price = 0.0
157 if sinfo:
158 qty_in_product_uom = qty
159 product_default_uom = product_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]
160 seller_uom = supplierinfo_obj.read(cr, uid, sinfo, ['product_uom'])[0]['product_uom'][0]
161 if seller_uom and product_default_uom and product_default_uom != seller_uom:
162 uom_price_already_computed = True
163 qty_in_product_uom = product_uom_obj._compute_qty(cr, uid, product_default_uom, qty, to_uom_id=seller_uom)
164 cr.execute('SELECT * ' \
165 'FROM pricelist_partnerinfo ' \
166 'WHERE suppinfo_id IN %s' \
167 'AND min_quantity <= %s ' \
168 'ORDER BY min_quantity DESC LIMIT 1', (tuple(sinfo),qty_in_product_uom,))
169 res2 = cr.dictfetchone()
170 if res2:
171 price = res2['price']
172 elif res['base'] == -3:
173 price = res['fixed_price']
174 else:
175 price_type = price_type_obj.browse(cr, uid, int(res['base']))
176 price = currency_obj.compute(cr, uid,
177 price_type.currency_id.id, res['currency_id'],
178 product_obj.price_get(cr, uid, [product_id],
179 price_type.field,context=context)[product_id], round=False, context=context)
180
181 if price:
182 price_limit = price
183
184 price = price * (1.0+(res['price_discount'] or 0.0))
185 price = rounding(price, res['price_round'])
186 price += (res['price_surcharge'] or 0.0)
187 if res['price_min_margin']:
188 price = max(price, price_limit+res['price_min_margin'])
189 if res['price_max_margin']:
190 price = min(price, price_limit+res['price_max_margin'])
191 break
192
193 else:
194 # False means no valid line found ! But we may not raise an
195 # exception here because it breaks the search
196 price = False
197
198 if price:
199 if 'uom' in context and not uom_price_already_computed:
200 product = products_dict[product_id]
201 uom = product.uos_id or product.uom_id
202 price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, price, context['uom'])
203
204 if results.get(product_id):
205 results[product_id][pricelist_id] = price
206 else:
207 results[product_id] = {pricelist_id: price}
208
209 return results
210
211product_pricelist()
2120
=== 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 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4 <record model="ir.ui.view" id="product_pricelist_item_form_view_fixed">
5 <field name="name">product.pricelist.item.form.fixed</field>
6 <field name="model">product.pricelist.item</field>
7 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <field name="price_max_margin" position="after">
11 <field name="fixed_price" colspan="3" attrs="{'readonly': [('base','!=', -3)]}"/>
12 </field>
13 </field>
14 </record>
15
16 <record model="ir.ui.view" id="product_pricelist_item_form_view_price_discount">
17 <field name="name">product.pricelist.item.form.price_discount</field>
18 <field name="model">product.pricelist.item</field>
19 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
20 <field name="type">form</field>
21 <field name="arch" type="xml">
22 <field name="price_discount" position="replace">
23 <field name="price_discount" nolabel="1" attrs="{'readonly': [('base','==', -3)]}"/>
24 </field>
25 </field>
26 </record>
27
28 <record model="ir.ui.view" id="product_pricelist_item_form_view_price_surcharge">
29 <field name="name">product.pricelist.item.form.price_surcharge</field>
30 <field name="model">product.pricelist.item</field>
31 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
32 <field name="type">form</field>
33 <field name="arch" type="xml">
34 <field name="price_surcharge" position="replace">
35 <field name="price_surcharge" nolabel="1" attrs="{'readonly': [('base','==', -3)]}"/>
36 </field>
37 </field>
38 </record>
39
40 <record model="ir.ui.view" id="product_pricelist_item_form_view_price_round">
41 <field name="name">product.pricelist.item.form.price_round</field>
42 <field name="model">product.pricelist.item</field>
43 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
44 <field name="type">form</field>
45 <field name="arch" type="xml">
46 <field name="price_round" position="replace">
47 <field name="price_round" string="Rounding Method" attrs="{'readonly': [('base','==', -3)]}"/>
48 </field>
49 </field>
50 </record>
51
52 <record model="ir.ui.view" id="product_pricelist_item_form_view_price_min_margin">
53 <field name="name">product.pricelist.item.form.price_min_margin</field>
54 <field name="model">product.pricelist.item</field>
55 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
56 <field name="type">form</field>
57 <field name="arch" type="xml">
58 <field name="price_min_margin" position="replace">
59 <field name="price_min_margin" string="Min. Margin" attrs="{'readonly': [('base','==', -3)]}"/>
60 </field>
61 </field>
62 </record>
63
64 <record model="ir.ui.view" id="product_pricelist_item_form_view_price_max_margin">
65 <field name="name">product.pricelist.item.form.price_max_margin</field>
66 <field name="model">product.pricelist.item</field>
67 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
68 <field name="type">form</field>
69 <field name="arch" type="xml">
70 <field name="price_max_margin" position="replace">
71 <field name="price_max_margin" string="Max. Margin" attrs="{'readonly': [('base','==', -3)]}"/>
72 </field>
73 </field>
74 </record>
75 </data>
76</openerp>
770
=== added directory 'product_pricelist_fixed_price/view'
=== added file 'product_pricelist_fixed_price/view/product_pricelist_item_view.xml'
--- product_pricelist_fixed_price/view/product_pricelist_item_view.xml 1970-01-01 00:00:00 +0000
+++ product_pricelist_fixed_price/view/product_pricelist_item_view.xml 2014-02-24 14:37:37 +0000
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="product_pricelist_item_fixedprice_form" model="ir.ui.view">
6 <field name="name">product.pricelist.item.fixedprice</field>
7 <field name="model">product.pricelist.item</field>
8 <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
9 <field name="arch" type="xml">
10 <group string="Price Computation" position="attributes">
11 <attribute name="col">6</attribute>
12 </group>
13 <field name="base" position="attributes">
14 <attribute name="invisible">True</attribute>
15 </field>
16 <field name="base_pricelist_id" position="before">
17 <field name="base_ext" on_change="onchange_base_ext(base_ext)"/>
18 </field>
19 <label string="Base Price" position="attributes">
20 <attribute name="attrs">{'invisible': [('base_ext', '=', -3)]}</attribute>
21 </label>
22 <label string="* ( 1 + " position="attributes">
23 <attribute name="attrs">{'invisible': [('base_ext', '=', -3)]}</attribute>
24 </label>
25 <field name="price_discount" position="attributes">
26 <attribute name="attrs">{'invisible': [('base_ext', '=', -3)]}</attribute>
27 </field>
28 <label string=" ) + " position="attributes">
29 <attribute name="attrs">{'invisible': [('base_ext', '=', -3)]}</attribute>
30 </label>
31 </field>
32 </record>
33
34 </data>
35</openerp>

Subscribers

People subscribed via source and target branches