diff --git a/web_widget_one2many_product_picker/README.rst b/web_widget_one2many_product_picker/README.rst index 10fb845f2..b0687d670 100644 --- a/web_widget_one2many_product_picker/README.rst +++ b/web_widget_one2many_product_picker/README.rst @@ -86,6 +86,7 @@ Widget options: * show_discount > Enable/Disable display discount (False by default) * show_subtotal > Enable/Disable show subtotal (True by default) * auto_save > Enable/Disable auto save (False by default) +* auto_save_delay > The time (in milliseconds) to wait after the last interaction before launching the autosave (1500 by default) * all_domain > The domain used in 'All' section ([] by default) If using auto save feature, you should keep in mind that the "Save" and "Discard" buttons @@ -95,6 +96,7 @@ Widget options: * ignore_warning > Enable/Disable display onchange warnings (False by default) * instant_search > Enable/Disable instant search mode (False by default) * trigger_refresh_fields > Fields in the main record that dispatch a widget refresh (["partner_id", "currency_id"] by default) +* auto_focus > Keep the focus on the search box after performing a search (True by default) All widget options are optional. Notice that you can call '_' method to use translations. This only can be used with this widget. @@ -215,7 +217,8 @@ Known issues / Roadmap ====================== * Translations in the xml 'options' attribute of the field that use the widget can't be exported automatically to be translated -* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects. +* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects +* sale.order onchanges that affects to "order_line" subfields will be ommitted to increase the performance Bug Tracker =========== @@ -244,6 +247,8 @@ Contributors * Pedro M. Baeza * David Vidal +* Giovanni Serra + Maintainers ~~~~~~~~~~~ diff --git a/web_widget_one2many_product_picker/__init__.py b/web_widget_one2many_product_picker/__init__.py index f0e48908c..28345b82a 100644 --- a/web_widget_one2many_product_picker/__init__.py +++ b/web_widget_one2many_product_picker/__init__.py @@ -1,2 +1,3 @@ # Copyright 2020 Tecnativa - Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/web_widget_one2many_product_picker/i18n/es.po b/web_widget_one2many_product_picker/i18n/es.po index 8caba4d46..244f08d42 100644 --- a/web_widget_one2many_product_picker/i18n/es.po +++ b/web_widget_one2many_product_picker/i18n/es.po @@ -6,118 +6,143 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-02-17 13:45+0000\n" -"Last-Translator: claudiagn \n" -"Language-Team: none\n" +"POT-Creation-Date: 2022-03-04 18:46+0000\n" +"PO-Revision-Date: 2022-03-04 19:49+0100\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" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.0\n" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:6 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 +#, python-format +msgid "Accept" +msgstr "Aceptar" + +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 #, python-format msgid "Add" msgstr "Añadir" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js:193 +#: code:addons/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js:0 #, python-format msgid "All" msgstr "Todo" +#. module: web_widget_one2many_product_picker +#: model:ir.model,name:web_widget_one2many_product_picker.model_base +msgid "Base" +msgstr "" + #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:35 +#: code:addons/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js:0 +#, python-format +msgid "By Name" +msgstr "Por Nombre" + +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't create the %s: Duplicated product! (Already in database)" +msgstr "No se puede crear el %s: Producto duplicado! (Actualmente en la base de datos)" + +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't create the %s: Duplicated product! (Inside query)" +msgstr "No se puede crear el %s: Producto duplicado! (En la petición)" + +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't write the %s: Duplicated product! (Already in database)" +msgstr "No se puede escribir el %s: Producto duplicado! (Actualmente en la base de datos)" + +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 +#, python-format +msgid "Discard" +msgstr "Descartar" + +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 #, python-format msgid "Groups" msgstr "Grupos" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:43 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 +#, python-format +msgid "LOADING..." +msgstr "CARGANDO..." + +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 #, python-format msgid "Lines" -msgstr "Línias" +msgstr "Líneas" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:67 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 #, python-format msgid "Load More" -msgstr "Carga más" +msgstr "Cargar más" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_modif_price.xml:11 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_modif_price.xml:0 #, python-format -msgid "Price:" -msgstr "Precio:" - -#. module: web_widget_one2many_product_picker -#: model:ir.model,name:web_widget_one2many_product_picker.model_product_product -msgid "Product" -msgstr "Producto" +msgid "Price" +msgstr "Precio" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:13 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 #, python-format msgid "Remove" msgstr "Eliminar" #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:23 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 #, python-format msgid "Search..." msgstr "Buscar..." #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:58 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 #, python-format msgid "Subtotal:" msgstr "Subtotal:" -#. module: web_widget_one2many_product_picker -#: model:ir.model.fields,help:web_widget_one2many_product_picker.field_product_product__image_variant_medium -msgid "" -"This field holds the image used as image for the product variantor product " -"image medium, limited to 512x512px." -msgstr "" -"Aquest camp conté la imatge que s'utilitza com a imatge per al mitjà " -"d'imatge del producte que varia el producte, limitada a 512x512px." - -#. module: web_widget_one2many_product_picker -#: model:ir.model.fields,help:web_widget_one2many_product_picker.field_product_product__image_variant_big -msgid "" -"This field holds the image used as image for the product variantor product " -"image, limited to 1024x1024px." -msgstr "" -"Aquest camp conté la imatge que s'utilitza com a imatge per al mitjà " -"d'imatge del producte que varia el producte, limitada a 1024x1024px." - -#. module: web_widget_one2many_product_picker -#: model:ir.model.fields,field_description:web_widget_one2many_product_picker.field_product_product__image_variant_big -msgid "Variant Image Big (Computed)" -msgstr "Imagen variante grande (calculada)" - -#. module: web_widget_one2many_product_picker -#: model:ir.model.fields,field_description:web_widget_one2many_product_picker.field_product_product__image_variant_medium -msgid "Variant Image Medium (Computed)" -msgstr "Imagen variante media (calculada)" - #. module: web_widget_one2many_product_picker #. openerp-web -#: code:addons/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js:341 +#: code:addons/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js:0 #, python-format msgid "[No widget %s]" msgstr "[Sin widget %s]" -#~ msgid "Add 1" -#~ msgstr "Añadir 1" +#~ msgid "HTTP Routing" +#~ msgstr "Ruta HTTP" + +#~ msgid "Pricelist Item" +#~ msgstr "Item de Lista de precios" + +#~ msgid "Product" +#~ msgstr "Producto" diff --git a/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot b/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot index b2273e96f..721e08cab 100644 --- a/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot +++ b/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-03-04 18:46+0000\n" +"PO-Revision-Date: 2022-03-04 18:46+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,6 +15,13 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 +#, python-format +msgid "Accept" +msgstr "" + #. module: web_widget_one2many_product_picker #. openerp-web #: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 @@ -27,6 +36,11 @@ msgstr "" msgid "All" msgstr "" +#. module: web_widget_one2many_product_picker +#: model:ir.model,name:web_widget_one2many_product_picker.model_base +msgid "Base" +msgstr "" + #. module: web_widget_one2many_product_picker #. openerp-web #: code:addons/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js:0 @@ -34,6 +48,32 @@ msgstr "" msgid "By Name" msgstr "" +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't create the %s: Duplicated product! (Already in database)" +msgstr "" + +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't create the %s: Duplicated product! (Inside query)" +msgstr "" + +#. module: web_widget_one2many_product_picker +#: code:addons/web_widget_one2many_product_picker/models/base.py:0 +#, python-format +msgid "Can't write the %s: Duplicated product! (Already in database)" +msgstr "" + +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:0 +#, python-format +msgid "Discard" +msgstr "" + #. module: web_widget_one2many_product_picker #. openerp-web #: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 @@ -41,6 +81,13 @@ msgstr "" msgid "Groups" msgstr "" +#. module: web_widget_one2many_product_picker +#. openerp-web +#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 +#, python-format +msgid "LOADING..." +msgstr "" + #. module: web_widget_one2many_product_picker #. openerp-web #: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml:0 diff --git a/web_widget_one2many_product_picker/models/__init__.py b/web_widget_one2many_product_picker/models/__init__.py new file mode 100644 index 000000000..0e4444933 --- /dev/null +++ b/web_widget_one2many_product_picker/models/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/web_widget_one2many_product_picker/models/base.py b/web_widget_one2many_product_picker/models/base.py new file mode 100644 index 000000000..86a1cd305 --- /dev/null +++ b/web_widget_one2many_product_picker/models/base.py @@ -0,0 +1,60 @@ +# Copyright 2022 Tecnativa - Alexandre D. Díaz +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import _, api, models +from odoo.exceptions import ValidationError + + +class BaseModel(models.BaseModel): + _inherit = "base" + + @api.model + def _check_product_picker_duplicated_products(self, vals_list): + relation = self.env.context.get("product_picker_relation") + if relation != self._name or not len(vals_list): + return + product_field = self.env.context.get("product_picker_product_field") + product_ids = [ + values[product_field] for values in vals_list if product_field in values + ] + num_products = len(product_ids) + if not num_products: + return + elif num_products != len(set(product_ids)): + raise ValidationError( + _("Can't create the %s: Duplicated product! (Inside query)") % relation + ) + relation_field = self.env.context.get("product_picker_relation_field") + # All records have the same 'relation id' when created with the product picker + relation_id = vals_list[0][relation_field] + # When write maybe need get the value from the record + if not relation_id: + field_obj = self[relation_field] + if field_obj: + relation_id = relation_id.id + has_product = ( + self.search( + [ + (relation_field, "=", relation_id), + (product_field, "in", product_ids), + ], + count=True, + limit=1, + ) + != 0 + ) + if has_product: + raise ValidationError( + _("Can't create the %s: Duplicated product! (Already in database)") + % relation + ) + + @api.model_create_multi + def create(self, vals_list): + """Avoid create lines that have a product currently used when use the product picker""" + self._check_product_picker_duplicated_products(vals_list) + return super().create(vals_list) + + def write(self, values): + """Avoid write lines that have a product currently used when use the product picker""" + self._check_product_picker_duplicated_products([values]) + return super().write(values) diff --git a/web_widget_one2many_product_picker/readme/CONFIGURE.rst b/web_widget_one2many_product_picker/readme/CONFIGURE.rst index 9d6350245..e938b788d 100644 --- a/web_widget_one2many_product_picker/readme/CONFIGURE.rst +++ b/web_widget_one2many_product_picker/readme/CONFIGURE.rst @@ -44,7 +44,7 @@ Widget options: * show_discount > Enable/Disable display discount (False by default) * show_subtotal > Enable/Disable show subtotal (True by default) * auto_save > Enable/Disable auto save (False by default) -* all_domain > The domain used in 'All' section ([] by default) +* auto_save_delay > The time (in milliseconds) to wait after the last interaction before launching the autosave (1500 by default) If using auto save feature, you should keep in mind that the "Save" and "Discard" buttons will lose part of its functionality as the document will be saved every time you @@ -53,6 +53,7 @@ Widget options: * ignore_warning > Enable/Disable display onchange warnings (False by default) * instant_search > Enable/Disable instant search mode (False by default) * trigger_refresh_fields > Fields in the main record that dispatch a widget refresh (["partner_id", "currency_id"] by default) +* auto_focus > Keep the focus on the search box after performing a search (True by default) All widget options are optional. Notice that you can call '_' method to use translations. This only can be used with this widget. diff --git a/web_widget_one2many_product_picker/readme/ROADMAP.rst b/web_widget_one2many_product_picker/readme/ROADMAP.rst index 0e3fe6e62..47177187e 100644 --- a/web_widget_one2many_product_picker/readme/ROADMAP.rst +++ b/web_widget_one2many_product_picker/readme/ROADMAP.rst @@ -1,2 +1,3 @@ * Translations in the xml 'options' attribute of the field that use the widget can't be exported automatically to be translated -* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects. +* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects +* sale.order onchanges that affects to "order_line" subfields will be ommitted to increase the performance diff --git a/web_widget_one2many_product_picker/static/description/index.html b/web_widget_one2many_product_picker/static/description/index.html index 823f5446b..f7fa79025 100644 --- a/web_widget_one2many_product_picker/static/description/index.html +++ b/web_widget_one2many_product_picker/static/description/index.html @@ -3,7 +3,7 @@ - + Web Widget One2Many Product Picker