Skip to Content
Menu
This question has been flagged

I've made a custom field in product.template to select a product quality, based on a Many2one relationship with qualities.

Product:

qualities_id = field.Many2one(comodel_name="qualities", string="quality")

In the class: qualities there is a One2Many relationship with the class: quality.supplier.

Qualities:

reseller_ids = fields.One2many('supplierinfo', 'product_qual_id', 'Supplier')

Here we can select a quality type e.g. ( id=16 type=B321 ). This quality type (16) can have more then one supplier. So in supplierinfo we have the field product_qual_id (id = 16) that holds multi suppliers (id = 24, 25, 26)

Supplierinfo:

product_qual_id = fields.Many2one('qualities', 'Quality Template')

Supplierinfo holds suppliers and each supplier holds more then one quantity and price. There is a relationship between supplierinfo and supplier prices using the field suppinfo_id.

pricelist_ids = fields.One2many('supplierprice', 'suppinfo_id', 'Supplier Price')

Because of this relationship, supplierprice: suppinfo, holds more then one quantity and corresponding price based on supplierinfo_id. Field that holds these records:

Supplierprice:

suppinfo_id = fields.Many2one('supplierinfo', 'Supplier information')


Qualities = ( id=16 type=B321 ). This quality type (16) can have more then one supplier. So in supplierinfo we have the field product_qual_id (id = 16) that holds multi suppliers (id = 24, 25, 26) where Record id: 24 in relation to supplierprice has multi qty and prices:

  1. supplierprice id=30 supplierinfo id=24 qty=200, price=285
  2. supplierprice id=31 supplierinfo id=24 qty=300, price=265
  3. supplierprice id=32 supplierinfo id=24 qty=500, price=248

With additional automation, I need the price from supplierprice, based on (less or more) quantity in the main product. (product.template, price). Can anyone push me in the right direction. How can I get the price from supplierprice into a (new) field in my product.template?

Avatar
Discard
Related Posts Replies Views Activity
1
Dec 19
8506
1
Mar 23
781
0
Dec 22
1505
0
Jun 21
1838
0
Feb 21
2912