Add fields on webshop and send data to quotation order?

Hi guys,

I've been looking at extending and improving the Odoo webshop. I'm now at the point that I would love to have the ability to let users fill in text fields on a product form (in the webshop). The idea is that they have fields, just like in the back-end that they can fill in.

When the user clicks on Add to Cart the values should be saved and eventually when the user clicks on the pay now button these extra details should be added in the back-end on the sales order / quotation, in these fields that I made: (in the model sale.order.line)

 class sample(models.Model):
    _inherit = 'sale.order.line'
    height = fields.Integer()
    width = fields.Integer()
    numberOfUnits = fields.Integer()

It looks like the @http.route('/shop/payment/validate') in (addons/website_sale/controllers) is responsible for dealing with the data after the user clicks on the Pay Now button. So my questions:

  • How can I add textfields with labels on the view

  • How can I send the data to fields that I've custom added in the model sale.order.line?

My initial idea was to add a type under addons/website_sale/models in under the product_attribute class like this:

 class product_attribute(osv.Model):
    _inherit = "product.attribute"
    _columns = {
        'type': fields.selection([('radio', 'Radio'), ('select', 'Select'), ('color', 'Color'), ('hidden', 'Hidden'), ('textfield','Textfield')], string="Type", type="char"),
    _defaults = {
        'type': lambda *a: 'radio',

But I have no clue how to further extend this so that a new type is available for product variants.

Any information / help / details are very welcome!


I have managed to add quite a lot thanks to Jérémy but am now stuck on creating a dropdown on sale.order level. I've inherited the sale.order model and added a Many2one there. This Many2one leads to a new model I've added to save all colours in, so it can be added dynamically.

 class sale_line_colorpicker(models.Model):
    _name = 'sale.order.colorpicker'
    _description = dropdown for order/quotation (pick colors)'
    name = fields.Char('Name', required=True)

#Add many2one (for color dropdown) to sale.order
class aa_custom_colorpicker_in_salemodel(models.Model):
    _inherit = 'sale.order'
    kleurenpicker = fields.Many2one('sale.order.colorpicker','Kleur')

This colorpicker (with all values) should be shown once on the 'Extra' page in the webshop and when the user selects a color it should be added to the order so the automatically generated order in the back-end also has the correct colour filled in. It should be added in this method somehow.. But the colorpicker is on sale.order level and all the rest on sale.order.line level..

 class sale_order_line_your_extension(osv.osv):
    _inherit = "sale.order.line"
    #Color should still be migrated from quotation/order > invoice!
    def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
        ret = super(sale_order_line_your_extension, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=False, context=context)
	hoogte =  if line.hoogte:
            hoogte = line.hoogte
        ret['hoogte'] = hoogt ret['kleurenpicker'] = kleur
        return ret 

How can I now add a dropdown to the webshop page 'Extra' and how can I get the values from the webshop to my quotation?



Luke Branch


Interesting question. I've subscribed to this thread, however if I figure out how to do it myself i'll definitely post back with what I find.

@Luke, I'll soon have to tackle this since I can't delay it much longer so I guess I'll have to dive in to this one myself.. If I find anything / get it working I will let you know too! Any guidance, tips or ideas though? Anything that could point me in the correct way would be nice.

hi yenthe, not sure that variant is the best way... you will generate many new product.product... If i understand your use case, you want just ask more informations on some product... Perso, I will make a new step before shipping, and add for each product/sale_order_line which need more info, a form to complete the missing infos... This page post the form to a new route. (don't forget to break the default link: cart -> checkout ->billing to cart -> extra_info -> checkout -> billing) I don't know your delay, but i'm developping this extra step by default in the next Odoo community version... (which by default allow only x_ fields on sale order)...

Luke Branch


I'll try and take a look at this on Saturday, however i'm pretty busy at the moment and can't promise i'll be able to.

I'd recommend perhaps digging into the code in website_crm (Odoo core module for contact form), and perhaps the modules related to the new form builder in (master dev branch):



To see if you can make any sense of how it is accomplished there. As from what I understand of your description it is similar in function to what you are trying to accomplish.

I would recommend looking into adding an access rights layer to your module once you figure it out as well, to make sure you've got restrictions on what can and can't be accessed from the frontend as well, just to be safe:

Luke Branch


I think I read your question incorrectly the first time around. Regarding the two bullet points I'll try to take a look at this on Saturday and see if I can make any progress on it.

@Luke, Thanks for the detailed response & feedback. I've started extending the example of Jérémy and it works pretty good! I'll respond on his answer to so keep an eye out if you want to learn from this too. By the way if you have questions you can contact me too (if I can help you) :) @Jérémy you're right about the product.product and variants being swamped with data, I like your approach more.

Luke Branch


Thanks, i'd be interested to see what you come up with. Please post back with more info once you've worked out what you want to do, as i'd be very interested to see what you've done.

This could be a very useful feature for textile and print companies with online ordering, as well as a load of other applications.

@Luke, Will do! I'm actually building this for ordering print-related products on this webshop! I'll keep you updated, I might write a blog post about this too :)

Luke Branch


Brilliant, I look forward to hearing how your project progresses. Most web-to-print type modules i've seen around for Magento and other platforms are ridiculously over-priced, while often offering only basic functionality (eg. custom sizing attributes with calculated fields according to size/finish, and a basic HTML5 editor for basic layouts).

There are a handful of half-decent web-based image editors out there that could potentially be integrated into an Odoo module, that could allow print shops to build a viable web-to-print shop for basics like t-shirts, business cards, company stationery and the like.

I think Odoo is the perfect platform for this type of functionality due to it's robust nature and extendability, and I anticipate that an extendable module/app achieving some basic web-to-print functionality (even just calculated fields and an upload facility for designs) would be in quite high demand if it was either a reasonably priced LGPL3 module, or a community module.

Luke Branch

I thought this might be a useful reference for you if you're interested in in-browser editors for web-to-print:

@Luke, I won't go very far with this module though. I'll only extend the current sale.order module and add some of those fields to the webshop so the user has an extra page where he can choose/fill in details. So nothing to advanced but it will give other people inside in to the basics too :)

