私はone2manyフィールドを与える必要があるために、フォームビューの内部にツリービューを与えたいと思います。odooのフォームビューでツリービューを取得するone2manyフィールドを与える方法は?
私はone2manyフィールドを与えて、私はまた、フォームビューでツリービューを取得します。
しかし、私は、フォームビューのツリービューでいくつかの値を与えると私はレコードを保存しながら、私はそれを表示し、保存し、ツリー内の任意の値を与えていない、このエラー
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]
を示していたときに問題がありますレコードにはエラーが表示されません。
私のコードは、私はちょうど、フォームビューではないone2manyフィールドと任意の依存関係のツリービューを必要とする
<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"/>
の.xml
の.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
です。
どうすればこの問題を解決できますか?
おかげで...