Skip to Content
Menu
This question has been flagged

Hi all, I met a trouble when inherit pos.config model

This is my models.py

class PosReport(models.Model):
    _inherit = 'pos.config'
    def _tz_get(self):
    # put POSIX 'Etc/*' entries at the end to avoid confusing users - see bug 1086728
        return [(tz, tz) for tz in sorted(pytz.all_timezones, key=lambda tz: tz if not tz.startswith('Etc/') else '_')]
    hourly_report = fields.Boolean(string="Run report", help="Turn on or off auto orders report")
    ftp_host = fields.Text(string="FTP host", size=45, help="The FTP host address")
    ftp_user = fields.Text(string="FTP username", size=45, help="The FTP host username")
    ftp_password = fields.Text(string="FTP password", size=45, help="The FTP host password")
    ftp_folder = fields.Text(string="Order folder path", help="The directory where orders will be stored")
    pax = fields.Text(string="PAX (for F&B)", default="0")
    membership_id = fields.Text(string="Membership id", default="0")
    tz = fields.Selection(_tz_get, string='Timezone', default=lambda self: self._context.get('tz'),
    help="The partner's timezone, used to output proper date and time values "
                "inside printed reports. It is important to set a value for this field. "
                "You should use the same timezone that is otherwise used to pick and "
                "render date and time values: your computer's timezone.")
    machine_id = fields.Text(string="Machine Id", size=45, help="Machine id of POS system")



And this my xml:

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <record id="hourly_report_config" model="ir.ui.view">

        <field name="name">pos.config.form.view</field>

        <field name="model">pos.config</field>

        <field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>

        <field name="sequence">1</field>

        <field name="arch" type="xml">

            <xpath expr="//sheet/group[5]" position="after">

                <group string="Hourly report configurations">

                    <field name="hourly_report" />

                    <field name="ftp_host" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="ftp_user" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="ftp_password" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="ftp_folder" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="machine_id" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="pax" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="membership_id" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                    <field name="tz" attrs="{'invisible': [('hourly_report', '=', False)]}"/>

                </group>

            </xpath>

        </field>

    </record>

</odoo>


When I click on Install button,

Odoo show me an error message. Please help me to resolve it:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 677, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 333, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo/service/model.py", line 101, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 326, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 935, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/site-packages/odoo/http.py", line 506, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/site-packages/odoo/addons/web/controllers/main.py", line 889, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/site-packages/odoo/addons/web/controllers/main.py", line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python2.7/site-packages/odoo/api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python2.7/site-packages/odoo/api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/module/module.py", line 527, in button_immediate_upgrade
    return self._button_immediate_function(type(self).button_upgrade)
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/module/module.py", line 484, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "/usr/lib/python2.7/site-packages/odoo/modules/registry.py", line 83, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/site-packages/odoo/modules/loading.py", line 335, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/usr/lib/python2.7/site-packages/odoo/modules/loading.py", line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/site-packages/odoo/modules/loading.py", line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/usr/lib/python2.7/site-packages/odoo/modules/loading.py", line 95, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python2.7/site-packages/odoo/tools/convert.py", line 845, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python2.7/site-packages/odoo/tools/convert.py", line 915, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/usr/lib/python2.7/site-packages/odoo/tools/convert.py", line 799, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/usr/lib/python2.7/site-packages/odoo/tools/convert.py", line 707, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/ir/ir_model.py", line 1190, in _update
    record.write(values)
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/ir/ir_ui_view.py", line 380, in write
    return super(View, self).write(self._compute_defaults(vals))
  File "/usr/lib/python2.7/site-packages/odoo/models.py", line 3565, in write
    self._fields[key].determine_inverse(self)
  File "/usr/lib/python2.7/site-packages/odoo/fields.py", line 1041, in determine_inverse
    getattr(records, self.inverse)()
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/ir/ir_ui_view.py", line 220, in _inverse_arch
    view.write(data)
  File "/usr/lib/python2.7/site-packages/odoo/addons/base/ir/ir_ui_view.py", line 380, in write
    return super(View, self).write(self._compute_defaults(vals))
  File "/usr/lib/python2.7/site-packages/odoo/models.py", line 3557, in write
    self._write(old_vals)
  File "/usr/lib/python2.7/site-packages/odoo/models.py", line 3708, in _write
    self._validate_fields(vals)
  File "/usr/lib/python2.7/site-packages/odoo/models.py", line 1079, in _validate_fields
    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
ParseError: "Error while validating constraint

Field `tz` does not exist

Error context:
View `pos.config.form.view`
[view_id: 1182, xml_id: hourly_report.hourly_report_config, model: pos.config, parent_id: 851]
None" while parsing /usr/lib/python2.7/site-packages/odoo/addons/hourly_report/views/views.xml:3, near
<record id="hourly_report_config" model="ir.ui.view">
        <field name="name">pos.config.form.view</field>
        <field name="model">pos.config</field>
        <field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
        <field name="sequence">1</field>
	<field name="arch" type="xml">
            <xpath expr="//sheet/group[5]" position="after">
                <group string="Hourly report configurations">
                    <field name="hourly_report"/>
                    <field name="ftp_host" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="ftp_user" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="ftp_password" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="ftp_folder" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="machine_id" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="pax" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="membership_id" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
                    <field name="tz" attrs="{'invisible': [('hourly_report', '=', False)]}"/>
		    <button>Click</button>
                </group>
            </xpath>
        </field>
    </record>
Avatar
Discard

Hi,

make sure that the model.py is called in it init file

Related Posts Replies Views Activity
0
Sep 24
202
1
Aug 24
8077
2
Dec 23
27711
0
Sep 23
352
0
Mar 23
5756