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

How to add a custom bonus quantity field in Sale order line?

By
Odoo
on 5/3/15, 3:06 AM 563 views

I have a custom product quantity (bonus_field) in sale order line,

Scenario..

I want to give bonus to all customers as product like 

When  I sell X  product I want to give  Y of 2,3,.4 or  etc.. will give as Bonus product.Also I need to reduce the inventory of this bonus product


---------------------------

eg. Product A quantity 100 already in stock

when I sell A of 50 ,I want to give 2  A product as  bonus.

Then I need to reduce 52 from stock(50 product+2 bonus prodcut,this 2 product dont have price it will go as free).

I have added code like below.................


class SaleOrderLine(osv.osv):

    '''

    Sale Order Line

    '''

    _inherit = "sale.order.line"

    

    _columns = {

               'bonus_new':fields.integer('Bonus')

    }

.......................................................


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

            <field name="name">account.order.promo.form</field>

            <field name="model">account.invoice</field>

            <field name="type">form</field>

            <field name="inherit_id" ref="account.invoice_form" />

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

               <!--  <xpath expr="/form/sheet/notebook/page/group/group/field[@name='origin']" position="after">

                    <field name="coupon_code" />

                </xpath> -->

                

                <xpath expr="/form/header/button[@name='invoice_open']" position="after">

                    <button name="apply_promotions" type="object" states="draft" string="Click For Bonus" />

                </xpath>

                

                

                 <xpath

                    expr="//field[@name='invoice_line']/tree/field[@name='product_id']" position="after">

                     

                      <field name="bonus_new"/>

                      

                </xpath>

                

            </field>   


do this code work???

Baiju
on 5/3/15, 7:29 AM

No

Odoo
on 5/3/15, 7:31 AM

Hi Baiju I am trying to add a functionality..Bu its not working

Odoo
on 5/3/15, 7:32 AM

can you please post the code for additional functionality..

Baiju
on 5/3/15, 1:37 PM

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: 5/3/15, 3:06 AM
Seen: 563 times
Last updated: 5/3/15, 1:51 PM