Atul Jain
Atul Jain

Reputation: 1055

How to add a field in a purchase order line and perform an action in OpenERP

I added two fields in purchase order line. It works properly and save but when I confirm the order it raises the error like

AttributeError: "Field 'product_tunch' does not exist in object 'browse_record(purchase.order, 23)'"

Here the field was added successfully but why am I getting an error when I confirm the purchase order and below is my field

_columns={
    'product_tunch':fields.float('Tunch', digits_compute=  dp.get_precision('price_subtotal')),
    'product_kt':fields.selection([('14kt','14 KT'), ('18kt','18 KT'), ('20kt','20 KT')
                                   , ('22kt','22 KT'), ('24kt','24 KT')], 'Type', 
                                   size=32,),

and my function is

def _amount_line(self, cr, uid, ids, prop, arg, context=None):
    res = {}
    cur_obj=self.pool.get('res.currency')
    tax_obj = self.pool.get('account.tax')
    for line in self.browse(cr, uid, ids, context=context):
        taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id, line.product_pc, line.order_id.partner_id)
        cur = line.order_id.pricelist_id.currency_id
        res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
        res[line.id]=(line.price_unit *line.product_qty*(line.product_tunch/100)) 
    return res

and my view file is

<record id="view_purchase_inherit_form"  model="ir.ui.view">
        <field name="name">purchase.inherit.form</field>
        <field name="model">purchase.order.line</field>
        <field name="inherit_id" ref="purcahse.view_order_form"/>
        <field name="arch" type="xml">
            <data>
                <xpath expr="//field[@name='taxes']" position="before">
                    <field name="product_tunch"/>
                    <field name="product_kt"/>
                </xpath>
            </data> 
        </field>
    </record> 

Upvotes: 0

Views: 2487

Answers (3)

reco
reco

Reputation: 3

You can try to start your server once using this syntax:

 openerp-server -c path/to/your/conf.file -d your_database -u module_to_update

Upvotes: 0

Akil Akil T
Akil Akil T

Reputation: 31

Check the spelling of purchase in views file 4 th line

Upvotes: 1

ImportError
ImportError

Reputation: 148

  1. restart server and update module to see effects
  2. if not, check sql table by pgAdmin and in purchase_order check if there are 'product_tunch' column
  3. Have you written in your .py _inherit = 'purchase.order' above your colums? Have you added your file in init.py?

I haven't more ideas

Upvotes: 0

Related Questions