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

Hello all,

We are on Odoo 10.

I have declared a new many2one field customer_of_division_id in the model sale.order and in the model account.invoice.

I have added the field on the form view of both models this way :

<field name="customer_of_division_id"/>


My field is displayed like this in a new sale order :



And my field is displayed like this on a new invoice :



Why is it not the same on both? How to avoid all the address displayed on the second one?


EDIT #1 : Here is all the code

In the Python

class SaleOrder(models.Model):
_inherit = "sale.order"
    customer_of_division_id = fields.Many2one(related="partner_id.customer_of_division_id", string='Customer of the division')

class AccountInvoice(models.Model):
_inherit = "account.invoice"
    customer_of_division_id = fields.Many2one(related="partner_id.customer_of_division_id", string='Customer of the division', readonly=True)

In the XML

<record id="invoice_form" model="ir.ui.view">
    <field name="name">account.invoice.form.inherit.vtm2</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form" />
    <field name="arch" type="xml">
        <xpath expr="//field[@name='partner_shipping_id']" position="attributes">
            <attribute name="domain">['&amp;',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
        </xpath>
        <field name="payment_term_id" position="after">
            <field name="customer_of_division_id"/>
        </field>
     </field>
</record>
<record id="view_order_form" model="ir.ui.view">
    <field name="name">sale.view.order.form.inherit.vtm2</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form" />
    <field name="arch" type="xml">
        <xpath expr="//field[@name='partner_shipping_id']" position="attributes">
            <attribute name="domain">['&amp;',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
        </xpath>
         <field name="payment_term_id" position="after">
             <field name="customer_of_division_id" attrs="{'readonly': [('state', 'not in', ('draft','sent'))]}"/>
         </field>
    </field>
</record>

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

Hi, can you paste the code of your field definition and also xml inheritance code? How you pass value to the Many2one field on invoice?

Tác giả

If I remove the 'Readonly=True' in my Python declaration, It is well displayed. Thanks. But it doesn't help me to understand why all the address was displayed..???!!! Big thanks

Sorry. I thought that it was an easy problem. I have put my code above. Thanks.

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

For me it shows just partner without address after saving the invoice record. Can u just try without readonly=True.

I am not sure about that behaviour in readonly mode.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
2011
4
thg 7 23
2460
1
thg 9 21
9749
1
thg 1 24
17316
3
thg 2 17
26796