Skip to Content
Menu
This question has been flagged
1 Reply
2828 Views

I can change unit price when drafting an invoice, and I'd like to add a form field to set the cost price as well. How may I accomplish that?    

Avatar
Discard
Hello Mr Niyas,

I hope you don't mind me emailing you, but my Odoo forum karma is not enough to comment on your answer.

Can you be more specific about which model I need to import in order to expose the cost entry in the data field? Is there any documentation that records all these? And, which file must I edit for the invoice?

On Wed, Feb 14, 2018 at 7:14 AM Niyas Raphy <niyasraphyk@gmail.com> wrote:

A new answer on Set cost price for products added to draft invoice has been posted. Click here to access the post :

See post

--
Niyas Raphy


Sent by Odoo S.A. using Odoo.

Best Answer

Hi,

To add a new field you can  inherit the form and add a new field using xpath.

In Python :

First of all you have to inherit the model and add the  field to corresponding  model

from odoo import models, fields

class NameForClass(models.Model):
_inherit = "model_name"

new_field_name = fields.Char(string="Cost")

In XML:

<record id="give_an_id_for_record" model="ir.ui.view">  
<field name="name">a_name_here</field>
<field name="model">model_name</field>
<field name="inherit_id" ref="external_id_of_original_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name_of_existing_field']" position="after">
             <field name="new_field_name"/>
</xpath>

</field>
</record>

Have a look at this video too : Additional field to existing view in odoo 10

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
133
0
Mar 23
863
1
Mar 23
1830
3
Dec 22
2929
2
Jul 22
6008