Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
2081 Lượt xem

I have successfully extended res.partner (_inherit='res.partner') with partner specific fields via a new model "my_buyer". These new fields in "my_buyer" are viewable within res.partner and a view was added with "ref='base.view_partner_form'" So that I can update "my_buyer" from the Contacts App.

This all works well.

I'd now like to take/use those new, partner specific, fields from "my_buyer" and have them transfer over to the sale.order.form so that I can present that information on CRM/quotations sent to the partner/customer/buyer.

my_buyer is basically attributes of an individual buyer. When they receive a quotation from me, I want them to see/recall what their attribute value is. I want that attribute tied to their partner record, because that attribute follows along with them through our relationship and any future quotation, purchase from us.

Because my_buyer fields are already within res.partner, and res.partner is tied to sale.order sort of, I thought it's be easy to call the my_buyer fields, but I'm getting errors.

Any help/enlightenment is appreciated.

d

Ảnh đại diện
Huỷ bỏ

Please show your qweb and the traceback.

Câu trả lời hay nhất

Hi,

If you are looking to inherit and add new fields to an existing view/model, you can do it like this,


In the python side,

class SaleOrderInherit(models.Model):
_inherit = 'sale.order'

test_field = fields.Char(string='Test Name')

then in the XML,

<record id="sale_order_inherit" model="ir.ui.view">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="test_name"/>
</field>
</field>
</record>

The above code will add a new field to the model sale.order, similarly you can add in res.partner model.

You can see here: How To Inherit And Add Field to Existing Views In Odoo


Also if you like to add the new fields from the user interface, without a module, see this: How to Add Custom Field From User Interface In Odoo


Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Ermin,

I was just adding my new fields via the UI Views, but I'm assuming from your request, that I should be using inherited views, like I've done with res.partner?

like this?:

<record id = "mybuy_form_view" model = "ir.ui.view" >

        <field name = "name" > mybuy.form </field>

        <field name = "model" > sale.order </field>

        <field name = "inherit_id" ref = "sale.view_order_form" > </field>

            <field name = "arch" type = "xml" >

Ảnh đại diện
Huỷ bỏ