Skip to content

Instantly share code, notes, and snippets.

@lukebranch
Created January 24, 2015 03:03
Show Gist options
  • Save lukebranch/0ca9665175816d0c9f3f to your computer and use it in GitHub Desktop.
Save lukebranch/0ca9665175816d0c9f3f to your computer and use it in GitHub Desktop.
Here's a link to my answer here:
https://github.com/OdooCommunityExamples/B2B_Add_To_Cart_Example
I've put together an incredibly basic module with only the functionality needed for what you have asked in this question.
I have added the view change (that snippet) into an xml file in a subdirectory called 'views' to organise it properly. Fundamentally you just need an __init__.py file, an __openerp__.py file with your dependencies (in this case website_sale, etc.), and your view definition (in this case /views/B2B_Add_To_Cart.xml).
Inside this XML file you just need to place your <template> tags nested inside the opening and closing <openerp> and <data> tags. Remember that you are working with XHTML/XML, and therefore opening and closing tags must be properly nested or you will run into problems.
In regards to the t-if statements, you are simply stating in Qweb that it should use this tag only if the user id in the database in the database (not user_id.partner_id.name) is equal to (==) the name 'Public user'.
Therefore whatever nested tags are inside that <a> tag there, they will only be displayed to users if there user id is not 'Public user'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment