You are on page 1of 1

related?

=onchange+readonly="1"+force_save="1"-khi dùng readonly,có thể dữ liệu 0


lưu xuống dtb, phải thêm force_save

many2one change based on another field


@api.onchange('contact_city_id')
def onchange_contact_city_id(self):
for rec in self:
return {'domain': {'contact_district_id': [('city_id', '=',
rec.contact_city_id.id)]}}
-khi thay đổi thành phố(contact_city_id) trong contact, thì
quận(contact_district_id) trong contact sẽ thay đổi theo
thành phố - city_id nằm trong module của quận

--------------------Tạo button kế bên cancel in sales-----------


<record model="ir.ui.view" id="button_field">
<field name="name">Button Test</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<button name="action_cancel" position="after">
<button name="action_add_point" string="Test" type="object"/>
</button>
</field>
</record>

------------------Tạo button trong action------------


<!-- <record id="action_add_point" model="ir.actions.server">-->
<!-- <field name="name">Test</field>-->
<!-- <field name="type">ir.actions.server</field>-->
<!-- <field name="model_id" ref="model_sale_order" />-->
<!-- <field name="binding_model_id" ref="model_sale_order" />-->
<!-- <field name="state">code</field>-->
<!-- <field name="code">records.action_confirm()</field>-->
<!-- </record>-->

---------------------get id từ form từ một child trong form đó


self.env['sale.order'].browse(self._context.get('active_ids', []))

----------------------inherit_id____________________
--kế thừa từ record,template,... cha nhưng sửa children không ảnh hưởng đến cha
phải thêm primary
- record: mode="primary"
-

You might also like