Ich möchte eine Baumansicht innerhalb der Formularansicht geben, dass ich ein one2many Feld geben muss.Wie man one2many Feld geben, um Baumansicht in Formularansicht von odoo zu erhalten?
Ich habe one2many Feld gegeben und ich bekomme auch die Baumansicht in der Formularansicht.
Aber das Problem ist, wenn ich einige Werte in der Baumansicht der Formularansicht geben und während ich den Datensatz gespeichert Es zeigt diesen Fehler
Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set
[object with reference: make - make]
Wenn ich keine Werte im Baum geben sie anzeigen und speichern Der Datensatz zeigt keinen Fehler.
Meine Codes sind
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 and 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"/>
ich gerade Baumansicht in der Formularansicht nicht Abhängigkeit mit one2many Feld benötigen.
Wie kann ich das erreichen?
Dank ...