i want give tree view inside form view need give one2many field.
i have given one2many field , tree view in form view.
but problem when give values in tree view of form view , while saving record shows error
integrity error operation cannot completed, due following: - deletion: may trying delete record while other records still reference - creation/update: mandatory field not correctly set [object reference: make - make]
when not giving values in tree view , save record not show error.
my codes are
.py
class vansdent_bill(osv.osv): _name = "vansdent.bill" _description = "vans dent" _columns = { 'name': fields.char('year', required=true), 'make': fields.char('make', required=true), 'model': fields.char('model', required=true), 'customer': fields.many2one('res.partner', 'customer', domain=[('customer', '=', true)]), 'serviceid': fields.many2one('vans.dent', 'service id', select=true), 'vin':fields.char('vin'), 'description':fields.char('description'), 'part':fields.char('part'), 'price':fields.char('price'), 'quantity':fields.char('qty'), 'labour':fields.char('labour'), 'paint':fields.char('paint'), 'other':fields.char('other'), 'empty': fields.char('empty', ondelete='cascade'), 'order_line': fields.one2many('vansdent.bill', 'empty', 'order lines'), 'type':fields.char('type'), 'hours':fields.char('hours'), 'rate':fields.char('rate/hr'), 'total':fields.char('total'), 'tax':fields.char('taxable'), 'tamount':fields.char('taxable amount'), 'atax':fields.char('tax'), 'ntotal':fields.char('net total'), 'desc':fields.text('descriptiom'), 'empty2': fields.char('empty', ondelete='cascade'), 'order_line2': fields.one2many('vansdent.bill', 'empty2', 'order lines'), } def vansdentbill_service(self, cr, uid, ids, serviceid=false, context=none): res = {} if serviceid: service_obj = self.pool.get('vans.dent') rec = service_obj.browse(cr, uid, serviceid) res = {'value': {'name': rec.year.name, 'model': rec.model.name, 'make': rec.make.name,'vin':rec.vin}} else: res = {'value': {'name': false, 'model': false, 'make': false,'vin':false}} return res
.xml
<record id="vans_service_form_view" model="ir.ui.view"> <field name="name">vans.service.form</field> <field name="model">vansdent.bill</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="billing"> <sheet> <group> <group> <field name="serviceid" on_change="vansdentbill_service(serviceid)"/> <field name="customer"/> <field name="vin"/> </group> <group> <field name="name" /> <field name="make" /> <field name="model"/> </group> </group> <notebook> <page string="service"> <field name="order_line"> <tree string="service details" editable="bottom"> <field name="description"/> <field name="part"/> <field name="price"/> <field name="quantity"/> <field name="labour" /> <field name="paint"/> <field name="other"/> </tree> </field> <separator string="totals"/> <field name="order_line2"> <tree string="bill details" editable="bottom"> <field name="type"/> <field name="hours"/> <field name="rate"/> <field name="total"/> <field name="tax" /> </tree> </field> <group class="oe_subtotal_footer oe_right"> <field name="tamount" widget="monetary" options="{'currency_field': 'currency_id'}"/> <field name="atax" widget="monetary" options="{'currency_field': 'currency_id'}"/> <div class="oe_subtotal_footer_separator oe_inline"> <label for="ntotal"/> </div> <field name="ntotal" nolabel="1" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/> </group> <div class="oe_clear"/> <field name="desc" class="oe_inline" placeholder="terms , conditions..."/> </page> </notebook> </sheet> </form> </field> </record> <record model="ir.ui.view" id="vans_service_tree_view"> <field name="name">vans.service.tree</field> <field name="model">vansdent.bill</field> <field name="type">tree</field> <field name="arch" type="xml"> <tree string="service"> <field name="serviceid"/> <field name="customer"/> <field name="vin"/> <field name="name"/> <field name="make"/> <field name="model"/> </tree> </field> </record> <record model="ir.actions.act_window" id="vans_service_buy_form"> <field name="name">vansdent.service</field> <field name="res_model">vansdent.bill</field> </record> <menuitem name="billing" parent="base.menu_sales" id="vansdent_service_menu_mainform" action="vans_service_buy_form" sequence="6"/>
i need tree view in form view not dependency one2many field.
how can achieve this?
thanks...
the error regarding make
field, set required
. trying create/update record without setting value it. not displayed in tree view, unless there default value, or other method set it, there no way user it, hence error:
- creation/update: mandatory field not correctly set
[object reference: make - make]
Comments
Post a Comment