hi all,
below are both Model (.py) and View (xml) files, when I run it from custom Menu and toggle off, instead of Update and set it to False it Deletes record... what I made mistake? is it due to widget i used? or anythig else? please guide.
Python file:
from odoo import models, fields
class ServiceTypes(models.Model):
_name = 'tests.servicetypes'
_rec_name = 'name'
_description = "Tests Service Types and Services"
name = fields.Char(string="Services Types", required=True)
active = fields.Boolean(string="Active?", default=True)
service_type_ids = fields.One2many('tests.services', 'service_type_id')
class Services(models.Model):
_name = 'tests.services'
_rec_name = 'name'
_description = "Tests Services"
name = fields.Char(string="Service Name", required=True)
service_type_id = fields.Many2one('tests.servicetypes', string="Service Type", required=True)
active = fields.Boolean(string="Active?", default=True)
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Services Master Detail Form -->
<record model="ir.ui.view" id="testsservicetypes_form_view">
<field name="name">testsservicetypes.form</field>
<field name="model">tests.servicetypes</field>
<field name="arch" type="xml">
<form string="Service Type">
<sheet>
<group>
<field name="name"/>
<field name="active" widget="boolean_toggle"/>
</group>
<notebook>
<page string="Services">
<field name="service_type_ids">
<tree editable="bottom" string="Services">
<field name="name"/>
<field name="active" widget="boolean_toggle"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="testsservicetypes_tree_view">
<field name="name">testsservicetypes.tree</field>
<field name="model">tests.servicetypes</field>
<field name="arch" type="xml">
<tree string="Service Types">
<field name="name"/>
<field name="active" widget="boolean_toggle"/>
</tree>
</field>
</record>
</odoo>
regards