1 Answer
Best Answer

I don't know if it will help you...

But if I have well understand your needs, it should... 

Ps: Hope that I see you to Odoo Experience :) (

-- PART 2 --

For your question 1: Use checkbox...

Just using bootstrap: see here an example 

For your question 2: Switch step...

Just changing xpath... But be aware, that you cannot easily change the href from a in /shop/car, because other view use it...

Maybe playing with sequence ? Else, I use a js hack to test now... 

For you question 3: write on field

It should work... I have just tested with 'product_qty_uom' : 10 and it works... So check maybe your value, you have probably a typo in get param when you compute your new qty... print the value before ?

-- PART 3 --

I Fixed view order with a clean teplate (no js)

Like I said in part 2, play with sequence fix the problem...

See my commit

-- PART 4 --

See my commit

It should work... info will be on sale order... 

ps: _prepare_order_line_invoice_line is only to prepare values to be write on Invoice...


Just a proto, need to be improved :)

Thanks Jérémy! I've both accepted & upvoted your answer. It doesn't do everything I need but gives me a very good insight how to continue / extend this! I have three questions that I hope you can answer. 1) How can I make fields in the webshop that are not digit? I tried with type="boolean" to get checkboxes for example but that simply gives me a textfield. 2) Would it be much work to change the flow from Review Order > Shipping & Billing > Extra to Review Order > Extra > Shipping & Billing? I think that makes more sense. 3) How exactly should I calculate and fill on field in the back-end with data from the webshop? I tried it like this: 'product_uom_qty': (int(post.get('%s-%s' % (, 'hoogteWebshop'))) * int(post.get('%s-%s' % (, 'breedteWebshop'))) / 10000 * 1 but the field product_uom_qty is not updated/calculated in the backend..

On a sidenote: yes I will be at Odoo Experience! You're free to come have a chat at our stand (VanRoey), you're always welcome there :) And I will attend that session for sure, I'm not used to the website part yet.

I have just updated my previous answer... See part 2 ! Have a good evening...

Hi Jérémy! Changing the order seems to be something you'd better don't do, seems to give some annoying problems.. so I'll leave that for what it is for now. The solution about checkboxes was really stupid, should've figured that one out by myself :) And for the calculation: I've got that working now too! There only rests me one question now.. I've created a new model (sale.order.line.colorpicker) which simply holds color names. All those names are filled in a dropdown on the quotation/sale order screen in the following field: kleurenpicker (this is a Many2one from sale.order to sale.order.line.colorpicker). This colorpicker should be shown on the extra screen but only once, above all the products, and this should then be passed from the webshop to the correct quotation / order.. any ideas? :s If you need more information or code let me know. And thanks a lot for all this help! I will soon try to create a blog post about such things to help others too :)

Hi for the step order, See part 3, I have fixed without JS the inherit... About your last point I have some doubts about what you are trying to do... I understand: "Only one color for one order", but the model name suggests an other thing "sale.order.line.colorpicker"... (and not sale.order.colorpicker)... So if you can provide the code, it will help me :)

@Jeremy I've updated my question to add more details and some of the code!

@yenthe, branch updated

Thanks again Jérémy! I've decided to share my whole module now so you can see what I have. The flow on the webshop should go like this: Review Order > Shipping & Billing > Extra > Payment > Confirmation. Or even better might be to leave Payment out. Could you tell me what I'm doing wrong or missing to make this flow work? Also, the selected color does not seem to show up on the order either :s Think you could have a look? Thanks for all the help.


@yenthe, See your first pull request :)