Skip to content

Commit

Permalink
[IMP] Only show the widget when we can weigh
Browse files Browse the repository at this point in the history
  • Loading branch information
chienandalu committed Sep 20, 2024
1 parent 61ebc28 commit 66b1fd9
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 4 deletions.
105 changes: 105 additions & 0 deletions stock_weighing_remote_measure/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_weighing_remote_measure
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-17 09:39+0000\n"
"PO-Revision-Date: 2024-07-17 11:41+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: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.4\n"

#. module: stock_weighing_remote_measure
#: model_terms:ir.ui.view,arch_db:stock_weighing_remote_measure.weighing_wizard_form_view
msgid ""
"<span><i class=\"fa fa-info-circle\" role=\"image\"/> You need to configure "
"a default remote device in your user preferences to be able to start "
"measuring remotely</span>"
msgstr ""
"<span><i class=\"fa fa-info-circle\" role=\"image\"/> Necesita configurar "
"un dispositivo remoto por defecto en sus preferencias de usuario para poder "
"comenzar a pesar de forma remota</span>"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/js/weight_record_form_widget.esm.js:0
#, python-format
msgid "Choose a device:"
msgstr "Escoja un dispositivo:"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Device info"
msgstr "Información del dispositivo"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/js/weight_record_form_widget.esm.js:0
#, python-format
msgid "Discard"
msgstr "Descartar"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Manual tare"
msgstr "Tara manual"

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__measure_device_id
msgid "Measure Device"
msgstr "Dispositivo de medición"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Minus"
msgstr "Menos"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Plus"
msgstr "Más"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "REAL:"
msgstr "REAL:"

#. module: stock_weighing_remote_measure
#: model:ir.model,name:stock_weighing_remote_measure.model_weighing_wizard
msgid "Record weights over detailed operations"
msgstr "Grabar pesos en operaciones detalladas"

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "TARE:"
msgstr "TARA:"

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__uom_id
msgid "Uom"
msgstr "UdM"

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__weight_with_widget
msgid "Weight"
msgstr "Peso"
103 changes: 103 additions & 0 deletions stock_weighing_remote_measure/i18n/stock_weighing_remote_measure.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_weighing_remote_measure
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-17 09:38+0000\n"
"PO-Revision-Date: 2024-07-17 09:38+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: stock_weighing_remote_measure
#: model_terms:ir.ui.view,arch_db:stock_weighing_remote_measure.weighing_wizard_form_view
msgid ""
"<span><i class=\"fa fa-info-circle\" role=\"image\"/> You need to configure "
"a default remote device in your user preferences to be able to start "
"measuring remotely</span>"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/js/weight_record_form_widget.esm.js:0
#, python-format
msgid "Choose a device:"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Device info"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/js/weight_record_form_widget.esm.js:0
#, python-format
msgid "Discard"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Manual tare"
msgstr ""

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__measure_device_id
msgid "Measure Device"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Minus"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "Plus"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "REAL:"
msgstr ""

#. module: stock_weighing_remote_measure
#: model:ir.model,name:stock_weighing_remote_measure.model_weighing_wizard
msgid "Record weights over detailed operations"
msgstr ""

#. module: stock_weighing_remote_measure
#. openerp-web
#: code:addons/stock_weighing_remote_measure/static/src/xml/weight_record_form_widget.xml:0
#, python-format
msgid "TARE:"
msgstr ""

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__uom_id
msgid "Uom"
msgstr ""

#. module: stock_weighing_remote_measure
#: model:ir.model.fields,field_description:stock_weighing_remote_measure.field_weighing_wizard__weight_with_widget
msgid "Weight"
msgstr ""
4 changes: 4 additions & 0 deletions stock_weighing_remote_measure/wizards/weighing_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class WeighingWizard(models.TransientModel):
readonly=True,
)
uom_id = fields.Many2one(comodel_name="uom.uom", compute="_compute_uom_id")
# HACK: We need to force this relation. If we just duplicate the field declaration
# in the view with different `attrs` invisibility domain it doesn't have the
# expected effect. TODO: check if it works in >=16
weight_with_widget = fields.Float(related="weight", readonly=False)

@api.depends("product_id", "selected_move_line_id")
def _compute_uom_id(self):
Expand Down
25 changes: 21 additions & 4 deletions stock_weighing_remote_measure/wizards/weighing_wizard_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,30 @@
<field name="weight" position="before">
<field name="measure_device_id" invisible="1" />
<field name="uom_id" invisible="1" />
<div
class="alert alert-info"
attrs="{'invisible': ['|', ('measure_device_id', '!=', False), ('has_weight', '=', False)]}"
>
<span><i
class="fa fa-info-circle"
role="image"
/> You need to configure a default remote device in your user preferences to be able to start measuring remotely</span>
</div>
</field>
<field name="weight" position="attributes">
<attribute name="widget">remote_measure_form</attribute>
<!-- Override to set your preferred tares -->
<attribute
name="options"
>{'remote_device_field': 'measure_device_id', 'uom_field': 'uom_id', 'tares': [{'tare':'0.05', 'name': '50 gr.'}, {'tare': '0.1', 'name': '100 gr.'}, {'tare': '0.2', 'name': '200 gr.'}, {'tare': '0.5', 'name': '500 gr.'}]}</attribute>
name="attrs"
>{'invisible': [('has_weight', '!=', False), ('measure_device_id', '!=', False)]}</attribute>
</field>
<field name="weight" position="after">
<field
name="weight_with_widget"
class="form-control-lg text-center text-info o_input_weight"
nolabel="1"
attrs="{'invisible': ['|', ('measure_device_id', '=', False), ('has_weight', '=', False)]}"
widget="remote_measure_form"
options="{'remote_device_field': 'measure_device_id', 'uom_field': 'uom_id', 'tares': [{'tare':'0.05', 'name': '50 gr.'}, {'tare': '0.1', 'name': '100 gr.'}, {'tare': '0.2', 'name': '200 gr.'}, {'tare': '0.5', 'name': '500 gr.'}]}"
/>
</field>
</field>
</record>
Expand Down

0 comments on commit 66b1fd9

Please sign in to comment.