Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Editable Cost Price on Validated and Paid Invoice lines?

By
Gill Potter
on 1/26/16, 11:35 AM 528 views

I am using Odoo v8.

I have a situation in a services company where the final cost of providing a service may not be known until after the Invoice has been issued (validated) and sometimes it will have been paid.

An estimate of the cost price can be entered on the Sales Order Line. I have written a module to pass the Cost Price (price_unit) field to the Invoice Line on creation of the Invoice. Cost Price is editable whilst the Invoice is in “Draft” state. Once the Invoice is validated, none of the Invoice Line is editable. I need to make a change which will allow just my new Cost Price field to remain editable.

I can see in account_invoice.py that the invoice line is treated as one field which is only editable in the draft status :-

invoice_line = fields.One2many('account.invoice.line', 'invoice_id', string='Invoice Lines',

    readonly=True, states={'draft': [('readonly', False)]}, copy=True)

So my question is how can I allow editing of an individual field on the invoice line with any status?

 

Gill Potter
on 2/4/16, 1:17 AM
0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 1/27/16, 12:51 AM

Gill,

In order to make separate fields editable under a one2many fields, u need to make changes at xml part as:

<field name='invoice_line'>

<tree>

<field name='cost_price_field' attrs="{'readonly': [('parent.[STATE_FIELD IN ACCOUNT.INVOICE]', '=', 'draft')]}"/>

<field name='abc' attrs="{'readonly': [('parent.[STATE_FIELD IN ACCOUNT.INVOICE]', '=', '[STATE]')]}"/>

<field name='def' attrs="{'readonly': [('parent.[STATE_FIELD IN ACCOUNT.INVOICE]', '=', '[STATE]')]}"/>

</tree>

</field>

this will make the individual field in invoice_line field(one2many to account.invoice.line) to be readonly on the basis of state of current invoice object.

Hope it Helps!

Thank you for your suggestion. I am struggling to apply it as I need to add it to my xpath expression and I want to be able to EDIT the field rather than not edit it. So readonly needs to be set to false for parent.state of open and paid. My xml is here <xpath expr="//field[@name='invoice_line']/tree/field[@name='price_unit']" position="after">

Gill Potter
on 1/27/16, 4:55 AM

Gill,
Please keep it like this
< xpath expr="//field[@name='invoice_line']/tree/field[@name='price_unit']" position="attribute">
<attribute name="attrs">{'readonly': [('state', 'not in ', ['open', 'paid'])]}</attribute>
</xpath>
Hope i got u right!

Pawan
on 2/4/16, 1:20 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/26/16, 11:35 AM
Seen: 528 times
Last updated: 2/4/16, 1:18 AM