Skip to Content
Menu
This question has been flagged

We have a 3-layer model for product qualities. Model 1 is the main model which contains product quality info.

#-------------------------------------------------------------------------------
#  product qualities
#-------------------------------------------------------------------------------
class qualities(models.Model):
    _name = 'qualities'
    _description = 'Sheet Qualities'


    name = fields.Char('Quality', required=True, help='Quality name')
    reseller_ids = fields.One2many('qualityinfo', 'product_qual_id', 'Quality Supplier')  

Each quality-type has multiple suppliers connectect by: reseller_ids = fields.One2many('qualityinfo', 'product_qual_id', 'Quality Supplier')

#-------------------------------------------------------------------------------
# Quality supplier
#-------------------------------------------------------------------------------



class qualityinfo(models.Model):
    _name = 'qualityinfo'
    _description = "Information about a quality supplier"

    name = fields.Many2one('res.partner', 'Supplier', required=True,domain =    [('supplier','=',True)], ondelete='cascade')
    product_code = fields.Char('Supplier Product Code')
    sequence = fields.Integer('Sequence')
    min_qty = fields.Float('Minimal Quantity', required=True)
    product_qual_id = fields.Many2one('qualities', 'Quality Template', ondelete='cascade', select=True)
    pricelist_ids = fields.One2many('pricelist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist', copy=True)
    company_id = fields.Many2one('res.company','Company',select=1)



#-------------------------------------------------------------------------------
# Quality suppliers pricelist
#-------------------------------------------------------------------------------  
class pricelist_partnerinfo(models.Model):
    _name = 'pricelist.partnerinfo'

    name = fields.Char('Description')
    suppinfo_id = fields.Many2one('qualityinfo', 'Partner Information', required=True, ondelete='cascade')
    min_quantity = fields.Float('Quantity', required=True)
    price = fields.Float('Unit Price', required=True)

    _order = 'min_quantity asc'

So far so good. But now we need a single price from the pricelist into a price field in qualities. We have tried the following, without any result:

def _get_price(self):
quality_id = self._context.get('product_qual_id' False)
if product_qual_id:
    price = self.env['qualityinfo'].browse(product_qual_id).with_context(pricelist.partnerinfo=self.id).price self.price = price

I need the price of pricelist.partnerinfo in quality to calculate total cost.

Avatar
Discard

send me your custom module to this mail i will hep you prasanth.logicious@gmail.com

Author Best Answer

@ prasanth, I wonder if you had a change at looking at my module-sources. Any help is welcome.

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 17
2700
3
Jul 16
18691
1
Apr 15
12075
0
May 16
2474
0
Apr 24
397