OpenERP - Add fields only to some products inside a Category - odoo

I'm setting up OpenERP v7. I know how to create modules and so on.
The problem is that not all the products will have the same fields. For example for T-shirts I would have Color, Size. But for belts I will have: Material, Length (as an example).
I know the option of using multi-variants but it's very very confusing. It creates a new column for Dimension values but then the Name of the product has also the Dimension values in it. It's very annoying.
Also, the access to the Product Templates is only accessible from the Sales module, so our Procurement department doesn't have access to it.
I would like more if a pre-defined template appears after a user selects the category of the product. Since products in same category will have the same field requirements.

I would suggest you the following.
Define all fields in your model (color, size, material etc.). Then hide the from views according to the product category.
To hide some field based on the category_id value you may try something like this:
<field name="some_field"
attrs="{'invisible': [('category_id', 'not in', [1, 2, 3])]}"/>

I found out a better way to solve it, which is by using the module product_custom_attributes, downloadable from: https://www.odoo.com/apps/7.0/product_custom_attributes/
This module let's me create sets of attributes that can be later loaded into the product, I can also filtrate the products depending on the attribute value which is cool.

Related

Adding new product with category tree - specific price problems

I installed an add-on for bulk action (called ba_importer v 1.1.24), I upload an Excel file with my data and create a group of products.
I can set the categories' tree or manually add ID of main categories and associated. I tried with no luck to use the tree features (like Home/Products/etc) and so I use all the ID of main category and all the associated. The result is a product with the correct categories set, but with no specific price from the customer group linked to a category.
I tried to edit a single product, remove all categories and set it one by one (set one, save, set one, save etc.) and then the specific price from the group linked to a category appears to the product.
Is there a better solution? I'm thinking about make a personal PHP page that reads an Excel file and sets all the information about the product, but I'm scared to face the same problem with the specific price. 
There is no such thing as "category-related specific price",
if you have specific prices tied to customer groups , these are created as a result of the add/update product action with ps_specific_price DB entries having id_group with your restricted ID.
It is likely that the bulk module acts directly with DB queries to speed up things and bypasses this operation, I've seen this behaviour with those kind of modules in the past.
Since you are talking of a paid add-on, I would definitely seek help from the developer.

Database design for a product-configurator

I have been asked by a customer to develop a "product configurator", and i need some inputs on how to handle the DB part of the project.
Each product can have a subset of different precreated attributes.
The minimum is 1 attribute, but there is no maximum.
Some attributes have dependencies/relationships with other attributes.
Eg. If the product is a chair, you need to choose the material (wood, plastic, metal), and you need to choose which type of legs the chair shoud have.
If the Product is a cabinet, you still need to choose a material, but instead of legs there will be different doors to choose from etc.
Each of these attributes might have subattributes. Eg. the door has a color, a size and a doorhandle.
Then the door handle has a material, a type and so on.
This ultimatly ends up in a multi-layered attribute-tree.
By itself this isnt too complicated to code, however the customer wants to be able to manage (Create, update and delete) all products, attributes and relationships between attributes, within the webapp.
So coding the relationship-part isn't a viable solution.
I have gone with a EAV model to facilitate the "potential unlimited" amount of attributes each product can have.
But i am struggling to figure out how to go about the "attribute relationships".
A simplified version of my DB design looks like this:
If each product could subscribe to groups of attributes that is legal. Then each attribute belongs to a group like "wood group".
Then the user could set the groups of attributes against a product that should need to be answered to configure a product.
With regards managing a tree, you could use a column type of hierarchyid . Or construct an outline string as key field.
An outline for example
1.
1.1.
1.1.1.
1.2.
2.
2.1.

What is the best relational schema (or ERD) of dynamically nested objects?

I am trying to draw the table diagram of a product listing web application.
Application logic:
Admin user will create:
Categories (must be dynamically created by admin user),
Category's attributes (must be dynamically created by admin user),
Selection of Category attribute's options (must be dynamically created by admin user)
User will post a product under a specific category and must choose category attribute's option for each category attributes to successfully save the product.
Example: Admin creates category "food"
"food" has its attribute "meal_type" and "sugar".
"meal_type" has its options "breakfast", "lunch" and "dinner".
"sugar" has its options "with-sugar" and "non-sugar".
and now user can post his product "pizza" under category "food".
When user chosen "food" category, he must see its attributes "meal_type" and "suger"
and then must set those option values.
For example, "pizza"'s category is "food" and "meal_type"="breakfast", "sugar"="with-sugar".
And I want to call these option values together with product details when selecting these items.
I have made this (removed non-related fields)
but I am not sure this will work and be efficient at same time.
What is the most efficient relational schema (or ERD) for case like this?
I could help, but I don't really understand what exactly a user is supposed to do? Is he supposed to order products on the website? If so, maybe the naming of the tables should be different, eg "order_product" instead of "product"?
and as for the performance, at this stage and with this structure there should be no problems.

Odoo many2one field related to one2many

I'm confused by something in the Odoo source code. On the stock.picking model, there is a product_id field. It's defined as a related field via move_lines.product_id.
move_lines is a one2many field. I don't understand how a many2one field can use a one2many field as its relation.
Here's a link to the source code I'm referring to:
https://github.com/odoo/odoo/blob/316ffc80147de076b28c6156ac679dd90da0935e/addons/stock/models/stock_picking.py#L288
You can see that product_id is defined as:
product_id = fields.Many2one('product.product', 'Product', related='move_lines.product_id')
And move_lines is defined as:
move_lines = fields.One2many('stock.move', 'picking_id', string="Stock Moves", copy=True)
What is the purpose of this definition? How is it even allowed?
If I look at the value of the product_id field for a picking, it returns the product for the first move line in the picking, not all of products.
However, if I search the picking tree view with a custom filter on the Product field, for example, Product contains 'Product Name', the results seem to account for all products in the picking. If I search for any product in the picking the picking appears in the view, it's not just limited to the first product.
Can someone explain this behavior? There is even a note in the source code that the product_id field is specifically for searching, so I'm thinking there is some magic functionality I never knew about.
It's not related to the One2many field, it's related to the move_lines object (which is stock.move model), and takes from that model product_id field, which has a type of Many2one. So, everything is correct. Here's the code.

How to set customer specific pricelists which is common in B2B

How to set customer specific pricelists which is common in B2B.
Pricelists per customer or organisation.
If this not exist out of the box, should i tag pricelists witch dynamic properties or add a custom condition, what is tag (TagsContainsCondition).
It dosnt seems to be possible to add own conditions for pricelist assignments!?
I guess this is the best method to override if you dont want to send to many pricelists to the client:
PricingServiceImpl.EvaluatePriceLists
This is already possible out of the box. Simply go to price list assignments and then add a new condition: "Tags contains". In the frontend, you'll need to populate the tags passed to the pricing engine with whatever values you'd like, for instance it can be customerid, or organization name.
You can also extend and add your own conditions as described here: http://docs.virtocommerce.com/display/vc2devguide/Composing+dynamic+conditions.