From 1b016c7b0b8ef71066c9548c673355d54704b7f8 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 30 Mar 2020 15:26:27 +0200 Subject: [PATCH 01/26] [ADD] product_multi_price: New Module --- product_multi_price/README.rst | 115 +++++ product_multi_price/__init__.py | 1 + product_multi_price/__manifest__.py | 25 + .../demo/multi_price_demo_data.xml | 10 + product_multi_price/i18n/es.po | 172 +++++++ .../i18n/product_multi_price.pot | 171 +++++++ product_multi_price/models/__init__.py | 4 + .../models/product_multi_price.py | 98 ++++ .../models/product_pricelist.py | 37 ++ product_multi_price/models/product_product.py | 68 +++ .../models/product_template.py | 59 +++ product_multi_price/readme/CONFIGURE.rst | 9 + product_multi_price/readme/CONTRIBUTORS.rst | 4 + product_multi_price/readme/DESCRIPTION.rst | 2 + product_multi_price/readme/ROADMAP.rst | 3 + product_multi_price/readme/USAGE.rst | 14 + .../security/ir.model.access.csv | 4 + .../security/multi_price_security.xml | 18 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 465 ++++++++++++++++++ product_multi_price/tests/__init__.py | 1 + .../tests/test_product_multi_price.py | 119 +++++ .../views/multi_price_views.xml | 62 +++ .../views/product_pricelist_views.xml | 14 + product_multi_price/views/product_views.xml | 28 ++ 25 files changed, 1503 insertions(+) create mode 100644 product_multi_price/README.rst create mode 100644 product_multi_price/__init__.py create mode 100644 product_multi_price/__manifest__.py create mode 100644 product_multi_price/demo/multi_price_demo_data.xml create mode 100644 product_multi_price/i18n/es.po create mode 100644 product_multi_price/i18n/product_multi_price.pot create mode 100644 product_multi_price/models/__init__.py create mode 100644 product_multi_price/models/product_multi_price.py create mode 100644 product_multi_price/models/product_pricelist.py create mode 100644 product_multi_price/models/product_product.py create mode 100644 product_multi_price/models/product_template.py create mode 100644 product_multi_price/readme/CONFIGURE.rst create mode 100644 product_multi_price/readme/CONTRIBUTORS.rst create mode 100644 product_multi_price/readme/DESCRIPTION.rst create mode 100644 product_multi_price/readme/ROADMAP.rst create mode 100644 product_multi_price/readme/USAGE.rst create mode 100644 product_multi_price/security/ir.model.access.csv create mode 100644 product_multi_price/security/multi_price_security.xml create mode 100644 product_multi_price/static/description/icon.png create mode 100644 product_multi_price/static/description/index.html create mode 100644 product_multi_price/tests/__init__.py create mode 100644 product_multi_price/tests/test_product_multi_price.py create mode 100644 product_multi_price/views/multi_price_views.xml create mode 100644 product_multi_price/views/product_pricelist_views.xml create mode 100644 product_multi_price/views/product_views.xml diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst new file mode 100644 index 000000000000..0e5cc0caa2bb --- /dev/null +++ b/product_multi_price/README.rst @@ -0,0 +1,115 @@ +=================== +Product Multi Price +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github + :target: https://github.com/OCA/product-attribute/tree/11.0/product_multi_price + :alt: OCA/product-attribute +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-attribute-11-0/product-attribute-11-0-product_multi_price + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/135/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set multiple prices to products and base pricelist +rules on them. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure multiple prices you need to set multi prices field names first. +To do so, you need admin permissions. Then go to: + +#. *Settings > General Settings > Technical > Database Structure > + Price Field Names* +#. Create the multi price fields you need. + +If you have multiple companies, you can assign independet field sets for each +one. + +Usage +===== + +To use this module, you need to: + +#. Go to the product page. +#. In the general tab, there's a list called *Prices*. +#. You can add one for every multiple price field name available. + +To base pricelist rules on that fields, in the pricelist: + +#. Add a rule and choose *formula* as the computing method. +#. In the *Based on* dropdown list you can select *Multiple Prices*. +#. A new list appear: *Multiple Price Field Name*. Pick the one you need. +#. Configure the formula. +#. Now the rule is based on that price for the products that have it + configured. Otherwise, it will return 0. + +Known issues / Roadmap +====================== + +* Add mechanisms that allow to set multiprices values from external flows. For + example: having AVCO, FIFO and Standard prices computed simultaneously in + this table. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * David Vidal + * Pedro M. Baeza + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/product-attribute `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_multi_price/__init__.py b/product_multi_price/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/product_multi_price/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py new file mode 100644 index 000000000000..43ae4912d7e7 --- /dev/null +++ b/product_multi_price/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Product Multi Price", + "version": "11.0.1.0.0", + 'author': 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/product-attribute', + "category": "Product Management", + "license": "AGPL-3", + "depends": [ + "product", + ], + "data": [ + "security/ir.model.access.csv", + "security/multi_price_security.xml", + "views/multi_price_views.xml", + "views/product_pricelist_views.xml", + "views/product_views.xml", + ], + 'demo': [ + "demo/multi_price_demo_data.xml", + ], + "installable": True, +} diff --git a/product_multi_price/demo/multi_price_demo_data.xml b/product_multi_price/demo/multi_price_demo_data.xml new file mode 100644 index 000000000000..d2f2955c39f1 --- /dev/null +++ b/product_multi_price/demo/multi_price_demo_data.xml @@ -0,0 +1,10 @@ + + + + + + price_1 + + + + diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po new file mode 100644 index 000000000000..eb43d2e9f863 --- /dev/null +++ b/product_multi_price/i18n/es.po @@ -0,0 +1,172 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_multi_price +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-04-03 14:21+0000\n" +"PO-Revision-Date: 2020-04-03 14:21+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_multi_price +#: sql_constraint:product.multi.price:0 +msgid "A field name cannot be assigned to a product twice for the same company" +msgstr "No puede haber un nombre de campo repetido en la misma compañía" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_company_id +msgid "Company" +msgstr "Compañía" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_date +msgid "Created on" +msgstr "Creado en" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: product_multi_price +#: code:addons/product_multi_price/models/product_multi_price.py:91 +#, python-format +msgid "Field names can only contain characters, digits and underscores (up to 63)." +msgstr "Los nombres de campo solo pueden contener caracteres alfanuméricos, dígitos o guiones bajos (hasta 63)." + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id +msgid "ID" +msgstr "ID (identificación)" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price___last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name___last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_uid +msgid "Last Updated by" +msgstr "Última actualización de" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_date +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_multi_price +msgid "Multi Price" +msgstr "Multi Precio" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name +msgid "Multiple Price Field Name" +msgstr "Nombre de Campo de Precio Múltiple" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_template_form_view +#: model:ir.ui.view,arch_db:product_multi_price.product_variant_easy_edit_view +msgid "Multiple Prices" +msgstr "Precios Múltiples" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +msgid "Name" +msgstr "Nombre" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +msgid "Price" +msgstr "Precio" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_name +msgid "Price Field Name" +msgstr "Nombre de Campo de Precio" + +#. module: product_multi_price +#: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config +#: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu +msgid "Price Field Names" +msgstr "Nombres de Campo de Precio" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist +msgid "Pricelist" +msgstr "Tarifa" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist_item +msgid "Pricelist item" +msgstr "Elemento de Tarifa" + +#. module: product_multi_price +#: sql_constraint:product.multi.price.name:0 +msgid "Prices Names must be unique per company" +msgstr "Los Nombres de Precio deben ser únicos para cada compañía" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_product +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_product_id +msgid "Product" +msgstr "Producto" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +msgid "Product Multi Price" +msgstr "Multi Precio de Producto" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +msgid "Product Multi Price Field Name" +msgstr "Nombre de Campo de Multi Precio de Producto" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +msgid "Product Multi_price" +msgstr "Multi Precio de Producto" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: product_multi_price +#: code:addons/product_multi_price/models/product_multi_price.py:96 +#, python-format +msgid "The field name is used in the model, try another" +msgstr "El campo se utiliza en el modelo, escoja otro" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price +msgid "product.multi.price" +msgstr "product.multi.price" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "product.multi.price.name" +msgstr "product.multi.price.name" diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot new file mode 100644 index 000000000000..2824a64a1530 --- /dev/null +++ b/product_multi_price/i18n/product_multi_price.pot @@ -0,0 +1,171 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_multi_price +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_multi_price +#: sql_constraint:product.multi.price:0 +msgid "A field name cannot be assigned to a product twice for the same company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_company_id +msgid "Company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_uid +msgid "Created by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_date +msgid "Created on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_display_name +msgid "Display Name" +msgstr "" + +#. module: product_multi_price +#: code:addons/product_multi_price/models/product_multi_price.py:92 +#, python-format +msgid "Field names can only contain characters, digits and underscores (up to 63)." +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id +msgid "ID" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price___last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name___last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_multi_price +msgid "Multi Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name +msgid "Multiple Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_template_form_view +#: model:ir.ui.view,arch_db:product_multi_price.product_variant_easy_edit_view +msgid "Multiple Prices" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +msgid "Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +msgid "Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_name +msgid "Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config +#: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu +msgid "Price Field Names" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist +msgid "Pricelist" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist_item +msgid "Pricelist item" +msgstr "" + +#. module: product_multi_price +#: sql_constraint:product.multi.price.name:0 +msgid "Prices Names must be unique per company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_product +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_product_id +msgid "Product" +msgstr "" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +msgid "Product Multi Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +msgid "Product Multi Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +msgid "Product Multi_price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_multi_price +#: code:addons/product_multi_price/models/product_multi_price.py:97 +#, python-format +msgid "The field name is used in the model, try another" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price +msgid "product.multi.price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "product.multi.price.name" +msgstr "" + diff --git a/product_multi_price/models/__init__.py b/product_multi_price/models/__init__.py new file mode 100644 index 000000000000..b0fa0aa6da96 --- /dev/null +++ b/product_multi_price/models/__init__.py @@ -0,0 +1,4 @@ +from . import product_multi_price +from . import product_pricelist +from . import product_product +from . import product_template diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py new file mode 100644 index 000000000000..c858a8748ff8 --- /dev/null +++ b/product_multi_price/models/product_multi_price.py @@ -0,0 +1,98 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, api, fields, models, tools +from odoo.exceptions import ValidationError +from odoo.addons import decimal_precision as dp + + +class ProductMultiPrice(models.Model): + _name = 'product.multi.price' + + name = fields.Many2one( + comodel_name='product.multi.price.name', + required=True, + ) + product_id = fields.Many2one( + comodel_name='product.product', + required=True, + ondelete='cascade', + ) + price = fields.Float( + digits=dp.get_precision('Product Price'), + ) + company_id = fields.Many2one( + comodel_name='res.company', + related='name.company_id', + store=True, + readonly=True, + ) + + _sql_constraints = [ + ('multi_price_uniq', 'unique(name, product_id, company_id)', + 'A field name cannot be assigned to a product twice for the same ' + 'company'), + ] + + +class ProductMultiPriceName(models.Model): + _name = 'product.multi.price.name' + + @api.model + def _get_company(self): + return self._context.get('company_id', self.env.user.company_id.id) + + name = fields.Char( + required=True, + string='Price Field Name', + ondelete='restrict' + ) + company_id = fields.Many2one( + comodel_name='res.company', + required=True, + default=lambda self: self._get_company() + ) + + _sql_constraints = [ + ('multi_price_name_uniq', 'unique(name, company_id)', + 'Prices Names must be unique per company'), + ] + + @api.model + @tools.ormcache() + def _get_field_names(self): + return set([x.name for x in self.search([])]) + + @api.model + def create(self, vals): + res = super().create(vals) + self.clear_caches() + return res + + def write(self, vals): + res = super().write(vals) + if 'name' in vals: + self.clear_caches() + return res + + def unlink(self): + res = super().unlink() + self.clear_caches() + return res + + @api.constrains('name') + def _check_name(self): + """The target is to use multi price as if they were virtual fields + so we want to constrain the naming to the same rules""" + product_fields = list(self.env['product.product']._fields) + product_fields += list(self.env['product.template']._fields) + for field in self: + try: + models.check_pg_name(field.name) + except ValidationError: + msg = _( + "Field names can only contain characters, " + "digits and underscores (up to 63).") + raise ValidationError(msg) + if field in set(product_fields): + raise ValidationError(_( + "The field name is used in the model, try another")) diff --git a/product_multi_price/models/product_pricelist.py b/product_multi_price/models/product_pricelist.py new file mode 100644 index 000000000000..8d1cfb6963df --- /dev/null +++ b/product_multi_price/models/product_pricelist.py @@ -0,0 +1,37 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductPricelist(models.Model): + _inherit = 'product.pricelist' + + def _compute_price_rule(self, products_qty_partner, date=False, + uom_id=False): + """Recompute price after calling the atomic super method for + getting proper prices when based on multi price. + """ + rule_obj = self.env['product.pricelist.item'] + result = super()._compute_price_rule( + products_qty_partner, date, uom_id) + # Make sure all rule records are fetched at once and put in cache + rule_obj.browse(x[1] for x in result.values()).mapped('price_discount') + for product, qty, _partner in products_qty_partner: + rule = rule_obj.browse(result[product.id][1]) + if rule.compute_price == 'formula' and rule.base == 'multi_price': + result[product.id] = ( + product._get_multiprice_pricelist_price(rule), + rule.id) + return result + + +class ProductPricelistItem(models.Model): + _inherit = 'product.pricelist.item' + + base = fields.Selection( + selection_add=[('multi_price', 'Multiple Price Field')], + ) + multi_price_name = fields.Many2one( + comodel_name='product.multi.price.name', + string="Multiple Price Field Name", + ) diff --git a/product_multi_price/models/product_product.py b/product_multi_price/models/product_product.py new file mode 100644 index 000000000000..03a042a0fb1a --- /dev/null +++ b/product_multi_price/models/product_product.py @@ -0,0 +1,68 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models, fields, tools +from odoo.addons import decimal_precision as dp + + +class ProductProduct(models.Model): + _inherit = "product.product" + + price_ids = fields.One2many( + comodel_name='product.multi.price', + inverse_name='product_id', + ) + multi_price = fields.Float( + digits=dp.get_precision('Product Price'), + compute='_compute_multi_price', + groups="base.group_user", + ) + + def _get_multiprice_pricelist_price(self, rule): + """Method for getting the price from multi price.""" + self.ensure_one() + company = rule.company_id or self.env.user.company_id + price = self.env['product.multi.price'].search([ + ('company_id', '=', company.id), + ('name', '=', rule.multi_price_name.id), + ('product_id', '=', self.id), + ]).price or 0 + if price: + # We have to replicate this logic in this method as pricelist + # method are atomic and we can't hack inside. + # Verbatim copy of part of product.pricelist._compute_price_rule. + qty_uom_id = self._context.get('uom') or self.uom_id.id + price_uom = self.env['product.uom'].browse([qty_uom_id]) + convert_to_price_uom = ( + lambda price: self.uom_id._compute_price( + price, price_uom)) + price_limit = price + price = (price - (price * (rule.price_discount / 100))) or 0.0 + if rule.price_round: + price = tools.float_round( + price, precision_rounding=rule.price_round) + if rule.price_surcharge: + price_surcharge = convert_to_price_uom(rule.price_surcharge) + price += price_surcharge + if rule.price_min_margin: + price_min_margin = convert_to_price_uom(rule.price_min_margin) + price = max(price, price_limit + price_min_margin) + if rule.price_max_margin: + price_max_margin = convert_to_price_uom(rule.price_max_margin) + price = min(price, price_limit + price_max_margin) + return price + + def _compute_multi_price(self): + """Use multi_price field as the proxy for any of the registered + multi price fields on the product passing it by context""" + multi_price_field = self.env.context.get('multi_price_field', False) + if not multi_price_field: + self.update({'multi_price': 0}) + return + prices_list = self.env['product.multi.price'].search_read([ + ('name.name', '=', multi_price_field), + ('product_id', 'in', self.ids), + ('company_id', '=', self.env.user.company_id.id) + ], ['product_id', 'price'], limit=1) + prices_dict = {x['product_id'][0]: x['price'] for x in prices_list} + for product in self: + product.multi_price = prices_dict.get(product.id, 0.0) diff --git a/product_multi_price/models/product_template.py b/product_multi_price/models/product_template.py new file mode 100644 index 000000000000..a7c6f670964b --- /dev/null +++ b/product_multi_price/models/product_template.py @@ -0,0 +1,59 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models +from odoo.addons import decimal_precision as dp + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + price_ids = fields.One2many( + comodel_name='product.multi.price', + compute='_compute_price_ids', + inverse='_set_price_ids', + ) + multi_price = fields.Float( + digits=dp.get_precision('Product Price'), + compute='_compute_multi_price', + groups="base.group_user", + readonly=True, + ) + + @api.depends('product_variant_ids', + 'product_variant_ids.price_ids') + def _compute_price_ids(self): + for p in self: + if len(p.product_variant_ids) == 1: + p.price_ids = p.product_variant_ids.price_ids + + def _set_price_ids(self): + for p in self: + if len(p.product_variant_ids) == 1: + p.product_variant_ids.price_ids = p.price_ids + + def _get_multiprice_pricelist_price(self, rule): + if len(self.product_variant_ids) == 1: + return ( + self.product_variant_ids._get_multiprice_pricelist_price(rule)) + return 0 + + @api.depends('product_variant_ids', 'product_variant_ids.multi_price') + def _compute_multi_price(self): + """Use multi_price field as the frontend for any of the registered + multi price fields on the product passing it by context""" + multi_price_field = self.env.context.get('multi_price_field', False) + if not multi_price_field: + self.update({'multi_price': 0}) + return + for p in self: + if len(p.product_variant_ids) == 1: + p.multi_price = p.product_variant_ids.multi_price + + @api.model + def create(self, vals): + product = super().create(vals) + if vals.get('price_ids'): + product.write({ + 'price_ids': vals.get('price_ids'), + }) + return product diff --git a/product_multi_price/readme/CONFIGURE.rst b/product_multi_price/readme/CONFIGURE.rst new file mode 100644 index 000000000000..91472fd43690 --- /dev/null +++ b/product_multi_price/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +To configure multiple prices you need to set multi prices field names first. +To do so, you need admin permissions. Then go to: + +#. *Settings > General Settings > Technical > Database Structure > + Price Field Names* +#. Create the multi price fields you need. + +If you have multiple companies, you can assign independet field sets for each +one. diff --git a/product_multi_price/readme/CONTRIBUTORS.rst b/product_multi_price/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..ac6cb650339b --- /dev/null +++ b/product_multi_price/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * David Vidal + * Pedro M. Baeza diff --git a/product_multi_price/readme/DESCRIPTION.rst b/product_multi_price/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..c76055a6eb90 --- /dev/null +++ b/product_multi_price/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to set multiple prices to products and base pricelist +rules on them. diff --git a/product_multi_price/readme/ROADMAP.rst b/product_multi_price/readme/ROADMAP.rst new file mode 100644 index 000000000000..620354d64ab4 --- /dev/null +++ b/product_multi_price/readme/ROADMAP.rst @@ -0,0 +1,3 @@ +* Add mechanisms that allow to set multiprices values from external flows. For + example: having AVCO, FIFO and Standard prices computed simultaneously in + this table. diff --git a/product_multi_price/readme/USAGE.rst b/product_multi_price/readme/USAGE.rst new file mode 100644 index 000000000000..7c796fa82a8b --- /dev/null +++ b/product_multi_price/readme/USAGE.rst @@ -0,0 +1,14 @@ +To use this module, you need to: + +#. Go to the product page. +#. In the general tab, there's a list called *Prices*. +#. You can add one for every multiple price field name available. + +To base pricelist rules on that fields, in the pricelist: + +#. Add a rule and choose *formula* as the computing method. +#. In the *Based on* dropdown list you can select *Multiple Prices*. +#. A new list appear: *Multiple Price Field Name*. Pick the one you need. +#. Configure the formula. +#. Now the rule is based on that price for the products that have it + configured. Otherwise, it will return 0. diff --git a/product_multi_price/security/ir.model.access.csv b/product_multi_price/security/ir.model.access.csv new file mode 100644 index 000000000000..c15ad02ac205 --- /dev/null +++ b/product_multi_price/security/ir.model.access.csv @@ -0,0 +1,4 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"multi price","product.multi.price","model_product_multi_price","base.group_user",1,1,1,1 +"multi price name read","product.multi.price.name","model_product_multi_price_name","base.group_user",1,0,0,0 +"multi price name admin","product.multi.price.name","model_product_multi_price_name","base.group_system",1,1,1,1 diff --git a/product_multi_price/security/multi_price_security.xml b/product_multi_price/security/multi_price_security.xml new file mode 100644 index 000000000000..ba093f4594a1 --- /dev/null +++ b/product_multi_price/security/multi_price_security.xml @@ -0,0 +1,18 @@ + + + + + Multiple Price multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + Multiple Price Field Name multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + diff --git a/product_multi_price/static/description/icon.png b/product_multi_price/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9 zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz# z-5EK$o(!F?hmX*2Yt6+coY`6jGbb7tF#6nHA zuKk=GGJ;ZwON1iAfG$E#Y7MnZVmrY|j0eVI(DN_MNFJmyZ|;w4tf@=CCDZ#5N_0K= z$;R~bbk?}TpfDjfB&aiQ$VA}s?P}xPERJG{kxk5~R`iRS(SK5d+Xs9swCozZISbnS zk!)I0>t=A<-^z(cmSFz3=jZ23u13X><0b)P)^1T_))Kr`e!-pb#q&J*Q`p+B6la%C zuVl&0duN<;uOsB3%T9Fp8t{ED108<+W(nOZd?gDnfNBC3>M8WE61$So|P zVvqH0SNtDTcsUdzaMDpT=Ty0pDHHNL@Z0w$Y`XO z2M-_r1S+GaH%pz#Uy0*w$Vdl=X=rQXEzO}d6J^R6zjM1u&c9vYLvLp?W7w(?np9x1 zE_0JSAJCPB%i7p*Wvg)pn5T`8k3-uR?*NT|J`eS#_#54p>!p(mLDvmc-3o0mX*mp_ zN*AeS<>#^-{S%W<*mz^!X$w_2dHWpcJ6^j64qFBft-o}o_Vx80o0>}Du;>kLts;$8 zC`7q$QI(dKYG`Wa8#wl@V4jVWBRGQ@1dr-hstpQL)Tl+aqVpGpbSfN>5i&QMXfiZ> zaA?T1VGe?rpQ@;+pkrVdd{klI&jVS@I5_iz!=UMpTsa~mBga?1r}aRBm1WS;TT*s0f0lY=JBl66Upy)-k4J}lh=P^8(SXk~0xW=T9v*B|gzIhN z>qsO7dFd~mgxAy4V?&)=5ieYq?zi?ZEoj)&2o)RLy=@hbCRcfT5jigwtQGE{L*8<@Yd{zg;CsL5mvzfDY}P-wos_6PfprFVaeqNE%h zKZhLtcQld;ZD+>=nqN~>GvROfueSzJD&BE*}XfU|H&(FssBqY=hPCt`d zH?@s2>I(|;fcW&YM6#V#!kUIP8$Nkdh0A(bEVj``-AAyYgwY~jB zT|I7Bf@%;7aL7Wf4dZ%VqF$eiaC38OV6oy3Z#TER2G+fOCd9Iaoy6aLYbPTN{XRPz z;U!V|vBf%H!}52L2gH_+j;`bTcQRXB+y9onc^wLm5wi3-Be}U>k_u>2Eg$=k!(l@I zcCg+flakT2Nej3i0yn+g+}%NYb?ta;R?(g5SnwsQ49U8Wng8d|{B+lyRcEDvR3+`O{zfmrmvFrL6acVP%yG98X zo&+VBg@px@i)%o?dG(`T;n*$S5*rnyiR#=wW}}GsAcfyQpE|>a{=$Hjg=-*_K;UtD z#z-)AXwSRY?OPefw^iI+ z)AXz#PfEjlwTes|_{sB?4(O@fg0AJ^g8gP}ex9Ucf*@_^J(s_5jJV}c)s$`Myn|Kd z$6>}#q^n{4vN@+Os$m7KV+`}c%4)4pv@06af4-x5#wj!KKb%caK{A&Y#Rfs z-po?Dcb1({W=6FKIUirH&(yg=*6aLCekcKwyfK^JN5{wcA3nhO(o}SK#!CINhI`-I z1)6&n7O&ZmyFMuNwvEic#IiOAwNkR=u5it{B9n2sAJV5pNhar=j5`*N!Na;c7g!l$ z3aYBqUkqqTJ=Re-;)s!EOeij=7SQZ3Hq}ZRds%IM*PtM$wV z@;rlc*NRK7i3y5BETSKuumEN`Xu_8GP1Ri=OKQ$@I^ko8>H6)4rjiG5{VBM>B|%`&&s^)jS|-_95&yc=GqjNo{zFkw%%HHhS~e=s zD#sfS+-?*t|J!+ozP6KvtOl!R)@@-z24}`9{QaVLD^9VCSR2b`b!KC#o;Ki<+wXB6 zx3&O0LOWcg4&rv4QG0)4yb}7BFSEg~=IR5#ZRj8kg}dS7_V&^%#Do==#`u zpy6{ox?jWuR(;pg+f@mT>#HGWHAJRRDDDv~@(IDw&R>9643kK#HN`!1vBJHnC+RM&yIh8{gG2q zA%e*U3|N0XSRa~oX-3EAneep)@{h2vvd3Xvy$7og(sayr@95+e6~Xvi1tUqnIxoIH zVWo*OwYElb#uyW{Imam6f2rGbjR!Y3`#gPqkv57dB6K^wRGxc9B(t|aYDGS=m$&S!NmCtrMMaUg(c zc2qC=2Z`EEFMW-me5B)24AqF*bV5Dr-M5ig(l-WPS%CgaPzs6p_gnCIvTJ=Y<6!gT zVt@AfYCzjjsMEGi=rDQHo0yc;HqoRNnNFeWZgcm?f;cp(6CNylj36DoL(?TS7eU#+ z7&mfr#y))+CJOXQKUMZ7QIdS9@#-}7y2K1{8)cCt0~-X0O!O?Qx#E4Og+;A2SjalQ zs7r?qn0H044=sDN$SRG$arw~n=+T_DNdSrarmu)V6@|?1-ZB#hRn`uilTGPJ@fqEy zGt(f0B+^JDP&f=r{#Y_wi#AVDf-y!RIXU^0jXsFpf>=Ji*TeqSY!H~AMbJdCGLhC) zn7Rx+sXw6uYj;WRYrLd^5IZq@6JI1C^YkgnedZEYy<&4(z%Q$5yv#Boo{AH8n$a zhb4Y3PWdr269&?V%uI$xMcUrMzl=;w<_nm*qr=c3Rl@i5wWB;e-`t7D&c-mcQl7x! zZWB`UGcw=Y2=}~wzrfLx=uet<;m3~=8I~ZRuzvMQUQdr+yTV|ATf1Uuomr__nDf=X zZ3WYJtHp_ri(}SQAPjv+Y+0=fH4krOP@S&=zZ-t1jW1o@}z;xk8 z(Nz1co&El^HK^NrhVHa-_;&88vTU>_J33=%{if;BEY*J#1n59=07jrGQ#IP>@u#3A z;!q+E1Rj3ZJ+!4bq9F8PXJ@yMgZL;>&gYA0%_Kbi8?S=XGM~dnQZQ!yBSgcZhY96H zrWnU;k)qy`rX&&xlDyA%(a1Hhi5CWkmg(`Gb%m(HKi-7Z!LKGRP_B8@`7&hdDy5n= z`OIxqxiVfX@OX1p(mQu>0Ai*v_cTMiw4qRt3~NBvr9oBy0)r>w3p~V0SCm=An6@3n)>@z!|o-$HvDK z|3D2ZMJkLE5loMKl6R^ez@Zz%S$&mbeoqH5`Bb){Ei21q&VP)hWS2tjShfFtGE+$z zzCR$P#uktu+#!w)cX!lWN1XU%K-r=s{|j?)Akf@q#3b#{6cZCuJ~gCxuMXRmI$nGtnH+-h z+GEi!*X=AP<|fG`1>MBdTb?28JYc=fGvAi2I<$B(rs$;eoJCyR6_bc~p!XR@O-+sD z=eH`-ye})I5ic1eL~TDmtfJ|8`0VJ*Yr=hNCd)G1p2MMz4C3^Mj?7;!w|Ly%JqmuW zlIEW^Ft%z?*|fpXda>Jr^1noFZEwFgVV%|*XhH@acv8rdGxeEX{M$(vG{Zw+x(ei@ zmfXb22}8-?Fi`vo-YVrTH*C?a8%M=Hv9MqVH7H^J$KsD?>!SFZ;ZsvnHr_gn=7acz z#W?0eCdVhVMWN12VV^$>WlQ?f;P^{(&pYTops|btm6aj>_Uz+hqpGwB)vWp0Cf5y< zft8-je~nn?W11plq}N)4A{l8I7$!ks_x$PXW-2XaRFswX_BnF{R#6YIwMhAgd5F9X zGmwdadS6(a^fjHtXg8=l?Rc0Sm%hk6E9!5cLVloEy4eh(=FwgP`)~I^5~pBEWo+F6 zSf2ncyMurJN91#cJTy_u8Y}@%!bq1RkGC~-bV@SXRd4F{R-*V`bS+6;W5vZ(&+I<9$;-V|eNfLa5n-6% z2(}&uGRF;p92eS*sE*oR$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(| z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4PdpwWDop%^}n;dD#K4s#DYA8SHZ z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^WYu2u5kubqmwp%drJ6 z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d} z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k&YOi-3|1QKB z z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zl&#s4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@QS0TEL_?njX|@vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6# z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f# zuT7fvjSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC zC}~H#WXlkUW*H5CDOo<)#x7%RY)A;ShGhI5s*#cRDA8YgqG(HeKDx+#(ZQ?386dv! zlXCO)w91~Vw4AmOcATuV653fa9R$fyK8ul%rG z-wfS zihugoZyr38Im?Zuh6@RcF~t1anQu7>#lPpb#}4cOA!EM11`%f*07RqOVkmX{p~KJ9 z^zP;K#|)$`^Rb{rnHGH{~>1(fawV0*Z#)}M`m8-?ZJV<+e}s9wE# z)l&az?w^5{)`S(%MRzxdNqrs1n*-=jS^_jqE*5XDrA0+VE`5^*p3CuM<&dZEeCjoz zR;uu_H9ZPZV|fQq`Cyw4nscrVwi!fE6ciMmX$!_hN7uF;jjKG)d2@aC4ropY)8etW=xJvni)8eHi`H$%#zn^WJ5NLc-rqk|u&&4Z6fD_m&JfSI1Bvb?b<*n&sfl0^t z=HnmRl`XrFvMKB%9}>PaA`m-fK6a0(8=qPkWS5bb4=v?XcWi&hRY?O5HdulRi4?fN zlsJ*N-0Qw+Yic@s0(2uy%F@ib;GjXt01Fmx5XbRo6+n|pP(&nodMoap^z{~q ziEeaUT@Mxe3vJSfI6?uLND(CNr=#^W<1b}jzW58bIfyWTDle$mmS(|x-0|2UlX+9k zQ^EX7Nw}?EzVoBfT(-LT|=9N@^hcn-_p&sqG z&*oVs2JSU+N4ZD`FhCAWaS;>|wH2G*Id|?pa#@>tyxX`+4HyIArWDvVrX)2WAOQff z0qyHu&-S@i^MS-+j--!pr4fPBj~_8({~e1bfcl0wI1kaoN>mJL6KUPQm5N7lB(ui1 zE-o%kq)&djzWJ}ob<-GfDlkB;F31j-VHKvQUGQ3sp`CwyGJk_i!y^sD0fqC@$9|jO zOqN!r!8-p==F@ZVP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html new file mode 100644 index 000000000000..0224d32fcc43 --- /dev/null +++ b/product_multi_price/static/description/index.html @@ -0,0 +1,465 @@ + + + + + + +Product Multi Price + + + +
+

Product Multi Price

+ + +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

+

This module allows to set multiple prices to products and base pricelist +rules on them.

+

Table of contents

+ +
+

Configuration

+

To configure multiple prices you need to set multi prices field names first. +To do so, you need admin permissions. Then go to:

+
    +
  1. Settings > General Settings > Technical > Database Structure > +Price Field Names
  2. +
  3. Create the multi price fields you need.
  4. +
+

If you have multiple companies, you can assign independet field sets for each +one.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to the product page.
  2. +
  3. In the general tab, there’s a list called Prices.
  4. +
  5. You can add one for every multiple price field name available.
  6. +
+

To base pricelist rules on that fields, in the pricelist:

+
    +
  1. Add a rule and choose formula as the computing method.
  2. +
  3. In the Based on dropdown list you can select Multiple Prices.
  4. +
  5. A new list appear: Multiple Price Field Name. Pick the one you need.
  6. +
  7. Configure the formula.
  8. +
  9. Now the rule is based on that price for the products that have it +configured. Otherwise, it will return 0.
  10. +
+
+
+

Known issues / Roadmap

+
    +
  • Add mechanisms that allow to set multiprices values from external flows. For +example: having AVCO, FIFO and Standard prices computed simultaneously in +this table.
  • +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa
      +
    • David Vidal
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/product-attribute project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/product_multi_price/tests/__init__.py b/product_multi_price/tests/__init__.py new file mode 100644 index 000000000000..03b7c618dfc8 --- /dev/null +++ b/product_multi_price/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_multi_price diff --git a/product_multi_price/tests/test_product_multi_price.py b/product_multi_price/tests/test_product_multi_price.py new file mode 100644 index 000000000000..fafcb0600d67 --- /dev/null +++ b/product_multi_price/tests/test_product_multi_price.py @@ -0,0 +1,119 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests.common import SavepointCase + + +class TestProductMultiPrice(SavepointCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.price_name_obj = cls.env['product.multi.price.name'] + cls.price_field_1 = cls.price_name_obj.create({'name': 'test_field_1'}) + cls.price_field_2 = cls.price_name_obj.create({'name': 'test_field_2'}) + prod_tmpl_obj = cls.env['product.template'] + product_obj = cls.env['product.product'] + cls.prod_1 = prod_tmpl_obj.create({ + 'name': 'Test Product Template', + 'price_ids': [ + (0, 0, { + 'name': cls.price_field_1.id, + 'price': 5.5, + }), + (0, 0, { + 'name': cls.price_field_2.id, + 'price': 20.0, + }), + ], + }) + cls.prod_att_1 = cls.env['product.attribute'].create({'name': 'Color'}) + cls.prod_attr1_v1 = cls.env['product.attribute.value'].create({ + 'name': 'red', 'attribute_id': cls.prod_att_1.id}) + cls.prod_attr1_v2 = cls.env['product.attribute.value'].create({ + 'name': 'blue', 'attribute_id': cls.prod_att_1.id}) + cls.prod_2 = prod_tmpl_obj.create({ + 'name': 'Test Product 2 With Variants', + 'attribute_line_ids': [(0, 0, { + 'attribute_id': cls.prod_att_1.id, + })] + }) + cls.prod_prod_2_1 = product_obj.create({ + 'product_tmpl_id': cls.prod_2.id, + 'attribute_value_ids': [(6, 0, [cls.prod_attr1_v1.id])], + 'price_ids': [ + (0, 0, { + 'name': cls.price_field_1.id, + 'price': 6.6, + }), + (0, 0, { + 'name': cls.price_field_2.id, + 'price': 7.7, + }), + ], + }) + cls.prod_prod_2_2 = product_obj.create({ + 'product_tmpl_id': cls.prod_2.id, + 'attribute_value_ids': [(6, 0, [cls.prod_attr1_v2.id])], + 'price_ids': [ + (0, 0, { + 'name': cls.price_field_1.id, + 'price': 8.8, + }), + (0, 0, { + 'name': cls.price_field_2.id, + 'price': 9.9, + }), + ], + }) + cls.pricelist = cls.env['product.pricelist'].create({ + 'name': 'Test pricelist', + 'item_ids': [ + (0, 0, { + 'compute_price': 'formula', + 'base': 'multi_price', + 'multi_price_name': cls.price_field_1.id, + 'price_discount': 10, + 'applied_on': '3_global', + }), + ], + }) + + def test_product_multi_price(self): + """Multi Price for a product is computed based on the record name + passed by context""" + self.assertAlmostEqual(0, self.prod_1.multi_price) + price = self.prod_1.with_context( + multi_price_field='test_field_1').multi_price + self.assertAlmostEqual(price, 5.5) + price = self.prod_1.with_context( + multi_price_field='test_field_2').multi_price + self.assertAlmostEqual(price, 20.0) + # If the field doesn't exists or the product has no record for it + # a value of 0 will be returned. + price = self.prod_1.with_context( + multi_price_field='test_field_XXX').multi_price + self.assertAlmostEqual(price, 0) + # When a template has variants, no multiprice can be computed from it + price = self.prod_2.with_context( + multi_price_field='test_field_1').multi_price + self.assertAlmostEqual(price, 0.0) + # We should get it from the variants themselves + price = self.prod_prod_2_1.with_context( + multi_price_field='test_field_1').multi_price + self.assertAlmostEqual(price, 6.6) + price = self.prod_prod_2_2.with_context( + multi_price_field='test_field_1').multi_price + self.assertAlmostEqual(price, 8.8) + + def test_product_multi_price_pricelist(self): + """Pricelists based on multi prices for templates or variants""" + # import wdb; wdb.set_trace() + price = self.prod_1.with_context( + pricelist=self.pricelist.id).price + self.assertAlmostEqual(price, 4.95) + price = self.prod_prod_2_1.with_context( + pricelist=self.pricelist.id).price + self.assertAlmostEqual(price, 5.94) + price = self.prod_prod_2_2.with_context( + pricelist=self.pricelist.id).price + self.assertAlmostEqual(price, 7.92) diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml new file mode 100644 index 000000000000..cc6b9e50f782 --- /dev/null +++ b/product_multi_price/views/multi_price_views.xml @@ -0,0 +1,62 @@ + + + + product.multi.price + + + + + + + + + + + + product.multi.price + +
+ + + + + + + + +
+
+
+ + + product.multi.price + primary + + + + + bottom + + + + + + product.multi.price.name + + + + + + + + + + Price Field Names + product.multi.price.name + form + {} + + + + +
diff --git a/product_multi_price/views/product_pricelist_views.xml b/product_multi_price/views/product_pricelist_views.xml new file mode 100644 index 000000000000..e262ae80f9be --- /dev/null +++ b/product_multi_price/views/product_pricelist_views.xml @@ -0,0 +1,14 @@ + + + + + product.pricelist.item + + + + + + + + + diff --git a/product_multi_price/views/product_views.xml b/product_multi_price/views/product_views.xml new file mode 100644 index 000000000000..cc7e144f68df --- /dev/null +++ b/product_multi_price/views/product_views.xml @@ -0,0 +1,28 @@ + + + + + product.template + + + + + + + + + + + + product.product + + + + + + + + + + + From 19dc50af9f8effa020de580efd468917841aabd4 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 9 Apr 2020 10:56:00 +0200 Subject: [PATCH 02/26] [IMP] product_multi_price: Several improvements * Adjusted terminology * Better positioning of the prices list * Adjusted README * Remove useless constraint * Make multi price name translatable * Apply some guidelines * Remove compute proxy field as not finally used, and thus the ORM cache, but needed then to override initial computation. --- product_multi_price/README.rst | 11 ++-- product_multi_price/__manifest__.py | 2 +- product_multi_price/i18n/es.po | 57 +++++++------------ .../i18n/product_multi_price.pot | 38 +++---------- .../models/product_multi_price.py | 44 +------------- .../models/product_pricelist.py | 4 +- product_multi_price/models/product_product.py | 32 ++++------- .../models/product_template.py | 35 +++++------- product_multi_price/readme/CONFIGURE.rst | 3 +- product_multi_price/readme/USAGE.rst | 8 +-- .../static/description/index.html | 11 ++-- .../tests/test_product_multi_price.py | 28 --------- .../views/multi_price_views.xml | 3 +- product_multi_price/views/product_views.xml | 21 ++++--- 14 files changed, 85 insertions(+), 212 deletions(-) diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index 0e5cc0caa2bb..02f54886cba0 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -39,8 +39,7 @@ Configuration To configure multiple prices you need to set multi prices field names first. To do so, you need admin permissions. Then go to: -#. *Settings > General Settings > Technical > Database Structure > - Price Field Names* +#. *Settings > Technical > Database Structure > Price Field Names* #. Create the multi price fields you need. If you have multiple companies, you can assign independet field sets for each @@ -52,14 +51,14 @@ Usage To use this module, you need to: #. Go to the product page. -#. In the general tab, there's a list called *Prices*. -#. You can add one for every multiple price field name available. +#. In the general tab, there's a list called *Other Prices*. +#. You can add one for every price name available. To base pricelist rules on that fields, in the pricelist: #. Add a rule and choose *formula* as the computing method. -#. In the *Based on* dropdown list you can select *Multiple Prices*. -#. A new list appear: *Multiple Price Field Name*. Pick the one you need. +#. In the *Based on* dropdown list, select *Other Price*. +#. A new list appear: *Other Price Name*. Pick the one you need. #. Configure the formula. #. Now the rule is based on that price for the products that have it configured. Otherwise, it will return 0. diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 43ae4912d7e7..4a981581f678 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "11.0.1.0.0", + "version": "11.0.1.1.0", 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/product-attribute', diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index eb43d2e9f863..7b5b57e8e8a1 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -1,19 +1,21 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * product_multi_price +# * product_multi_price # msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-03 14:21+0000\n" -"PO-Revision-Date: 2020-04-03 14:21+0000\n" +"POT-Creation-Date: 2020-04-09 08:52+0000\n" +"PO-Revision-Date: 2020-04-09 10:54+0200\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: es\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" +"X-Generator: Poedit 2.0.6\n" #. module: product_multi_price #: sql_constraint:product.multi.price:0 @@ -44,12 +46,6 @@ msgstr "Creado en" msgid "Display Name" msgstr "Nombre mostrado" -#. module: product_multi_price -#: code:addons/product_multi_price/models/product_multi_price.py:91 -#, python-format -msgid "Field names can only contain characters, digits and underscores (up to 63)." -msgstr "Los nombres de campo solo pueden contener caracteres alfanuméricos, dígitos o guiones bajos (hasta 63)." - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id @@ -75,31 +71,23 @@ msgid "Last Updated on" msgstr "Última actualización en" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_multi_price -msgid "Multi Price" -msgstr "Multi Precio" +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +msgid "Name" +msgstr "Nombre" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name -msgid "Multiple Price Field Name" -msgstr "Nombre de Campo de Precio Múltiple" +msgid "Other Price Name" +msgstr "Nombre del otro precio" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_template_form_view -#: model:ir.ui.view,arch_db:product_multi_price.product_variant_easy_edit_view -msgid "Multiple Prices" -msgstr "Precios Múltiples" - -#. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name -msgid "Name" -msgstr "Nombre" +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +msgid "Other Prices" +msgstr "Otros precios" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids msgid "Price" msgstr "Precio" @@ -136,6 +124,7 @@ msgid "Product" msgstr "Producto" #. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view #: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" msgstr "Multi Precio de Producto" @@ -145,22 +134,11 @@ msgstr "Multi Precio de Producto" msgid "Product Multi Price Field Name" msgstr "Nombre de Campo de Multi Precio de Producto" -#. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view -msgid "Product Multi_price" -msgstr "Multi Precio de Producto" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template msgid "Product Template" msgstr "Plantilla de producto" -#. module: product_multi_price -#: code:addons/product_multi_price/models/product_multi_price.py:96 -#, python-format -msgid "The field name is used in the model, try another" -msgstr "El campo se utiliza en el modelo, escoja otro" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price msgid "product.multi.price" @@ -170,3 +148,6 @@ msgstr "product.multi.price" #: model:ir.model,name:product_multi_price.model_product_multi_price_name msgid "product.multi.price.name" msgstr "product.multi.price.name" + +#~ msgid "Multi Price" +#~ msgstr "Multi Precio" diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot index 2824a64a1530..bd0b44de3f3c 100644 --- a/product_multi_price/i18n/product_multi_price.pot +++ b/product_multi_price/i18n/product_multi_price.pot @@ -42,12 +42,6 @@ msgstr "" msgid "Display Name" msgstr "" -#. module: product_multi_price -#: code:addons/product_multi_price/models/product_multi_price.py:92 -#, python-format -msgid "Field names can only contain characters, digits and underscores (up to 63)." -msgstr "" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id @@ -73,31 +67,23 @@ msgid "Last Updated on" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_multi_price -msgid "Multi Price" +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +msgid "Name" msgstr "" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name -msgid "Multiple Price Field Name" +msgid "Other Price Name" msgstr "" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_template_form_view -#: model:ir.ui.view,arch_db:product_multi_price.product_variant_easy_edit_view -msgid "Multiple Prices" -msgstr "" - -#. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name -msgid "Name" +#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +msgid "Other Prices" msgstr "" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids msgid "Price" msgstr "" @@ -134,6 +120,7 @@ msgid "Product" msgstr "" #. module: product_multi_price +#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view #: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" msgstr "" @@ -143,22 +130,11 @@ msgstr "" msgid "Product Multi Price Field Name" msgstr "" -#. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view -msgid "Product Multi_price" -msgstr "" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template msgid "Product Template" msgstr "" -#. module: product_multi_price -#: code:addons/product_multi_price/models/product_multi_price.py:97 -#, python-format -msgid "The field name is used in the model, try another" -msgstr "" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price msgid "product.multi.price" diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index c858a8748ff8..40ab532b1ad8 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -1,7 +1,6 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models, tools -from odoo.exceptions import ValidationError +from odoo import api, fields, models from odoo.addons import decimal_precision as dp @@ -11,6 +10,7 @@ class ProductMultiPrice(models.Model): name = fields.Many2one( comodel_name='product.multi.price.name', required=True, + translate=True, ) product_id = fields.Many2one( comodel_name='product.product', @@ -56,43 +56,3 @@ def _get_company(self): ('multi_price_name_uniq', 'unique(name, company_id)', 'Prices Names must be unique per company'), ] - - @api.model - @tools.ormcache() - def _get_field_names(self): - return set([x.name for x in self.search([])]) - - @api.model - def create(self, vals): - res = super().create(vals) - self.clear_caches() - return res - - def write(self, vals): - res = super().write(vals) - if 'name' in vals: - self.clear_caches() - return res - - def unlink(self): - res = super().unlink() - self.clear_caches() - return res - - @api.constrains('name') - def _check_name(self): - """The target is to use multi price as if they were virtual fields - so we want to constrain the naming to the same rules""" - product_fields = list(self.env['product.product']._fields) - product_fields += list(self.env['product.template']._fields) - for field in self: - try: - models.check_pg_name(field.name) - except ValidationError: - msg = _( - "Field names can only contain characters, " - "digits and underscores (up to 63).") - raise ValidationError(msg) - if field in set(product_fields): - raise ValidationError(_( - "The field name is used in the model, try another")) diff --git a/product_multi_price/models/product_pricelist.py b/product_multi_price/models/product_pricelist.py index 8d1cfb6963df..67b71dd869c7 100644 --- a/product_multi_price/models/product_pricelist.py +++ b/product_multi_price/models/product_pricelist.py @@ -29,9 +29,9 @@ class ProductPricelistItem(models.Model): _inherit = 'product.pricelist.item' base = fields.Selection( - selection_add=[('multi_price', 'Multiple Price Field')], + selection_add=[('multi_price', 'Other Price')], ) multi_price_name = fields.Many2one( comodel_name='product.multi.price.name', - string="Multiple Price Field Name", + string="Other Price Name", ) diff --git a/product_multi_price/models/product_product.py b/product_multi_price/models/product_product.py index 03a042a0fb1a..cfa5d41277db 100644 --- a/product_multi_price/models/product_product.py +++ b/product_multi_price/models/product_product.py @@ -1,7 +1,6 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models, fields, tools -from odoo.addons import decimal_precision as dp class ProductProduct(models.Model): @@ -10,11 +9,7 @@ class ProductProduct(models.Model): price_ids = fields.One2many( comodel_name='product.multi.price', inverse_name='product_id', - ) - multi_price = fields.Float( - digits=dp.get_precision('Product Price'), - compute='_compute_multi_price', - groups="base.group_user", + string="Other Prices", ) def _get_multiprice_pricelist_price(self, rule): @@ -51,18 +46,13 @@ def _get_multiprice_pricelist_price(self, rule): price = min(price, price_limit + price_max_margin) return price - def _compute_multi_price(self): - """Use multi_price field as the proxy for any of the registered - multi price fields on the product passing it by context""" - multi_price_field = self.env.context.get('multi_price_field', False) - if not multi_price_field: - self.update({'multi_price': 0}) - return - prices_list = self.env['product.multi.price'].search_read([ - ('name.name', '=', multi_price_field), - ('product_id', 'in', self.ids), - ('company_id', '=', self.env.user.company_id.id) - ], ['product_id', 'price'], limit=1) - prices_dict = {x['product_id'][0]: x['price'] for x in prices_list} - for product in self: - product.multi_price = prices_dict.get(product.id, 0.0) + def price_compute(self, price_type, uom=False, currency=False, + company=False): + """Return temporary prices when computation is done for multi price for + avoiding error on super method. We will later fill these with the + correct values. + """ + if price_type == 'multi_price': + return dict.fromkeys(self.ids, 1.0) + return super().price_compute( + price_type, uom=uom, currency=currency, company=company) diff --git a/product_multi_price/models/product_template.py b/product_multi_price/models/product_template.py index a7c6f670964b..996fac1a4dad 100644 --- a/product_multi_price/models/product_template.py +++ b/product_multi_price/models/product_template.py @@ -1,7 +1,6 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models -from odoo.addons import decimal_precision as dp class ProductTemplate(models.Model): @@ -10,13 +9,8 @@ class ProductTemplate(models.Model): price_ids = fields.One2many( comodel_name='product.multi.price', compute='_compute_price_ids', - inverse='_set_price_ids', - ) - multi_price = fields.Float( - digits=dp.get_precision('Product Price'), - compute='_compute_multi_price', - groups="base.group_user", - readonly=True, + inverse='_inverse_price_ids', + string="Other Prices", ) @api.depends('product_variant_ids', @@ -26,7 +20,7 @@ def _compute_price_ids(self): if len(p.product_variant_ids) == 1: p.price_ids = p.product_variant_ids.price_ids - def _set_price_ids(self): + def _inverse_price_ids(self): for p in self: if len(p.product_variant_ids) == 1: p.product_variant_ids.price_ids = p.price_ids @@ -37,18 +31,6 @@ def _get_multiprice_pricelist_price(self, rule): self.product_variant_ids._get_multiprice_pricelist_price(rule)) return 0 - @api.depends('product_variant_ids', 'product_variant_ids.multi_price') - def _compute_multi_price(self): - """Use multi_price field as the frontend for any of the registered - multi price fields on the product passing it by context""" - multi_price_field = self.env.context.get('multi_price_field', False) - if not multi_price_field: - self.update({'multi_price': 0}) - return - for p in self: - if len(p.product_variant_ids) == 1: - p.multi_price = p.product_variant_ids.multi_price - @api.model def create(self, vals): product = super().create(vals) @@ -57,3 +39,14 @@ def create(self, vals): 'price_ids': vals.get('price_ids'), }) return product + + def price_compute(self, price_type, uom=False, currency=False, + company=False): + """Return temporary prices when computation is done for multi price for + avoiding error on super method. We will later fill these with the + correct values. + """ + if price_type == 'multi_price': + return dict.fromkeys(self.ids, 1.0) + return super().price_compute( + price_type, uom=uom, currency=currency, company=company) diff --git a/product_multi_price/readme/CONFIGURE.rst b/product_multi_price/readme/CONFIGURE.rst index 91472fd43690..79a9001b2f91 100644 --- a/product_multi_price/readme/CONFIGURE.rst +++ b/product_multi_price/readme/CONFIGURE.rst @@ -1,8 +1,7 @@ To configure multiple prices you need to set multi prices field names first. To do so, you need admin permissions. Then go to: -#. *Settings > General Settings > Technical > Database Structure > - Price Field Names* +#. *Settings > Technical > Database Structure > Price Field Names* #. Create the multi price fields you need. If you have multiple companies, you can assign independet field sets for each diff --git a/product_multi_price/readme/USAGE.rst b/product_multi_price/readme/USAGE.rst index 7c796fa82a8b..409ae850807f 100644 --- a/product_multi_price/readme/USAGE.rst +++ b/product_multi_price/readme/USAGE.rst @@ -1,14 +1,14 @@ To use this module, you need to: #. Go to the product page. -#. In the general tab, there's a list called *Prices*. -#. You can add one for every multiple price field name available. +#. In the general tab, there's a list called *Other Prices*. +#. You can add one for every price name available. To base pricelist rules on that fields, in the pricelist: #. Add a rule and choose *formula* as the computing method. -#. In the *Based on* dropdown list you can select *Multiple Prices*. -#. A new list appear: *Multiple Price Field Name*. Pick the one you need. +#. In the *Based on* dropdown list, select *Other Price*. +#. A new list appear: *Other Price Name*. Pick the one you need. #. Configure the formula. #. Now the rule is based on that price for the products that have it configured. Otherwise, it will return 0. diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index 0224d32fcc43..c5bc06401be0 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -390,8 +390,7 @@

Configuration

To configure multiple prices you need to set multi prices field names first. To do so, you need admin permissions. Then go to:

    -
  1. Settings > General Settings > Technical > Database Structure > -Price Field Names
  2. +
  3. Settings > Technical > Database Structure > Price Field Names
  4. Create the multi price fields you need.

If you have multiple companies, you can assign independet field sets for each @@ -402,14 +401,14 @@

Usage

To use this module, you need to:

  1. Go to the product page.
  2. -
  3. In the general tab, there’s a list called Prices.
  4. -
  5. You can add one for every multiple price field name available.
  6. +
  7. In the general tab, there’s a list called Other Prices.
  8. +
  9. You can add one for every price name available.

To base pricelist rules on that fields, in the pricelist:

  1. Add a rule and choose formula as the computing method.
  2. -
  3. In the Based on dropdown list you can select Multiple Prices.
  4. -
  5. A new list appear: Multiple Price Field Name. Pick the one you need.
  6. +
  7. In the Based on dropdown list, select Other Price.
  8. +
  9. A new list appear: Other Price Name. Pick the one you need.
  10. Configure the formula.
  11. Now the rule is based on that price for the products that have it configured. Otherwise, it will return 0.
  12. diff --git a/product_multi_price/tests/test_product_multi_price.py b/product_multi_price/tests/test_product_multi_price.py index fafcb0600d67..0ad1c4411f63 100644 --- a/product_multi_price/tests/test_product_multi_price.py +++ b/product_multi_price/tests/test_product_multi_price.py @@ -78,36 +78,8 @@ def setUpClass(cls): ], }) - def test_product_multi_price(self): - """Multi Price for a product is computed based on the record name - passed by context""" - self.assertAlmostEqual(0, self.prod_1.multi_price) - price = self.prod_1.with_context( - multi_price_field='test_field_1').multi_price - self.assertAlmostEqual(price, 5.5) - price = self.prod_1.with_context( - multi_price_field='test_field_2').multi_price - self.assertAlmostEqual(price, 20.0) - # If the field doesn't exists or the product has no record for it - # a value of 0 will be returned. - price = self.prod_1.with_context( - multi_price_field='test_field_XXX').multi_price - self.assertAlmostEqual(price, 0) - # When a template has variants, no multiprice can be computed from it - price = self.prod_2.with_context( - multi_price_field='test_field_1').multi_price - self.assertAlmostEqual(price, 0.0) - # We should get it from the variants themselves - price = self.prod_prod_2_1.with_context( - multi_price_field='test_field_1').multi_price - self.assertAlmostEqual(price, 6.6) - price = self.prod_prod_2_2.with_context( - multi_price_field='test_field_1').multi_price - self.assertAlmostEqual(price, 8.8) - def test_product_multi_price_pricelist(self): """Pricelists based on multi prices for templates or variants""" - # import wdb; wdb.set_trace() price = self.prod_1.with_context( pricelist=self.pricelist.id).price self.assertAlmostEqual(price, 4.95) diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml index cc6b9e50f782..ea4b6385a981 100644 --- a/product_multi_price/views/multi_price_views.xml +++ b/product_multi_price/views/multi_price_views.xml @@ -15,7 +15,7 @@ product.multi.price -
    + @@ -31,6 +31,7 @@ product.multi.price primary + diff --git a/product_multi_price/views/product_views.xml b/product_multi_price/views/product_views.xml index cc7e144f68df..8fce79c84dc0 100644 --- a/product_multi_price/views/product_views.xml +++ b/product_multi_price/views/product_views.xml @@ -5,10 +5,12 @@ product.template - - - - + + @@ -17,11 +19,12 @@ product.product - - - - - + + + From 5238e17353a1caab8ca7c8f271f9e96392963b60 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 17 Apr 2020 15:41:02 +0200 Subject: [PATCH 03/26] [FIX] product_multi_price: portal and public user error When a not internal user (portal/public) with a pricelist that contains multi price rules tries to see a page with a product affected for such rules, an exception raises due to lack of permissions over product.multi.price model. --- product_multi_price/__manifest__.py | 2 +- product_multi_price/models/product_product.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 4a981581f678..62620d5ee02a 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "11.0.1.1.0", + "version": "11.0.1.1.1", 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/product-attribute', diff --git a/product_multi_price/models/product_product.py b/product_multi_price/models/product_product.py index cfa5d41277db..6dff9b728fd8 100644 --- a/product_multi_price/models/product_product.py +++ b/product_multi_price/models/product_product.py @@ -16,7 +16,7 @@ def _get_multiprice_pricelist_price(self, rule): """Method for getting the price from multi price.""" self.ensure_one() company = rule.company_id or self.env.user.company_id - price = self.env['product.multi.price'].search([ + price = self.env['product.multi.price'].sudo().search([ ('company_id', '=', company.id), ('name', '=', rule.multi_price_name.id), ('product_id', '=', self.id), From aa9f5863eefe394dbe6cb352285fd48ddeb92eed Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 Apr 2020 11:06:42 +0200 Subject: [PATCH 04/26] [FIX] product_multi_price: Widget selection doesn't work inside tree view We mimick it putting regular widget with options no_open and no_create. --- product_multi_price/__manifest__.py | 3 ++- product_multi_price/views/multi_price_views.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 62620d5ee02a..e8af2759d36c 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -1,8 +1,9 @@ # Copyright 2020 Tecnativa - David Vidal +# Copyright 2020 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "11.0.1.1.1", + "version": "11.0.1.2.0", 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/product-attribute', diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml index ea4b6385a981..e49ba0dd6427 100644 --- a/product_multi_price/views/multi_price_views.xml +++ b/product_multi_price/views/multi_price_views.xml @@ -5,7 +5,7 @@ - + From 23e1832c9d8fca115d4d686a880c2984430f36da Mon Sep 17 00:00:00 2001 From: david Date: Thu, 25 Jun 2020 15:54:54 +0200 Subject: [PATCH 05/26] [MIG] product_multi_price: Migration to 12.0 --- product_multi_price/README.rst | 10 +- product_multi_price/__manifest__.py | 2 +- product_multi_price/i18n/es.po | 136 +++++++++++++----- .../i18n/product_multi_price.pot | 116 ++++++++++----- .../models/product_multi_price.py | 2 + product_multi_price/models/product_product.py | 2 +- .../models/product_template.py | 9 +- .../static/description/index.html | 6 +- .../tests/test_product_multi_price.py | 17 ++- .../views/product_pricelist_views.xml | 2 +- 10 files changed, 209 insertions(+), 93 deletions(-) diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index 02f54886cba0..fdf808c53553 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -14,13 +14,13 @@ Product Multi Price :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github - :target: https://github.com/OCA/product-attribute/tree/11.0/product_multi_price + :target: https://github.com/OCA/product-attribute/tree/12.0/product_multi_price :alt: OCA/product-attribute .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-attribute-11-0/product-attribute-11-0-product_multi_price + :target: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_multi_price :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/135/11.0 + :target: https://runbot.odoo-community.org/runbot/135/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -76,7 +76,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -109,6 +109,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/product-attribute `_ project on GitHub. +This module is part of the `OCA/product-attribute `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index e8af2759d36c..d35ddf0157c3 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "11.0.1.2.0", + "version": "12.0.1.0.0", 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/product-attribute', diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index 7b5b57e8e8a1..bf1c2557fc61 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -23,76 +23,126 @@ msgid "A field name cannot be assigned to a product twice for the same company" msgstr "No puede haber un nombre de campo repetido en la misma compañía" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_company_id -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_company_id +#: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base +msgid "" +"Base price for computation.\n" +"Public Price: The base price will be the Sale/public Price.\n" +"Cost Price : The base price will be the cost price.\n" +"Other Pricelist : Computation of the base price based on another Pricelist." +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base +#, fuzzy +#| msgid "Created on" +msgid "Based on" +msgstr "Creado en" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id msgid "Company" msgstr "Compañía" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_uid -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_uid +#: selection:product.pricelist.item,base:0 +msgid "Cost" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Cost Price Tax Included" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid msgid "Created by" msgstr "Creado por" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_date -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_date msgid "Created on" msgstr "Creado en" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_display_name -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name msgid "Display Name" msgstr "Nombre mostrado" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id msgid "ID" msgstr "ID (identificación)" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price___last_update -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name___last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name____last_update msgid "Last Modified on" msgstr "Última modificación en" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_uid -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_uid msgid "Last Updated by" msgstr "Última actualización de" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_date -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_date msgid "Last Updated on" msgstr "Última actualización en" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "Multi Price Record Options" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name msgid "Name" msgstr "Nombre" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name +#: selection:product.pricelist.item,base:0 +#, fuzzy +#| msgid "Other Prices" +msgid "Other Price" +msgstr "Otros precios" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name msgid "Other Price Name" msgstr "Nombre del otro precio" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +#: selection:product.pricelist.item,base:0 +#, fuzzy +#| msgid "Other Prices" +msgid "Other Pricelist" +msgstr "Otros precios" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" msgstr "Otros precios" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price +#: selection:product.pricelist.item,base:0 +msgid "Partner Prices on the product form" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" msgstr "Precio" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name msgid "Price Field Name" msgstr "Nombre de Campo de Precio" @@ -109,7 +159,9 @@ msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -msgid "Pricelist item" +#, fuzzy +#| msgid "Pricelist item" +msgid "Pricelist Item" msgstr "Elemento de Tarifa" #. module: product_multi_price @@ -117,37 +169,49 @@ msgstr "Elemento de Tarifa" msgid "Prices Names must be unique per company" msgstr "Los Nombres de Precio deben ser únicos para cada compañía" +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Prices based on supplier info" +msgstr "" + #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_product_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id msgid "Product" msgstr "Producto" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" msgstr "Multi Precio de Producto" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view msgid "Product Multi Price Field Name" msgstr "Nombre de Campo de Multi Precio de Producto" +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price +#, fuzzy +#| msgid "Product Multi Price" +msgid "Product Multiple Prices" +msgstr "Multi Precio de Producto" + #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template msgid "Product Template" msgstr "Plantilla de producto" #. module: product_multi_price -#: model:ir.model,name:product_multi_price.model_product_multi_price -msgid "product.multi.price" -msgstr "product.multi.price" +#: selection:product.pricelist.item,base:0 +#, fuzzy +#| msgid "Multi Price" +msgid "Public Price" +msgstr "Multi Precio" -#. module: product_multi_price -#: model:ir.model,name:product_multi_price.model_product_multi_price_name -msgid "product.multi.price.name" -msgstr "product.multi.price.name" +#~ msgid "product.multi.price" +#~ msgstr "product.multi.price" -#~ msgid "Multi Price" -#~ msgstr "Multi Precio" +#~ msgid "product.multi.price.name" +#~ msgstr "product.multi.price.name" diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot index bd0b44de3f3c..c47ad504e617 100644 --- a/product_multi_price/i18n/product_multi_price.pot +++ b/product_multi_price/i18n/product_multi_price.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -19,76 +19,119 @@ msgid "A field name cannot be assigned to a product twice for the same company" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_company_id -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_company_id +#: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base +msgid "Base price for computation.\n" +"Public Price: The base price will be the Sale/public Price.\n" +"Cost Price : The base price will be the cost price.\n" +"Other Pricelist : Computation of the base price based on another Pricelist." +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base +msgid "Based on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id msgid "Company" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_uid -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_uid +#: selection:product.pricelist.item,base:0 +msgid "Cost" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Cost Price Tax Included" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid msgid "Created by" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_create_date -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_date msgid "Created on" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_display_name -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name msgid "Display Name" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_id -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id msgid "ID" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price___last_update -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name___last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name____last_update msgid "Last Modified on" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_uid -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_uid msgid "Last Updated by" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_write_date -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_date msgid "Last Updated on" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "Multi Price Record Options" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name msgid "Name" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item_multi_price_name +#: selection:product.pricelist.item,base:0 +msgid "Other Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name msgid "Other Price Name" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_product_price_ids -#: model:ir.model.fields,field_description:product_multi_price.field_product_template_price_ids +#: selection:product.pricelist.item,base:0 +msgid "Other Pricelist" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_price +#: selection:product.pricelist.item,base:0 +msgid "Partner Prices on the product form" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" msgstr "" #. module: product_multi_price -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name msgid "Price Field Name" msgstr "" @@ -105,7 +148,7 @@ msgstr "" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -msgid "Pricelist item" +msgid "Pricelist Item" msgstr "" #. module: product_multi_price @@ -113,35 +156,40 @@ msgstr "" msgid "Prices Names must be unique per company" msgstr "" +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Prices based on supplier info" +msgstr "" + #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product -#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_product_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id msgid "Product" msgstr "" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" msgstr "" #. module: product_multi_price -#: model:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view msgid "Product Multi Price Field Name" msgstr "" #. module: product_multi_price -#: model:ir.model,name:product_multi_price.model_product_template -msgid "Product Template" +#: model:ir.model,name:product_multi_price.model_product_multi_price +msgid "Product Multiple Prices" msgstr "" #. module: product_multi_price -#: model:ir.model,name:product_multi_price.model_product_multi_price -msgid "product.multi.price" +#: model:ir.model,name:product_multi_price.model_product_template +msgid "Product Template" msgstr "" #. module: product_multi_price -#: model:ir.model,name:product_multi_price.model_product_multi_price_name -msgid "product.multi.price.name" +#: selection:product.pricelist.item,base:0 +msgid "Public Price" msgstr "" diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index 40ab532b1ad8..8be0abf2db9c 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -6,6 +6,7 @@ class ProductMultiPrice(models.Model): _name = 'product.multi.price' + _description = "Product Multiple Prices" name = fields.Many2one( comodel_name='product.multi.price.name', @@ -36,6 +37,7 @@ class ProductMultiPrice(models.Model): class ProductMultiPriceName(models.Model): _name = 'product.multi.price.name' + _description = "Multi Price Record Options" @api.model def _get_company(self): diff --git a/product_multi_price/models/product_product.py b/product_multi_price/models/product_product.py index 6dff9b728fd8..e937bdccc573 100644 --- a/product_multi_price/models/product_product.py +++ b/product_multi_price/models/product_product.py @@ -26,7 +26,7 @@ def _get_multiprice_pricelist_price(self, rule): # method are atomic and we can't hack inside. # Verbatim copy of part of product.pricelist._compute_price_rule. qty_uom_id = self._context.get('uom') or self.uom_id.id - price_uom = self.env['product.uom'].browse([qty_uom_id]) + price_uom = self.env['uom.uom'].browse([qty_uom_id]) convert_to_price_uom = ( lambda price: self.uom_id._compute_price( price, price_uom)) diff --git a/product_multi_price/models/product_template.py b/product_multi_price/models/product_template.py index 996fac1a4dad..81be41bc417b 100644 --- a/product_multi_price/models/product_template.py +++ b/product_multi_price/models/product_template.py @@ -33,12 +33,15 @@ def _get_multiprice_pricelist_price(self, rule): @api.model def create(self, vals): - product = super().create(vals) + """Overwrite creation for rewriting the prices (if set and having only + one variant), after the variant creation, that is performed in super. + """ + template = super().create(vals) if vals.get('price_ids'): - product.write({ + template.write({ 'price_ids': vals.get('price_ids'), }) - return product + return template def price_compute(self, price_type, uom=False, currency=False, company=False): diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index c5bc06401be0..2a59ab2421dd 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -367,7 +367,7 @@

    Product Multi Price

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    This module allows to set multiple prices to products and base pricelist rules on them.

    Table of contents

    @@ -427,7 +427,7 @@

    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.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -455,7 +455,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/product-attribute project on GitHub.

    +

    This module is part of the OCA/product-attribute project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/product_multi_price/tests/test_product_multi_price.py b/product_multi_price/tests/test_product_multi_price.py index 0ad1c4411f63..bf8b90f0de72 100644 --- a/product_multi_price/tests/test_product_multi_price.py +++ b/product_multi_price/tests/test_product_multi_price.py @@ -12,7 +12,6 @@ def setUpClass(cls): cls.price_field_1 = cls.price_name_obj.create({'name': 'test_field_1'}) cls.price_field_2 = cls.price_name_obj.create({'name': 'test_field_2'}) prod_tmpl_obj = cls.env['product.template'] - product_obj = cls.env['product.product'] cls.prod_1 = prod_tmpl_obj.create({ 'name': 'Test Product Template', 'price_ids': [ @@ -35,11 +34,14 @@ def setUpClass(cls): 'name': 'Test Product 2 With Variants', 'attribute_line_ids': [(0, 0, { 'attribute_id': cls.prod_att_1.id, + 'value_ids': [(6, 0, [ + cls.prod_attr1_v1.id, cls.prod_attr1_v2.id + ])], })] }) - cls.prod_prod_2_1 = product_obj.create({ - 'product_tmpl_id': cls.prod_2.id, - 'attribute_value_ids': [(6, 0, [cls.prod_attr1_v1.id])], + cls.prod_prod_2_1 = cls.prod_2.product_variant_ids[0] + cls.prod_prod_2_2 = cls.prod_2.product_variant_ids[1] + cls.prod_prod_2_1.write({ 'price_ids': [ (0, 0, { 'name': cls.price_field_1.id, @@ -51,9 +53,7 @@ def setUpClass(cls): }), ], }) - cls.prod_prod_2_2 = product_obj.create({ - 'product_tmpl_id': cls.prod_2.id, - 'attribute_value_ids': [(6, 0, [cls.prod_attr1_v2.id])], + cls.prod_prod_2_2.write({ 'price_ids': [ (0, 0, { 'name': cls.price_field_1.id, @@ -74,8 +74,7 @@ def setUpClass(cls): 'multi_price_name': cls.price_field_1.id, 'price_discount': 10, 'applied_on': '3_global', - }), - ], + })], }) def test_product_multi_price_pricelist(self): diff --git a/product_multi_price/views/product_pricelist_views.xml b/product_multi_price/views/product_pricelist_views.xml index e262ae80f9be..419f96cf5ae5 100644 --- a/product_multi_price/views/product_pricelist_views.xml +++ b/product_multi_price/views/product_pricelist_views.xml @@ -6,7 +6,7 @@ - + From 56bc6388b81374667e14cfd9c145ea1949a4291e Mon Sep 17 00:00:00 2001 From: Ernesto Tejeda Date: Fri, 31 Jul 2020 12:13:46 -0400 Subject: [PATCH 06/26] [IMP] product_multi_price: add show multi-price access group. --- product_multi_price/README.rst | 6 ++- product_multi_price/__init__.py | 1 + product_multi_price/__manifest__.py | 3 +- product_multi_price/hooks.py | 13 +++++++ product_multi_price/i18n/es.po | 13 +++---- .../i18n/product_multi_price.pot | 5 +++ .../migrations/12.0.2.0.0/post-migration.py | 7 ++++ product_multi_price/readme/CONFIGURE.rst | 5 ++- product_multi_price/readme/CONTRIBUTORS.rst | 1 + .../security/multi_price_security.xml | 37 +++++++++++-------- .../static/description/index.html | 5 ++- product_multi_price/views/product_views.xml | 2 + 12 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 product_multi_price/hooks.py create mode 100644 product_multi_price/migrations/12.0.2.0.0/post-migration.py diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index fdf808c53553..9d7443c34946 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -42,9 +42,12 @@ To do so, you need admin permissions. Then go to: #. *Settings > Technical > Database Structure > Price Field Names* #. Create the multi price fields you need. -If you have multiple companies, you can assign independet field sets for each +If you have multiple companies, you can assign independent field sets for each one. +Note: 'Show multi prices' access group must be checked to be able to +add multiple prices in the product form view. + Usage ===== @@ -95,6 +98,7 @@ Contributors * David Vidal * Pedro M. Baeza + * Ernesto Tejeda Maintainers ~~~~~~~~~~~ diff --git a/product_multi_price/__init__.py b/product_multi_price/__init__.py index 0650744f6bc6..cc6b6354ad8f 100644 --- a/product_multi_price/__init__.py +++ b/product_multi_price/__init__.py @@ -1 +1,2 @@ from . import models +from .hooks import post_init_hook diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index d35ddf0157c3..a3f46cb6338c 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "12.0.1.0.0", + "version": "12.0.2.0.0", 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/product-attribute', @@ -22,5 +22,6 @@ 'demo': [ "demo/multi_price_demo_data.xml", ], + "post_init_hook": "post_init_hook", "installable": True, } diff --git a/product_multi_price/hooks.py b/product_multi_price/hooks.py new file mode 100644 index 000000000000..6c519a3d57f1 --- /dev/null +++ b/product_multi_price/hooks.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, SUPERUSER_ID + + +def post_init_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + group_id = env.ref('product_multi_price.group_show_multi_prices').id + default_user = env.ref('base.default_user') + user = env['res.users'].with_context(active_test=False).search( + [("share", "=", False)]) + (user - default_user).write({'groups_id': [(4, group_id, None)]}) diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index bf1c2557fc61..e63c39f92dcd 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -34,7 +34,6 @@ msgstr "" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base #, fuzzy -#| msgid "Created on" msgid "Based on" msgstr "Creado en" @@ -109,7 +108,6 @@ msgstr "Nombre" #. module: product_multi_price #: selection:product.pricelist.item,base:0 #, fuzzy -#| msgid "Other Prices" msgid "Other Price" msgstr "Otros precios" @@ -121,7 +119,6 @@ msgstr "Nombre del otro precio" #. module: product_multi_price #: selection:product.pricelist.item,base:0 #, fuzzy -#| msgid "Other Prices" msgid "Other Pricelist" msgstr "Otros precios" @@ -160,7 +157,6 @@ msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item #, fuzzy -#| msgid "Pricelist item" msgid "Pricelist Item" msgstr "Elemento de Tarifa" @@ -194,7 +190,6 @@ msgstr "Nombre de Campo de Multi Precio de Producto" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price #, fuzzy -#| msgid "Product Multi Price" msgid "Product Multiple Prices" msgstr "Multi Precio de Producto" @@ -206,12 +201,14 @@ msgstr "Plantilla de producto" #. module: product_multi_price #: selection:product.pricelist.item,base:0 #, fuzzy -#| msgid "Multi Price" msgid "Public Price" msgstr "Multi Precio" -#~ msgid "product.multi.price" -#~ msgstr "product.multi.price" +#. module: product_multi_price +#: model:res.groups,name:product_multi_price.group_show_multi_prices +#, fuzzy +msgid "Show multi prices" +msgstr "product.multi.price" #~ msgid "product.multi.price.name" #~ msgstr "product.multi.price.name" diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot index c47ad504e617..3fa5ca508597 100644 --- a/product_multi_price/i18n/product_multi_price.pot +++ b/product_multi_price/i18n/product_multi_price.pot @@ -193,3 +193,8 @@ msgstr "" msgid "Public Price" msgstr "" +#. module: product_multi_price +#: model:res.groups,name:product_multi_price.group_show_multi_prices +msgid "Show multi prices" +msgstr "" + diff --git a/product_multi_price/migrations/12.0.2.0.0/post-migration.py b/product_multi_price/migrations/12.0.2.0.0/post-migration.py new file mode 100644 index 000000000000..edf4a0f25ede --- /dev/null +++ b/product_multi_price/migrations/12.0.2.0.0/post-migration.py @@ -0,0 +1,7 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl +from odoo.addons.product_multi_price.hooks import post_init_hook + + +def migrate(cr, version): + post_init_hook(cr, False) diff --git a/product_multi_price/readme/CONFIGURE.rst b/product_multi_price/readme/CONFIGURE.rst index 79a9001b2f91..b61299a39013 100644 --- a/product_multi_price/readme/CONFIGURE.rst +++ b/product_multi_price/readme/CONFIGURE.rst @@ -4,5 +4,8 @@ To do so, you need admin permissions. Then go to: #. *Settings > Technical > Database Structure > Price Field Names* #. Create the multi price fields you need. -If you have multiple companies, you can assign independet field sets for each +If you have multiple companies, you can assign independent field sets for each one. + +Note: 'Show multi prices' access group must be checked to be able to +add multiple prices in the product form view. diff --git a/product_multi_price/readme/CONTRIBUTORS.rst b/product_multi_price/readme/CONTRIBUTORS.rst index ac6cb650339b..9eb6d6c6984b 100644 --- a/product_multi_price/readme/CONTRIBUTORS.rst +++ b/product_multi_price/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * David Vidal * Pedro M. Baeza + * Ernesto Tejeda diff --git a/product_multi_price/security/multi_price_security.xml b/product_multi_price/security/multi_price_security.xml index ba093f4594a1..dd7c04826ce3 100644 --- a/product_multi_price/security/multi_price_security.xml +++ b/product_multi_price/security/multi_price_security.xml @@ -1,18 +1,23 @@ - - - - Multiple Price multi-company - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - - - - Multiple Price Field Name multi-company - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - - + + + + Show multi prices + + + + + + Multiple Price multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + Multiple Price Field Name multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index 2a59ab2421dd..c357803472d6 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -393,8 +393,10 @@

    Configuration

  13. Settings > Technical > Database Structure > Price Field Names
  14. Create the multi price fields you need.
-

If you have multiple companies, you can assign independet field sets for each +

If you have multiple companies, you can assign independent field sets for each one.

+

Note: ‘Show multi prices’ access group must be checked to be able to +add multiple prices in the product form view.

Usage

@@ -444,6 +446,7 @@

Contributors

  • Tecnativa
    • David Vidal
    • Pedro M. Baeza
    • +
    • Ernesto Tejeda
  • diff --git a/product_multi_price/views/product_views.xml b/product_multi_price/views/product_views.xml index 8fce79c84dc0..22c045731a6e 100644 --- a/product_multi_price/views/product_views.xml +++ b/product_multi_price/views/product_views.xml @@ -4,6 +4,7 @@ product.template + product.product + Date: Tue, 22 Sep 2020 13:10:09 +0000 Subject: [PATCH 07/26] Added translation using Weblate (Italian) --- product_multi_price/i18n/it.po | 200 +++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 product_multi_price/i18n/it.po diff --git a/product_multi_price/i18n/it.po b/product_multi_price/i18n/it.po new file mode 100644 index 000000000000..844f5f9b1cab --- /dev/null +++ b/product_multi_price/i18n/it.po @@ -0,0 +1,200 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_multi_price +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: product_multi_price +#: sql_constraint:product.multi.price:0 +msgid "A field name cannot be assigned to a product twice for the same company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base +msgid "Base price for computation.\n" +"Public Price: The base price will be the Sale/public Price.\n" +"Cost Price : The base price will be the cost price.\n" +"Other Pricelist : Computation of the base price based on another Pricelist." +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base +msgid "Based on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id +msgid "Company" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Cost" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Cost Price Tax Included" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid +msgid "Created by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_date +msgid "Created on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name +msgid "Display Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id +msgid "ID" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "Multi Price Record Options" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name +msgid "Name" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Other Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name +msgid "Other Price Name" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Other Pricelist" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids +msgid "Other Prices" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Partner Prices on the product form" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price +msgid "Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name +msgid "Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config +#: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu +msgid "Price Field Names" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist +msgid "Pricelist" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist_item +msgid "Pricelist Item" +msgstr "" + +#. module: product_multi_price +#: sql_constraint:product.multi.price.name:0 +msgid "Prices Names must be unique per company" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Prices based on supplier info" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_product +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id +msgid "Product" +msgstr "" + +#. module: product_multi_price +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +msgid "Product Multi Price" +msgstr "" + +#. module: product_multi_price +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +msgid "Product Multi Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price +msgid "Product Multiple Prices" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_multi_price +#: selection:product.pricelist.item,base:0 +msgid "Public Price" +msgstr "" + +#. module: product_multi_price +#: model:res.groups,name:product_multi_price.group_show_multi_prices +msgid "Show multi prices" +msgstr "" From 204760dd4a3c65ab17cea06739e91fadfde2f4be Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Tue, 22 Sep 2020 13:11:30 +0000 Subject: [PATCH 08/26] Translated using Weblate (Italian) Currently translated at 73.5% (25 of 34 strings) Translation: product-attribute-12.0/product-attribute-12.0-product_multi_price Translate-URL: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_multi_price/it/ --- product_multi_price/i18n/it.po | 58 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/product_multi_price/i18n/it.po b/product_multi_price/i18n/it.po index 844f5f9b1cab..ee7e4f4c626d 100644 --- a/product_multi_price/i18n/it.po +++ b/product_multi_price/i18n/it.po @@ -6,18 +6,22 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2020-09-22 16:00+0000\n" +"Last-Translator: Lorenzo Battistini \n" "Language-Team: none\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" #. module: product_multi_price #: sql_constraint:product.multi.price:0 msgid "A field name cannot be assigned to a product twice for the same company" msgstr "" +"Un nome di campo non può essere assegnato a un prodotto due volte per la " +"stessa azienda" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base @@ -26,27 +30,33 @@ msgid "Base price for computation.\n" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" +"Prezzo di base per il calcolo.\n" +"Prezzo pubblico: il prezzo di base sarà il prezzo di vendita/prezzo pubblico." +"\n" +"Prezzo di costo : il prezzo di base sarà il prezzo di costo.\n" +"Altro listino prezzi : calcolo del prezzo di base sulla base di un altro " +"listino prezzi." #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base msgid "Based on" -msgstr "" +msgstr "Basato su" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id msgid "Company" -msgstr "" +msgstr "Azienda" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Cost" -msgstr "" +msgstr "Costo" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Cost Price Tax Included" -msgstr "" +msgstr "Prezzo di costo imposte incluse" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid @@ -64,7 +74,7 @@ msgstr "" #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name msgid "Display Name" -msgstr "" +msgstr "Nome visualizzato" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id @@ -98,28 +108,28 @@ msgstr "" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name msgid "Name" -msgstr "" +msgstr "Nome" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Other Price" -msgstr "" +msgstr "Altro prezzo" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name msgid "Other Price Name" -msgstr "" +msgstr "Nome altro prezzo" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Other Pricelist" -msgstr "" +msgstr "Altro listino" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids #: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" -msgstr "" +msgstr "Altri prezzi" #. module: product_multi_price #: selection:product.pricelist.item,base:0 @@ -129,50 +139,50 @@ msgstr "" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" -msgstr "" +msgstr "Prezzo" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name msgid "Price Field Name" -msgstr "" +msgstr "Nome campo prezzo" #. module: product_multi_price #: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config #: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu msgid "Price Field Names" -msgstr "" +msgstr "Nomi campi prezzo" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist msgid "Pricelist" -msgstr "" +msgstr "Listino" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item msgid "Pricelist Item" -msgstr "" +msgstr "Articolo di listino" #. module: product_multi_price #: sql_constraint:product.multi.price.name:0 msgid "Prices Names must be unique per company" -msgstr "" +msgstr "I nomi dei prezzi devono essere unici per azienda" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Prices based on supplier info" -msgstr "" +msgstr "Prezzi basati sulle informazioni del fornitore" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id msgid "Product" -msgstr "" +msgstr "Prodotto" #. module: product_multi_price #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" -msgstr "" +msgstr "Prezzi multipli prodotto" #. module: product_multi_price #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view @@ -182,19 +192,19 @@ msgstr "" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price msgid "Product Multiple Prices" -msgstr "" +msgstr "Prezzi multipli prodotto" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template msgid "Product Template" -msgstr "" +msgstr "Modello prodotto" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Public Price" -msgstr "" +msgstr "Prezzo al pubblico" #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices msgid "Show multi prices" -msgstr "" +msgstr "Mostrare prezzi multipli" From fef064265e8793c0f88f06f7e11a79e49186eb79 Mon Sep 17 00:00:00 2001 From: claudiagn Date: Tue, 13 Oct 2020 11:06:56 +0000 Subject: [PATCH 09/26] Translated using Weblate (Spanish) Currently translated at 100.0% (34 of 34 strings) Translation: product-attribute-12.0/product-attribute-12.0-product_multi_price Translate-URL: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_multi_price/es/ --- product_multi_price/i18n/es.po | 44 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index e63c39f92dcd..4a63311d19cd 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -7,15 +7,15 @@ msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-04-09 08:52+0000\n" -"PO-Revision-Date: 2020-04-09 10:54+0200\n" -"Last-Translator: <>\n" +"PO-Revision-Date: 2020-10-13 13:08+0000\n" +"Last-Translator: claudiagn \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" -"X-Generator: Poedit 2.0.6\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" #. module: product_multi_price #: sql_constraint:product.multi.price:0 @@ -30,12 +30,16 @@ msgid "" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" +"Precio base de cálculo.\n" +"Precio público: El precio base será el Precio de venta / público.\n" +"Precio de costo: el precio base será el precio de costo.\n" +"Otra lista de precios: cálculo del precio base basado en otra lista de " +"precios." #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base -#, fuzzy msgid "Based on" -msgstr "Creado en" +msgstr "Basado en" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id @@ -46,12 +50,12 @@ msgstr "Compañía" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Cost" -msgstr "" +msgstr "Coste" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Cost Price Tax Included" -msgstr "" +msgstr "Precio de coste con impuesto incluido" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid @@ -75,7 +79,7 @@ msgstr "Nombre mostrado" #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id msgid "ID" -msgstr "ID (identificación)" +msgstr "ID" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update @@ -98,7 +102,7 @@ msgstr "Última actualización en" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price_name msgid "Multi Price Record Options" -msgstr "" +msgstr "Opciones de registro de precios múltiples" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name @@ -107,9 +111,8 @@ msgstr "Nombre" #. module: product_multi_price #: selection:product.pricelist.item,base:0 -#, fuzzy msgid "Other Price" -msgstr "Otros precios" +msgstr "Otro precio" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name @@ -118,9 +121,8 @@ msgstr "Nombre del otro precio" #. module: product_multi_price #: selection:product.pricelist.item,base:0 -#, fuzzy msgid "Other Pricelist" -msgstr "Otros precios" +msgstr "Otra tarifa" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids @@ -131,7 +133,7 @@ msgstr "Otros precios" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Partner Prices on the product form" -msgstr "" +msgstr "Precios de socios en el formulario de producto" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price @@ -156,7 +158,6 @@ msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -#, fuzzy msgid "Pricelist Item" msgstr "Elemento de Tarifa" @@ -168,7 +169,7 @@ msgstr "Los Nombres de Precio deben ser únicos para cada compañía" #. module: product_multi_price #: selection:product.pricelist.item,base:0 msgid "Prices based on supplier info" -msgstr "" +msgstr "Precios basados en la información del proveedor" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product @@ -189,9 +190,8 @@ msgstr "Nombre de Campo de Multi Precio de Producto" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price -#, fuzzy msgid "Product Multiple Prices" -msgstr "Multi Precio de Producto" +msgstr "Múltiples Precios de Producto" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template @@ -200,15 +200,13 @@ msgstr "Plantilla de producto" #. module: product_multi_price #: selection:product.pricelist.item,base:0 -#, fuzzy msgid "Public Price" -msgstr "Multi Precio" +msgstr "Precio público" #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices -#, fuzzy msgid "Show multi prices" -msgstr "product.multi.price" +msgstr "Muestra precios múltiples" #~ msgid "product.multi.price.name" #~ msgstr "product.multi.price.name" From edd3a66320c20560e183e09b85c7f3b366e7b5d7 Mon Sep 17 00:00:00 2001 From: Quentin Groulard Date: Fri, 16 Oct 2020 14:27:09 +0200 Subject: [PATCH 10/26] [IMP] product_multi_price: black, isort, prettier --- product_multi_price/__manifest__.py | 13 +- .../demo/multi_price_demo_data.xml | 5 +- product_multi_price/hooks.py | 13 +- .../models/product_multi_price.py | 49 +++--- .../models/product_pricelist.py | 28 ++-- product_multi_price/models/product_product.py | 51 +++--- .../models/product_template.py | 26 ++-- .../security/multi_price_security.xml | 20 ++- .../tests/test_product_multi_price.py | 147 +++++++++--------- .../views/multi_price_views.xml | 132 ++++++++-------- .../views/product_pricelist_views.xml | 13 +- product_multi_price/views/product_views.xml | 25 +-- 12 files changed, 267 insertions(+), 255 deletions(-) diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index a3f46cb6338c..0f662e15b5ed 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -4,14 +4,11 @@ { "name": "Product Multi Price", "version": "12.0.2.0.0", - 'author': 'Tecnativa,' - 'Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/product-attribute', + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-attribute", "category": "Product Management", "license": "AGPL-3", - "depends": [ - "product", - ], + "depends": ["product"], "data": [ "security/ir.model.access.csv", "security/multi_price_security.xml", @@ -19,9 +16,7 @@ "views/product_pricelist_views.xml", "views/product_views.xml", ], - 'demo': [ - "demo/multi_price_demo_data.xml", - ], + "demo": ["demo/multi_price_demo_data.xml"], "post_init_hook": "post_init_hook", "installable": True, } diff --git a/product_multi_price/demo/multi_price_demo_data.xml b/product_multi_price/demo/multi_price_demo_data.xml index d2f2955c39f1..9d9efab5fded 100644 --- a/product_multi_price/demo/multi_price_demo_data.xml +++ b/product_multi_price/demo/multi_price_demo_data.xml @@ -1,10 +1,7 @@ - - + - price_1 - diff --git a/product_multi_price/hooks.py b/product_multi_price/hooks.py index 6c519a3d57f1..968eca268057 100644 --- a/product_multi_price/hooks.py +++ b/product_multi_price/hooks.py @@ -1,13 +1,14 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import api, SUPERUSER_ID +from odoo import SUPERUSER_ID, api def post_init_hook(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) - group_id = env.ref('product_multi_price.group_show_multi_prices').id - default_user = env.ref('base.default_user') - user = env['res.users'].with_context(active_test=False).search( - [("share", "=", False)]) - (user - default_user).write({'groups_id': [(4, group_id, None)]}) + group_id = env.ref("product_multi_price.group_show_multi_prices").id + default_user = env.ref("base.default_user") + user = ( + env["res.users"].with_context(active_test=False).search([("share", "=", False)]) + ) + (user - default_user).write({"groups_id": [(4, group_id, None)]}) diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index 8be0abf2db9c..158dbde3ec6c 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -1,60 +1,57 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models + from odoo.addons import decimal_precision as dp class ProductMultiPrice(models.Model): - _name = 'product.multi.price' + _name = "product.multi.price" _description = "Product Multiple Prices" name = fields.Many2one( - comodel_name='product.multi.price.name', - required=True, - translate=True, + comodel_name="product.multi.price.name", required=True, translate=True, ) product_id = fields.Many2one( - comodel_name='product.product', - required=True, - ondelete='cascade', - ) - price = fields.Float( - digits=dp.get_precision('Product Price'), + comodel_name="product.product", required=True, ondelete="cascade", ) + price = fields.Float(digits=dp.get_precision("Product Price"),) company_id = fields.Many2one( - comodel_name='res.company', - related='name.company_id', + comodel_name="res.company", + related="name.company_id", store=True, readonly=True, ) _sql_constraints = [ - ('multi_price_uniq', 'unique(name, product_id, company_id)', - 'A field name cannot be assigned to a product twice for the same ' - 'company'), + ( + "multi_price_uniq", + "unique(name, product_id, company_id)", + "A field name cannot be assigned to a product twice for the same " + "company", + ), ] class ProductMultiPriceName(models.Model): - _name = 'product.multi.price.name' + _name = "product.multi.price.name" _description = "Multi Price Record Options" @api.model def _get_company(self): - return self._context.get('company_id', self.env.user.company_id.id) + return self._context.get("company_id", self.env.user.company_id.id) - name = fields.Char( - required=True, - string='Price Field Name', - ondelete='restrict' - ) + name = fields.Char(required=True, string="Price Field Name", ondelete="restrict") company_id = fields.Many2one( - comodel_name='res.company', + comodel_name="res.company", required=True, - default=lambda self: self._get_company() + default=lambda self: self._get_company(), ) _sql_constraints = [ - ('multi_price_name_uniq', 'unique(name, company_id)', - 'Prices Names must be unique per company'), + ( + "multi_price_name_uniq", + "unique(name, company_id)", + "Prices Names must be unique per company", + ), ] diff --git a/product_multi_price/models/product_pricelist.py b/product_multi_price/models/product_pricelist.py index 67b71dd869c7..037eee8e5270 100644 --- a/product_multi_price/models/product_pricelist.py +++ b/product_multi_price/models/product_pricelist.py @@ -4,34 +4,30 @@ class ProductPricelist(models.Model): - _inherit = 'product.pricelist' + _inherit = "product.pricelist" - def _compute_price_rule(self, products_qty_partner, date=False, - uom_id=False): + def _compute_price_rule(self, products_qty_partner, date=False, uom_id=False): """Recompute price after calling the atomic super method for getting proper prices when based on multi price. """ - rule_obj = self.env['product.pricelist.item'] - result = super()._compute_price_rule( - products_qty_partner, date, uom_id) + rule_obj = self.env["product.pricelist.item"] + result = super()._compute_price_rule(products_qty_partner, date, uom_id) # Make sure all rule records are fetched at once and put in cache - rule_obj.browse(x[1] for x in result.values()).mapped('price_discount') - for product, qty, _partner in products_qty_partner: + rule_obj.browse(x[1] for x in result.values()).mapped("price_discount") + for product, _qty, _partner in products_qty_partner: rule = rule_obj.browse(result[product.id][1]) - if rule.compute_price == 'formula' and rule.base == 'multi_price': + if rule.compute_price == "formula" and rule.base == "multi_price": result[product.id] = ( product._get_multiprice_pricelist_price(rule), - rule.id) + rule.id, + ) return result class ProductPricelistItem(models.Model): - _inherit = 'product.pricelist.item' + _inherit = "product.pricelist.item" - base = fields.Selection( - selection_add=[('multi_price', 'Other Price')], - ) + base = fields.Selection(selection_add=[("multi_price", "Other Price")],) multi_price_name = fields.Many2one( - comodel_name='product.multi.price.name', - string="Other Price Name", + comodel_name="product.multi.price.name", string="Other Price Name", ) diff --git a/product_multi_price/models/product_product.py b/product_multi_price/models/product_product.py index e937bdccc573..e72f936105b0 100644 --- a/product_multi_price/models/product_product.py +++ b/product_multi_price/models/product_product.py @@ -1,58 +1,65 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import models, fields, tools +from odoo import fields, models, tools class ProductProduct(models.Model): _inherit = "product.product" price_ids = fields.One2many( - comodel_name='product.multi.price', - inverse_name='product_id', + comodel_name="product.multi.price", + inverse_name="product_id", string="Other Prices", ) + def _convert_to_price_uom(self, price): + qty_uom_id = self._context.get("uom") or self.uom_id.id + price_uom = self.env["uom.uom"].browse([qty_uom_id]) + return self.uom_id._compute_price(price, price_uom) + def _get_multiprice_pricelist_price(self, rule): """Method for getting the price from multi price.""" self.ensure_one() company = rule.company_id or self.env.user.company_id - price = self.env['product.multi.price'].sudo().search([ - ('company_id', '=', company.id), - ('name', '=', rule.multi_price_name.id), - ('product_id', '=', self.id), - ]).price or 0 + price = ( + self.env["product.multi.price"] + .sudo() + .search( + [ + ("company_id", "=", company.id), + ("name", "=", rule.multi_price_name.id), + ("product_id", "=", self.id), + ] + ) + .price + or 0 + ) if price: # We have to replicate this logic in this method as pricelist # method are atomic and we can't hack inside. # Verbatim copy of part of product.pricelist._compute_price_rule. - qty_uom_id = self._context.get('uom') or self.uom_id.id - price_uom = self.env['uom.uom'].browse([qty_uom_id]) - convert_to_price_uom = ( - lambda price: self.uom_id._compute_price( - price, price_uom)) price_limit = price price = (price - (price * (rule.price_discount / 100))) or 0.0 if rule.price_round: - price = tools.float_round( - price, precision_rounding=rule.price_round) + price = tools.float_round(price, precision_rounding=rule.price_round) if rule.price_surcharge: - price_surcharge = convert_to_price_uom(rule.price_surcharge) + price_surcharge = self._convert_to_price_uom(rule.price_surcharge) price += price_surcharge if rule.price_min_margin: - price_min_margin = convert_to_price_uom(rule.price_min_margin) + price_min_margin = self._convert_to_price_uom(rule.price_min_margin) price = max(price, price_limit + price_min_margin) if rule.price_max_margin: - price_max_margin = convert_to_price_uom(rule.price_max_margin) + price_max_margin = self._convert_to_price_uom(rule.price_max_margin) price = min(price, price_limit + price_max_margin) return price - def price_compute(self, price_type, uom=False, currency=False, - company=False): + def price_compute(self, price_type, uom=False, currency=False, company=False): """Return temporary prices when computation is done for multi price for avoiding error on super method. We will later fill these with the correct values. """ - if price_type == 'multi_price': + if price_type == "multi_price": return dict.fromkeys(self.ids, 1.0) return super().price_compute( - price_type, uom=uom, currency=currency, company=company) + price_type, uom=uom, currency=currency, company=company + ) diff --git a/product_multi_price/models/product_template.py b/product_multi_price/models/product_template.py index 81be41bc417b..f12afc012fd3 100644 --- a/product_multi_price/models/product_template.py +++ b/product_multi_price/models/product_template.py @@ -7,14 +7,13 @@ class ProductTemplate(models.Model): _inherit = "product.template" price_ids = fields.One2many( - comodel_name='product.multi.price', - compute='_compute_price_ids', - inverse='_inverse_price_ids', + comodel_name="product.multi.price", + compute="_compute_price_ids", + inverse="_inverse_price_ids", string="Other Prices", ) - @api.depends('product_variant_ids', - 'product_variant_ids.price_ids') + @api.depends("product_variant_ids", "product_variant_ids.price_ids") def _compute_price_ids(self): for p in self: if len(p.product_variant_ids) == 1: @@ -27,8 +26,7 @@ def _inverse_price_ids(self): def _get_multiprice_pricelist_price(self, rule): if len(self.product_variant_ids) == 1: - return ( - self.product_variant_ids._get_multiprice_pricelist_price(rule)) + return self.product_variant_ids._get_multiprice_pricelist_price(rule) return 0 @api.model @@ -37,19 +35,17 @@ def create(self, vals): one variant), after the variant creation, that is performed in super. """ template = super().create(vals) - if vals.get('price_ids'): - template.write({ - 'price_ids': vals.get('price_ids'), - }) + if vals.get("price_ids"): + template.write({"price_ids": vals.get("price_ids")}) return template - def price_compute(self, price_type, uom=False, currency=False, - company=False): + def price_compute(self, price_type, uom=False, currency=False, company=False): """Return temporary prices when computation is done for multi price for avoiding error on super method. We will later fill these with the correct values. """ - if price_type == 'multi_price': + if price_type == "multi_price": return dict.fromkeys(self.ids, 1.0) return super().price_compute( - price_type, uom=uom, currency=currency, company=company) + price_type, uom=uom, currency=currency, company=company + ) diff --git a/product_multi_price/security/multi_price_security.xml b/product_multi_price/security/multi_price_security.xml index dd7c04826ce3..b7c6760211bd 100644 --- a/product_multi_price/security/multi_price_security.xml +++ b/product_multi_price/security/multi_price_security.xml @@ -1,23 +1,27 @@ - + Show multi prices - + Multiple Price multi-company - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] Multiple Price Field Name multi-company - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] diff --git a/product_multi_price/tests/test_product_multi_price.py b/product_multi_price/tests/test_product_multi_price.py index bf8b90f0de72..2922a463e4b7 100644 --- a/product_multi_price/tests/test_product_multi_price.py +++ b/product_multi_price/tests/test_product_multi_price.py @@ -4,87 +4,88 @@ class TestProductMultiPrice(SavepointCase): - @classmethod def setUpClass(cls): super().setUpClass() - cls.price_name_obj = cls.env['product.multi.price.name'] - cls.price_field_1 = cls.price_name_obj.create({'name': 'test_field_1'}) - cls.price_field_2 = cls.price_name_obj.create({'name': 'test_field_2'}) - prod_tmpl_obj = cls.env['product.template'] - cls.prod_1 = prod_tmpl_obj.create({ - 'name': 'Test Product Template', - 'price_ids': [ - (0, 0, { - 'name': cls.price_field_1.id, - 'price': 5.5, - }), - (0, 0, { - 'name': cls.price_field_2.id, - 'price': 20.0, - }), - ], - }) - cls.prod_att_1 = cls.env['product.attribute'].create({'name': 'Color'}) - cls.prod_attr1_v1 = cls.env['product.attribute.value'].create({ - 'name': 'red', 'attribute_id': cls.prod_att_1.id}) - cls.prod_attr1_v2 = cls.env['product.attribute.value'].create({ - 'name': 'blue', 'attribute_id': cls.prod_att_1.id}) - cls.prod_2 = prod_tmpl_obj.create({ - 'name': 'Test Product 2 With Variants', - 'attribute_line_ids': [(0, 0, { - 'attribute_id': cls.prod_att_1.id, - 'value_ids': [(6, 0, [ - cls.prod_attr1_v1.id, cls.prod_attr1_v2.id - ])], - })] - }) + cls.price_name_obj = cls.env["product.multi.price.name"] + cls.price_field_1 = cls.price_name_obj.create({"name": "test_field_1"}) + cls.price_field_2 = cls.price_name_obj.create({"name": "test_field_2"}) + prod_tmpl_obj = cls.env["product.template"] + cls.prod_1 = prod_tmpl_obj.create( + { + "name": "Test Product Template", + "price_ids": [ + (0, 0, {"name": cls.price_field_1.id, "price": 5.5}), + (0, 0, {"name": cls.price_field_2.id, "price": 20.0}), + ], + } + ) + cls.prod_att_1 = cls.env["product.attribute"].create({"name": "Color"}) + cls.prod_attr1_v1 = cls.env["product.attribute.value"].create( + {"name": "red", "attribute_id": cls.prod_att_1.id} + ) + cls.prod_attr1_v2 = cls.env["product.attribute.value"].create( + {"name": "blue", "attribute_id": cls.prod_att_1.id} + ) + cls.prod_2 = prod_tmpl_obj.create( + { + "name": "Test Product 2 With Variants", + "attribute_line_ids": [ + ( + 0, + 0, + { + "attribute_id": cls.prod_att_1.id, + "value_ids": [ + (6, 0, [cls.prod_attr1_v1.id, cls.prod_attr1_v2.id]) + ], + }, + ) + ], + } + ) cls.prod_prod_2_1 = cls.prod_2.product_variant_ids[0] cls.prod_prod_2_2 = cls.prod_2.product_variant_ids[1] - cls.prod_prod_2_1.write({ - 'price_ids': [ - (0, 0, { - 'name': cls.price_field_1.id, - 'price': 6.6, - }), - (0, 0, { - 'name': cls.price_field_2.id, - 'price': 7.7, - }), - ], - }) - cls.prod_prod_2_2.write({ - 'price_ids': [ - (0, 0, { - 'name': cls.price_field_1.id, - 'price': 8.8, - }), - (0, 0, { - 'name': cls.price_field_2.id, - 'price': 9.9, - }), - ], - }) - cls.pricelist = cls.env['product.pricelist'].create({ - 'name': 'Test pricelist', - 'item_ids': [ - (0, 0, { - 'compute_price': 'formula', - 'base': 'multi_price', - 'multi_price_name': cls.price_field_1.id, - 'price_discount': 10, - 'applied_on': '3_global', - })], - }) + cls.prod_prod_2_1.write( + { + "price_ids": [ + (0, 0, {"name": cls.price_field_1.id, "price": 6.6}), + (0, 0, {"name": cls.price_field_2.id, "price": 7.7}), + ], + } + ) + cls.prod_prod_2_2.write( + { + "price_ids": [ + (0, 0, {"name": cls.price_field_1.id, "price": 8.8}), + (0, 0, {"name": cls.price_field_2.id, "price": 9.9}), + ], + } + ) + cls.pricelist = cls.env["product.pricelist"].create( + { + "name": "Test pricelist", + "item_ids": [ + ( + 0, + 0, + { + "compute_price": "formula", + "base": "multi_price", + "multi_price_name": cls.price_field_1.id, + "price_discount": 10, + "applied_on": "3_global", + }, + ) + ], + } + ) def test_product_multi_price_pricelist(self): """Pricelists based on multi prices for templates or variants""" - price = self.prod_1.with_context( - pricelist=self.pricelist.id).price + price = self.prod_1.with_context(pricelist=self.pricelist.id).price self.assertAlmostEqual(price, 4.95) - price = self.prod_prod_2_1.with_context( - pricelist=self.pricelist.id).price + price = self.prod_prod_2_1.with_context(pricelist=self.pricelist.id).price self.assertAlmostEqual(price, 5.94) - price = self.prod_prod_2_2.with_context( - pricelist=self.pricelist.id).price + price = self.prod_prod_2_2.with_context(pricelist=self.pricelist.id).price self.assertAlmostEqual(price, 7.92) diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml index e49ba0dd6427..0a41ee3527d5 100644 --- a/product_multi_price/views/multi_price_views.xml +++ b/product_multi_price/views/multi_price_views.xml @@ -1,63 +1,73 @@ - + - - product.multi.price - - - - - - - - - - - - product.multi.price - - - - - - - - - - - - - - - - product.multi.price - primary - - - - - - bottom - - - - - - product.multi.price.name - - - - - - - - - - Price Field Names - product.multi.price.name - form - {} - - - - + + product.multi.price + + + + + + + + + + + product.multi.price + +
    + + + + + + + + +
    +
    +
    + + product.multi.price + primary + + + + + + bottom + + + + + product.multi.price.name + + + + + + + + + Price Field Names + product.multi.price.name + form + {} + + +
    diff --git a/product_multi_price/views/product_pricelist_views.xml b/product_multi_price/views/product_pricelist_views.xml index 419f96cf5ae5..ce85925d61b9 100644 --- a/product_multi_price/views/product_pricelist_views.xml +++ b/product_multi_price/views/product_pricelist_views.xml @@ -1,14 +1,17 @@ - + - product.pricelist.item - + - + - diff --git a/product_multi_price/views/product_views.xml b/product_multi_price/views/product_views.xml index 22c045731a6e..88a393472a9b 100644 --- a/product_multi_price/views/product_views.xml +++ b/product_multi_price/views/product_views.xml @@ -1,13 +1,16 @@ - + - product.template - - + + - - product.product - - + + - - From 248011db758db42e023df3222927de5d94acae33 Mon Sep 17 00:00:00 2001 From: Quentin Groulard Date: Fri, 16 Oct 2020 14:30:17 +0200 Subject: [PATCH 11/26] [MIG] product_multi_price: Migration to 13.0 --- product_multi_price/README.rst | 10 +-- product_multi_price/__manifest__.py | 2 +- product_multi_price/i18n/es.po | 62 +++++++---------- product_multi_price/i18n/it.po | 68 ++++++++----------- .../i18n/product_multi_price.pot | 53 ++++----------- .../migrations/12.0.2.0.0/post-migration.py | 7 -- .../13.0.1.0.0/noupdate_changes.xml | 13 ++++ .../migrations/13.0.1.0.0/post-migration.py | 11 +++ .../models/product_multi_price.py | 6 +- .../models/product_template.py | 2 + .../security/multi_price_security.xml | 4 +- .../static/description/index.html | 6 +- .../views/multi_price_views.xml | 1 - 13 files changed, 105 insertions(+), 140 deletions(-) delete mode 100644 product_multi_price/migrations/12.0.2.0.0/post-migration.py create mode 100644 product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml create mode 100644 product_multi_price/migrations/13.0.1.0.0/post-migration.py diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index 9d7443c34946..bdbeaa727f8d 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -14,13 +14,13 @@ Product Multi Price :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github - :target: https://github.com/OCA/product-attribute/tree/12.0/product_multi_price + :target: https://github.com/OCA/product-attribute/tree/13.0/product_multi_price :alt: OCA/product-attribute .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_multi_price + :target: https://translation.odoo-community.org/projects/product-attribute-13-0/product-attribute-13-0-product_multi_price :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/135/12.0 + :target: https://runbot.odoo-community.org/runbot/135/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -79,7 +79,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -113,6 +113,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/product-attribute `_ project on GitHub. +This module is part of the `OCA/product-attribute `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 0f662e15b5ed..7a9bce320d40 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "12.0.2.0.0", + "version": "13.0.1.0.0", "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-attribute", "category": "Product Management", diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index 4a63311d19cd..a851307e56fe 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-04-09 08:52+0000\n" "PO-Revision-Date: 2020-10-13 13:08+0000\n" @@ -18,15 +18,16 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: product_multi_price -#: sql_constraint:product.multi.price:0 +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq msgid "A field name cannot be assigned to a product twice for the same company" msgstr "No puede haber un nombre de campo repetido en la misma compañía" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base +#, fuzzy msgid "" "Base price for computation.\n" -"Public Price: The base price will be the Sale/public Price.\n" +"Sales Price: The base price will be the Sales Price.\n" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" @@ -47,16 +48,6 @@ msgstr "Basado en" msgid "Company" msgstr "Compañía" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost" -msgstr "Coste" - -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost Price Tax Included" -msgstr "Precio de coste con impuesto incluido" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid @@ -110,7 +101,7 @@ msgid "Name" msgstr "Nombre" #. module: product_multi_price -#: selection:product.pricelist.item,base:0 +#: model:ir.model.fields.selection,name:product_multi_price.selection__product_pricelist_item__base__multi_price msgid "Other Price" msgstr "Otro precio" @@ -119,22 +110,12 @@ msgstr "Otro precio" msgid "Other Price Name" msgstr "Nombre del otro precio" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Other Pricelist" -msgstr "Otra tarifa" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids #: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" msgstr "Otros precios" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Partner Prices on the product form" -msgstr "Precios de socios en el formulario de producto" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" @@ -158,19 +139,15 @@ msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -msgid "Pricelist Item" +#, fuzzy +msgid "Pricelist Rule" msgstr "Elemento de Tarifa" #. module: product_multi_price -#: sql_constraint:product.multi.price.name:0 +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq msgid "Prices Names must be unique per company" msgstr "Los Nombres de Precio deben ser únicos para cada compañía" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Prices based on supplier info" -msgstr "Precios basados en la información del proveedor" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id @@ -198,15 +175,28 @@ msgstr "Múltiples Precios de Producto" msgid "Product Template" msgstr "Plantilla de producto" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Public Price" -msgstr "Precio público" - #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices msgid "Show multi prices" msgstr "Muestra precios múltiples" +#~ msgid "Cost" +#~ msgstr "Coste" + +#~ msgid "Cost Price Tax Included" +#~ msgstr "Precio de coste con impuesto incluido" + +#~ msgid "Other Pricelist" +#~ msgstr "Otra tarifa" + +#~ msgid "Partner Prices on the product form" +#~ msgstr "Precios de socios en el formulario de producto" + +#~ msgid "Prices based on supplier info" +#~ msgstr "Precios basados en la información del proveedor" + +#~ msgid "Public Price" +#~ msgstr "Precio público" + #~ msgid "product.multi.price.name" #~ msgstr "product.multi.price.name" diff --git a/product_multi_price/i18n/it.po b/product_multi_price/i18n/it.po index ee7e4f4c626d..f9fad1e86091 100644 --- a/product_multi_price/i18n/it.po +++ b/product_multi_price/i18n/it.po @@ -1,10 +1,10 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * product_multi_price +# * product_multi_price # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" "PO-Revision-Date: 2020-09-22 16:00+0000\n" "Last-Translator: Lorenzo Battistini \n" @@ -17,7 +17,7 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: product_multi_price -#: sql_constraint:product.multi.price:0 +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq msgid "A field name cannot be assigned to a product twice for the same company" msgstr "" "Un nome di campo non può essere assegnato a un prodotto due volte per la " @@ -25,14 +25,16 @@ msgstr "" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base -msgid "Base price for computation.\n" -"Public Price: The base price will be the Sale/public Price.\n" +#, fuzzy +msgid "" +"Base price for computation.\n" +"Sales Price: The base price will be the Sales Price.\n" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" "Prezzo di base per il calcolo.\n" -"Prezzo pubblico: il prezzo di base sarà il prezzo di vendita/prezzo pubblico." -"\n" +"Prezzo pubblico: il prezzo di base sarà il prezzo di vendita/prezzo " +"pubblico.\n" "Prezzo di costo : il prezzo di base sarà il prezzo di costo.\n" "Altro listino prezzi : calcolo del prezzo di base sulla base di un altro " "listino prezzi." @@ -48,16 +50,6 @@ msgstr "Basato su" msgid "Company" msgstr "Azienda" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost" -msgstr "Costo" - -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost Price Tax Included" -msgstr "Prezzo di costo imposte incluse" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid @@ -111,7 +103,7 @@ msgid "Name" msgstr "Nome" #. module: product_multi_price -#: selection:product.pricelist.item,base:0 +#: model:ir.model.fields.selection,name:product_multi_price.selection__product_pricelist_item__base__multi_price msgid "Other Price" msgstr "Altro prezzo" @@ -120,22 +112,12 @@ msgstr "Altro prezzo" msgid "Other Price Name" msgstr "Nome altro prezzo" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Other Pricelist" -msgstr "Altro listino" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids #: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" msgstr "Altri prezzi" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Partner Prices on the product form" -msgstr "" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" @@ -159,19 +141,15 @@ msgstr "Listino" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -msgid "Pricelist Item" +#, fuzzy +msgid "Pricelist Rule" msgstr "Articolo di listino" #. module: product_multi_price -#: sql_constraint:product.multi.price.name:0 +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq msgid "Prices Names must be unique per company" msgstr "I nomi dei prezzi devono essere unici per azienda" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Prices based on supplier info" -msgstr "Prezzi basati sulle informazioni del fornitore" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id @@ -199,12 +177,22 @@ msgstr "Prezzi multipli prodotto" msgid "Product Template" msgstr "Modello prodotto" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Public Price" -msgstr "Prezzo al pubblico" - #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices msgid "Show multi prices" msgstr "Mostrare prezzi multipli" + +#~ msgid "Cost" +#~ msgstr "Costo" + +#~ msgid "Cost Price Tax Included" +#~ msgstr "Prezzo di costo imposte incluse" + +#~ msgid "Other Pricelist" +#~ msgstr "Altro listino" + +#~ msgid "Prices based on supplier info" +#~ msgstr "Prezzi basati sulle informazioni del fornitore" + +#~ msgid "Public Price" +#~ msgstr "Prezzo al pubblico" diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot index 3fa5ca508597..0f7e0845c8f3 100644 --- a/product_multi_price/i18n/product_multi_price.pot +++ b/product_multi_price/i18n/product_multi_price.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * product_multi_price +# * product_multi_price # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -14,14 +14,16 @@ msgstr "" "Plural-Forms: \n" #. module: product_multi_price -#: sql_constraint:product.multi.price:0 -msgid "A field name cannot be assigned to a product twice for the same company" +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq +msgid "" +"A field name cannot be assigned to a product twice for the same company" msgstr "" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base -msgid "Base price for computation.\n" -"Public Price: The base price will be the Sale/public Price.\n" +msgid "" +"Base price for computation.\n" +"Sales Price: The base price will be the Sales Price.\n" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" @@ -37,16 +39,6 @@ msgstr "" msgid "Company" msgstr "" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost" -msgstr "" - -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Cost Price Tax Included" -msgstr "" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid @@ -100,7 +92,7 @@ msgid "Name" msgstr "" #. module: product_multi_price -#: selection:product.pricelist.item,base:0 +#: model:ir.model.fields.selection,name:product_multi_price.selection__product_pricelist_item__base__multi_price msgid "Other Price" msgstr "" @@ -109,22 +101,12 @@ msgstr "" msgid "Other Price Name" msgstr "" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Other Pricelist" -msgstr "" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids #: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" msgstr "" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Partner Prices on the product form" -msgstr "" - #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" @@ -148,19 +130,14 @@ msgstr "" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -msgid "Pricelist Item" +msgid "Pricelist Rule" msgstr "" #. module: product_multi_price -#: sql_constraint:product.multi.price.name:0 +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq msgid "Prices Names must be unique per company" msgstr "" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Prices based on supplier info" -msgstr "" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id @@ -188,13 +165,7 @@ msgstr "" msgid "Product Template" msgstr "" -#. module: product_multi_price -#: selection:product.pricelist.item,base:0 -msgid "Public Price" -msgstr "" - #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices msgid "Show multi prices" msgstr "" - diff --git a/product_multi_price/migrations/12.0.2.0.0/post-migration.py b/product_multi_price/migrations/12.0.2.0.0/post-migration.py deleted file mode 100644 index edf4a0f25ede..000000000000 --- a/product_multi_price/migrations/12.0.2.0.0/post-migration.py +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2020 Tecnativa - Ernesto Tejeda -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl -from odoo.addons.product_multi_price.hooks import post_init_hook - - -def migrate(cr, version): - post_init_hook(cr, False) diff --git a/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml b/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml new file mode 100644 index 000000000000..fde32703ce30 --- /dev/null +++ b/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml @@ -0,0 +1,13 @@ + + + + ['|',('company_id','=',False),('company_id','in',company_ids)] + + + ['|',('company_id','=',False),('company_id','in',company_ids)] + + diff --git a/product_multi_price/migrations/13.0.1.0.0/post-migration.py b/product_multi_price/migrations/13.0.1.0.0/post-migration.py new file mode 100644 index 000000000000..10bcb5bd068a --- /dev/null +++ b/product_multi_price/migrations/13.0.1.0.0/post-migration.py @@ -0,0 +1,11 @@ +# Copyright 2020 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade # pylint: disable=W7936 + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data( + env.cr, "product_multi_price", "migrations/13.0.1.0.0/noupdate_changes.xml" + ) diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index 158dbde3ec6c..06e8b1783886 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -2,8 +2,6 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models -from odoo.addons import decimal_precision as dp - class ProductMultiPrice(models.Model): _name = "product.multi.price" @@ -15,7 +13,7 @@ class ProductMultiPrice(models.Model): product_id = fields.Many2one( comodel_name="product.product", required=True, ondelete="cascade", ) - price = fields.Float(digits=dp.get_precision("Product Price"),) + price = fields.Float(digits="Product Price",) company_id = fields.Many2one( comodel_name="res.company", related="name.company_id", @@ -39,7 +37,7 @@ class ProductMultiPriceName(models.Model): @api.model def _get_company(self): - return self._context.get("company_id", self.env.user.company_id.id) + return self._context.get("company_id", self.env.company) name = fields.Char(required=True, string="Price Field Name", ondelete="restrict") company_id = fields.Many2one( diff --git a/product_multi_price/models/product_template.py b/product_multi_price/models/product_template.py index f12afc012fd3..f80a2143de50 100644 --- a/product_multi_price/models/product_template.py +++ b/product_multi_price/models/product_template.py @@ -18,6 +18,8 @@ def _compute_price_ids(self): for p in self: if len(p.product_variant_ids) == 1: p.price_ids = p.product_variant_ids.price_ids + else: + p.price_ids = False def _inverse_price_ids(self): for p in self: diff --git a/product_multi_price/security/multi_price_security.xml b/product_multi_price/security/multi_price_security.xml index b7c6760211bd..7f73c76ce5e2 100644 --- a/product_multi_price/security/multi_price_security.xml +++ b/product_multi_price/security/multi_price_security.xml @@ -13,7 +13,7 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + >['|',('company_id','=',False),('company_id','in',company_ids)]
    Multiple Price Field Name multi-company @@ -21,7 +21,7 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + >['|',('company_id','=',False),('company_id','in',company_ids)] diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index c357803472d6..30bdbd6f3a63 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -367,7 +367,7 @@

    Product Multi Price

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    This module allows to set multiple prices to products and base pricelist rules on them.

    Table of contents

    @@ -429,7 +429,7 @@

    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.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -458,7 +458,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/product-attribute project on GitHub.

    +

    This module is part of the OCA/product-attribute project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml index 0a41ee3527d5..6a50d8637e59 100644 --- a/product_multi_price/views/multi_price_views.xml +++ b/product_multi_price/views/multi_price_views.xml @@ -61,7 +61,6 @@ Price Field Names product.multi.price.name - form {} From 9ddea47a6d1131683352ba2a1c1c34d9dce9a09d Mon Sep 17 00:00:00 2001 From: claudiagn Date: Tue, 23 Feb 2021 17:00:46 +0000 Subject: [PATCH 12/26] Added translation using Weblate (Catalan) --- product_multi_price/i18n/ca.po | 172 +++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 product_multi_price/i18n/ca.po diff --git a/product_multi_price/i18n/ca.po b/product_multi_price/i18n/ca.po new file mode 100644 index 000000000000..3928baf5e398 --- /dev/null +++ b/product_multi_price/i18n/ca.po @@ -0,0 +1,172 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_multi_price +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: product_multi_price +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq +msgid "" +"A field name cannot be assigned to a product twice for the same company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base +msgid "" +"Base price for computation.\n" +"Sales Price: The base price will be the Sales Price.\n" +"Cost Price : The base price will be the cost price.\n" +"Other Pricelist : Computation of the base price based on another Pricelist." +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base +msgid "Based on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id +msgid "Company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid +msgid "Created by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_date +msgid "Created on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name +msgid "Display Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id +msgid "ID" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name____last_update +msgid "Last Modified on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_uid +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_date +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_date +msgid "Last Updated on" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price_name +msgid "Multi Price Record Options" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name +msgid "Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields.selection,name:product_multi_price.selection__product_pricelist_item__base__multi_price +msgid "Other Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name +msgid "Other Price Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids +#: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids +msgid "Other Prices" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price +msgid "Price" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name +msgid "Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config +#: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu +msgid "Price Field Names" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist +msgid "Pricelist" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_pricelist_item +msgid "Pricelist Rule" +msgstr "" + +#. module: product_multi_price +#: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq +msgid "Prices Names must be unique per company" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_product +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id +msgid "Product" +msgstr "" + +#. module: product_multi_price +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view +msgid "Product Multi Price" +msgstr "" + +#. module: product_multi_price +#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view +msgid "Product Multi Price Field Name" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_multi_price +msgid "Product Multiple Prices" +msgstr "" + +#. module: product_multi_price +#: model:ir.model,name:product_multi_price.model_product_template +msgid "Product Template" +msgstr "" + +#. module: product_multi_price +#: model:res.groups,name:product_multi_price.group_show_multi_prices +msgid "Show multi prices" +msgstr "" From 1b4674f674c0a9178eb002c93aa22fc22fb5e8a3 Mon Sep 17 00:00:00 2001 From: claudiagn Date: Tue, 23 Feb 2021 17:00:35 +0000 Subject: [PATCH 13/26] Translated using Weblate (Spanish) Currently translated at 100.0% (28 of 28 strings) Translation: product-attribute-13.0/product-attribute-13.0-product_multi_price Translate-URL: https://translation.odoo-community.org/projects/product-attribute-13-0/product-attribute-13-0-product_multi_price/es/ --- product_multi_price/i18n/es.po | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/product_multi_price/i18n/es.po b/product_multi_price/i18n/es.po index a851307e56fe..94e82d2b45e2 100644 --- a/product_multi_price/i18n/es.po +++ b/product_multi_price/i18n/es.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-04-09 08:52+0000\n" -"PO-Revision-Date: 2020-10-13 13:08+0000\n" +"PO-Revision-Date: 2021-02-23 18:45+0000\n" "Last-Translator: claudiagn \n" "Language-Team: \n" "Language: es\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10\n" +"X-Generator: Weblate 4.3.2\n" #. module: product_multi_price #: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq @@ -24,7 +24,6 @@ msgstr "No puede haber un nombre de campo repetido en la misma compañía" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base -#, fuzzy msgid "" "Base price for computation.\n" "Sales Price: The base price will be the Sales Price.\n" @@ -32,7 +31,7 @@ msgid "" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" "Precio base de cálculo.\n" -"Precio público: El precio base será el Precio de venta / público.\n" +"Precio de venta: el precio base será el precio de venta.\n" "Precio de costo: el precio base será el precio de costo.\n" "Otra lista de precios: cálculo del precio base basado en otra lista de " "precios." @@ -139,9 +138,8 @@ msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item -#, fuzzy msgid "Pricelist Rule" -msgstr "Elemento de Tarifa" +msgstr "Regla de tarifa" #. module: product_multi_price #: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq From 1c5b37ce08c9698763556b19af55be3f85ab5e19 Mon Sep 17 00:00:00 2001 From: claudiagn Date: Tue, 23 Feb 2021 17:08:47 +0000 Subject: [PATCH 14/26] Translated using Weblate (Catalan) Currently translated at 100.0% (28 of 28 strings) Translation: product-attribute-13.0/product-attribute-13.0-product_multi_price Translate-URL: https://translation.odoo-community.org/projects/product-attribute-13-0/product-attribute-13-0-product_multi_price/ca/ --- product_multi_price/i18n/ca.po | 63 +++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/product_multi_price/i18n/ca.po b/product_multi_price/i18n/ca.po index 3928baf5e398..74a25dafc3f4 100644 --- a/product_multi_price/i18n/ca.po +++ b/product_multi_price/i18n/ca.po @@ -6,19 +6,23 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2021-02-23 18:45+0000\n" +"Last-Translator: claudiagn \n" "Language-Team: none\n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: product_multi_price #: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_multi_price_uniq msgid "" "A field name cannot be assigned to a product twice for the same company" msgstr "" +"No es pot assignar un nom de camp a un producte dues vegades per a la " +"mateixa empresa" #. module: product_multi_price #: model:ir.model.fields,help:product_multi_price.field_product_pricelist_item__base @@ -28,145 +32,150 @@ msgid "" "Cost Price : The base price will be the cost price.\n" "Other Pricelist : Computation of the base price based on another Pricelist." msgstr "" +"Preu base de càlcul.\n" +"Preu de venda: el preu base serà el preu de venda.\n" +"Preu de cost: el preu base serà el preu de cost.\n" +"Una altra llista de preus: càlcul del preu base basat en una altra llista de " +"preus." #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__base msgid "Based on" -msgstr "" +msgstr "Basat en" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__company_id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__company_id msgid "Company" -msgstr "" +msgstr "Companyia" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_uid #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_uid msgid "Created by" -msgstr "" +msgstr "Creat per" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__create_date #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__create_date msgid "Created on" -msgstr "" +msgstr "Creat el" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__display_name #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__display_name msgid "Display Name" -msgstr "" +msgstr "Nom visible" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__id #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__id msgid "ID" -msgstr "" +msgstr "ID" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price____last_update #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name____last_update msgid "Last Modified on" -msgstr "" +msgstr "Darrera modificació el" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_uid #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_uid msgid "Last Updated by" -msgstr "" +msgstr "Darrera actualització per" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__write_date #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__write_date msgid "Last Updated on" -msgstr "" +msgstr "Darrera actualització el" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price_name msgid "Multi Price Record Options" -msgstr "" +msgstr "Opcions de registre de preus múltiples" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name msgid "Name" -msgstr "" +msgstr "Nom" #. module: product_multi_price #: model:ir.model.fields.selection,name:product_multi_price.selection__product_pricelist_item__base__multi_price msgid "Other Price" -msgstr "" +msgstr "Altre preu" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_pricelist_item__multi_price_name msgid "Other Price Name" -msgstr "" +msgstr "Nom de l'altre preu" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_product__price_ids #: model:ir.model.fields,field_description:product_multi_price.field_product_template__price_ids msgid "Other Prices" -msgstr "" +msgstr "Altres preus" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__price msgid "Price" -msgstr "" +msgstr "Preu" #. module: product_multi_price #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name msgid "Price Field Name" -msgstr "" +msgstr "Nom del camp del preu" #. module: product_multi_price #: model:ir.actions.act_window,name:product_multi_price.action_multi_price_name_config #: model:ir.ui.menu,name:product_multi_price.multi_price_name_menu msgid "Price Field Names" -msgstr "" +msgstr "Noms de camps de preus" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist msgid "Pricelist" -msgstr "" +msgstr "Tarifa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_pricelist_item msgid "Pricelist Rule" -msgstr "" +msgstr "Regla de tarifa" #. module: product_multi_price #: model:ir.model.constraint,message:product_multi_price.constraint_product_multi_price_name_multi_price_name_uniq msgid "Prices Names must be unique per company" -msgstr "" +msgstr "Els noms dels preus han de ser únics per empresa" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_product #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__product_id msgid "Product" -msgstr "" +msgstr "Producte" #. module: product_multi_price #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" -msgstr "" +msgstr "Preu múltiple de producte" #. module: product_multi_price #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view msgid "Product Multi Price Field Name" -msgstr "" +msgstr "Nom del camp del preu múltiple del producte" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price msgid "Product Multiple Prices" -msgstr "" +msgstr "Preus múltiples de productes" #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_template msgid "Product Template" -msgstr "" +msgstr "Plantilla de producte" #. module: product_multi_price #: model:res.groups,name:product_multi_price.group_show_multi_prices msgid "Show multi prices" -msgstr "" +msgstr "Mostra preus múltiples" From 503d1b22a02216add0e0b63cea5ad097590aa31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ernesto=20Garc=C3=ADa=20Medina?= Date: Fri, 24 Mar 2023 10:45:30 -0600 Subject: [PATCH 15/26] [IMP] product_multi_price: black, isort, prettier --- product_multi_price/models/product_multi_price.py | 12 +++++++++--- product_multi_price/models/product_pricelist.py | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index 06e8b1783886..a1e9a9f8cfa3 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -8,12 +8,18 @@ class ProductMultiPrice(models.Model): _description = "Product Multiple Prices" name = fields.Many2one( - comodel_name="product.multi.price.name", required=True, translate=True, + comodel_name="product.multi.price.name", + required=True, + translate=True, ) product_id = fields.Many2one( - comodel_name="product.product", required=True, ondelete="cascade", + comodel_name="product.product", + required=True, + ondelete="cascade", + ) + price = fields.Float( + digits="Product Price", ) - price = fields.Float(digits="Product Price",) company_id = fields.Many2one( comodel_name="res.company", related="name.company_id", diff --git a/product_multi_price/models/product_pricelist.py b/product_multi_price/models/product_pricelist.py index 037eee8e5270..d60bf23ff658 100644 --- a/product_multi_price/models/product_pricelist.py +++ b/product_multi_price/models/product_pricelist.py @@ -27,7 +27,10 @@ def _compute_price_rule(self, products_qty_partner, date=False, uom_id=False): class ProductPricelistItem(models.Model): _inherit = "product.pricelist.item" - base = fields.Selection(selection_add=[("multi_price", "Other Price")],) + base = fields.Selection( + selection_add=[("multi_price", "Other Price")], + ) multi_price_name = fields.Many2one( - comodel_name="product.multi.price.name", string="Other Price Name", + comodel_name="product.multi.price.name", + string="Other Price Name", ) From 221a3ae252cd0efb9e24fbcb69ed7b3bce0d4af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ernesto=20Garc=C3=ADa=20Medina?= Date: Fri, 24 Mar 2023 14:23:59 -0600 Subject: [PATCH 16/26] [MIG] product_multi_price: Migration to 15.0 --- product_multi_price/__manifest__.py | 2 +- .../migrations/13.0.1.0.0/noupdate_changes.xml | 13 ------------- .../migrations/13.0.1.0.0/post-migration.py | 11 ----------- product_multi_price/models/product_multi_price.py | 8 +++----- product_multi_price/models/product_pricelist.py | 1 + product_multi_price/security/ir.model.access.csv | 6 +++--- .../tests/test_product_multi_price.py | 10 +++++++--- product_multi_price/views/multi_price_views.xml | 4 ++-- 8 files changed, 17 insertions(+), 38 deletions(-) delete mode 100644 product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml delete mode 100644 product_multi_price/migrations/13.0.1.0.0/post-migration.py diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 7a9bce320d40..473f31a74b41 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "13.0.1.0.0", + "version": "15.0.1.0.0", "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-attribute", "category": "Product Management", diff --git a/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml b/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml deleted file mode 100644 index fde32703ce30..000000000000 --- a/product_multi_price/migrations/13.0.1.0.0/noupdate_changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - diff --git a/product_multi_price/migrations/13.0.1.0.0/post-migration.py b/product_multi_price/migrations/13.0.1.0.0/post-migration.py deleted file mode 100644 index 10bcb5bd068a..000000000000 --- a/product_multi_price/migrations/13.0.1.0.0/post-migration.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2020 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade # pylint: disable=W7936 - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.load_data( - env.cr, "product_multi_price", "migrations/13.0.1.0.0/noupdate_changes.xml" - ) diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index a1e9a9f8cfa3..f3b70f34a4b9 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -5,13 +5,11 @@ class ProductMultiPrice(models.Model): _name = "product.multi.price" + _rec_name = "name_text" _description = "Product Multiple Prices" - name = fields.Many2one( - comodel_name="product.multi.price.name", - required=True, - translate=True, - ) + name = fields.Many2one("product.multi.price.name", required=True) + name_text = fields.Char(related="name.name") product_id = fields.Many2one( comodel_name="product.product", required=True, diff --git a/product_multi_price/models/product_pricelist.py b/product_multi_price/models/product_pricelist.py index d60bf23ff658..11901accfa03 100644 --- a/product_multi_price/models/product_pricelist.py +++ b/product_multi_price/models/product_pricelist.py @@ -29,6 +29,7 @@ class ProductPricelistItem(models.Model): base = fields.Selection( selection_add=[("multi_price", "Other Price")], + ondelete={"multi_price": "set default"}, ) multi_price_name = fields.Many2one( comodel_name="product.multi.price.name", diff --git a/product_multi_price/security/ir.model.access.csv b/product_multi_price/security/ir.model.access.csv index c15ad02ac205..603077c94d32 100644 --- a/product_multi_price/security/ir.model.access.csv +++ b/product_multi_price/security/ir.model.access.csv @@ -1,4 +1,4 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"multi price","product.multi.price","model_product_multi_price","base.group_user",1,1,1,1 -"multi price name read","product.multi.price.name","model_product_multi_price_name","base.group_user",1,0,0,0 -"multi price name admin","product.multi.price.name","model_product_multi_price_name","base.group_system",1,1,1,1 +multi_price,product.multi.price,model_product_multi_price,base.group_user,1,1,1,1 +multi_price_name_read,product.multi.price.name,model_product_multi_price_name,base.group_user,1,0,0,0 +multi_price_name_admin,product.multi.price.name,model_product_multi_price_name,base.group_system,1,1,1,1 diff --git a/product_multi_price/tests/test_product_multi_price.py b/product_multi_price/tests/test_product_multi_price.py index 2922a463e4b7..048403dfc9bc 100644 --- a/product_multi_price/tests/test_product_multi_price.py +++ b/product_multi_price/tests/test_product_multi_price.py @@ -1,9 +1,9 @@ # Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestProductMultiPrice(SavepointCase): +class TestProductMultiPrice(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -16,7 +16,11 @@ def setUpClass(cls): "name": "Test Product Template", "price_ids": [ (0, 0, {"name": cls.price_field_1.id, "price": 5.5}), - (0, 0, {"name": cls.price_field_2.id, "price": 20.0}), + ( + 0, + 0, + {"name": cls.price_field_2.id, "price": 20.0}, + ), ], } ) diff --git a/product_multi_price/views/multi_price_views.xml b/product_multi_price/views/multi_price_views.xml index 6a50d8637e59..46dab3decea5 100644 --- a/product_multi_price/views/multi_price_views.xml +++ b/product_multi_price/views/multi_price_views.xml @@ -3,7 +3,7 @@ product.multi.price - + @@ -52,7 +52,7 @@ product.multi.price.name - + From 3f97ea2c000e2d6ef4c68214d606087201fef65a Mon Sep 17 00:00:00 2001 From: oca-ci Date: Mon, 10 Apr 2023 08:52:46 +0000 Subject: [PATCH 17/26] [UPD] Update product_multi_price.pot --- product_multi_price/i18n/product_multi_price.pot | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/product_multi_price/i18n/product_multi_price.pot b/product_multi_price/i18n/product_multi_price.pot index 0f7e0845c8f3..56c2c649f3e1 100644 --- a/product_multi_price/i18n/product_multi_price.pot +++ b/product_multi_price/i18n/product_multi_price.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -113,6 +113,7 @@ msgid "Price" msgstr "" #. module: product_multi_price +#: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price__name_text #: model:ir.model.fields,field_description:product_multi_price.field_product_multi_price_name__name msgid "Price Field Name" msgstr "" @@ -146,15 +147,9 @@ msgstr "" #. module: product_multi_price #: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_form_view -#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_tree_view msgid "Product Multi Price" msgstr "" -#. module: product_multi_price -#: model_terms:ir.ui.view,arch_db:product_multi_price.product_multi_price_name_tree_view -msgid "Product Multi Price Field Name" -msgstr "" - #. module: product_multi_price #: model:ir.model,name:product_multi_price.model_product_multi_price msgid "Product Multiple Prices" From 4d7f98023b17297dd0fe1cf6c95cf16332c24efa Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 10 Apr 2023 08:58:02 +0000 Subject: [PATCH 18/26] [UPD] README.rst --- product_multi_price/README.rst | 10 +++++----- product_multi_price/static/description/index.html | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index bdbeaa727f8d..421d17152c97 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -14,13 +14,13 @@ Product Multi Price :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github - :target: https://github.com/OCA/product-attribute/tree/13.0/product_multi_price + :target: https://github.com/OCA/product-attribute/tree/15.0/product_multi_price :alt: OCA/product-attribute .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-attribute-13-0/product-attribute-13-0-product_multi_price + :target: https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_multi_price :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/135/13.0 + :target: https://runbot.odoo-community.org/runbot/135/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -79,7 +79,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -113,6 +113,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/product-attribute `_ project on GitHub. +This module is part of the `OCA/product-attribute `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index 30bdbd6f3a63..86d3c679f6d9 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -367,7 +367,7 @@

    Product Multi Price

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

    This module allows to set multiple prices to products and base pricelist rules on them.

    Table of contents

    @@ -429,7 +429,7 @@

    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.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -458,7 +458,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/product-attribute project on GitHub.

    +

    This module is part of the OCA/product-attribute project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    From e770ff7a7ccd5799a24fdba45be7288c099c2ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ernesto=20Garc=C3=ADa=20Medina?= Date: Thu, 18 May 2023 12:22:59 -0600 Subject: [PATCH 19/26] [FIX] product_multi_price: remove ondelete params from product.multi.price.name --- product_multi_price/models/product_multi_price.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py index f3b70f34a4b9..ce146f52ff1a 100644 --- a/product_multi_price/models/product_multi_price.py +++ b/product_multi_price/models/product_multi_price.py @@ -43,7 +43,7 @@ class ProductMultiPriceName(models.Model): def _get_company(self): return self._context.get("company_id", self.env.company) - name = fields.Char(required=True, string="Price Field Name", ondelete="restrict") + name = fields.Char(required=True, string="Price Field Name") company_id = fields.Many2one( comodel_name="res.company", required=True, From d696050523ef744d104e4ee36d7c484cc8877405 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 19 May 2023 09:38:01 +0000 Subject: [PATCH 20/26] product_multi_price 15.0.1.0.1 --- product_multi_price/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_multi_price/__manifest__.py b/product_multi_price/__manifest__.py index 473f31a74b41..72ac6f65ac4f 100644 --- a/product_multi_price/__manifest__.py +++ b/product_multi_price/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Product Multi Price", - "version": "15.0.1.0.0", + "version": "15.0.1.0.1", "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-attribute", "category": "Product Management", From 50099f9d364545e072aeff9b0577753a52ae3550 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sun, 3 Sep 2023 15:21:38 +0000 Subject: [PATCH 21/26] [UPD] README.rst --- product_multi_price/README.rst | 15 +++--- .../static/description/index.html | 46 ++++++++++--------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/product_multi_price/README.rst b/product_multi_price/README.rst index 421d17152c97..48115ea3b9e6 100644 --- a/product_multi_price/README.rst +++ b/product_multi_price/README.rst @@ -2,10 +2,13 @@ Product Multi Price =================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:db3e0600440dcafca889e339211f83be9973bd8907045d52490e64e8787e1645 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,11 +22,11 @@ Product Multi Price .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_multi_price :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/135/15.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to set multiple prices to products and base pricelist rules on them. @@ -78,7 +81,7 @@ 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 +If you spotted it first, help us to smash it by providing a detailed and welcomed `feedback `_. Do not contact contributors directly about support or help with technical issues. diff --git a/product_multi_price/static/description/index.html b/product_multi_price/static/description/index.html index 86d3c679f6d9..d736bf143f18 100644 --- a/product_multi_price/static/description/index.html +++ b/product_multi_price/static/description/index.html @@ -1,20 +1,20 @@ - + - + Product Multi Price