0
votes

I did some changes in product.template and override the field like this

list_price = fields.Float(copy=False, string='Sale Price',  store=True,compute='_calculate_sale_price',
                              help='compute cost as per gun_dealer', default=0.00)

and the compute methods is like

@api.multi
    @api.depends('profit_per_unit', 'estimated_shipping_charges'
                 , 'flat_rate_charges', 'list_price')
    def _calculate_sale_price(self):

        if self.category_parent_id == 33:
                self.list_price = self.standard_price+self.profit_per_unit+ \
                                  self.estimated_shipping_charges

        else:
            self.list_price = self.standard_price+self.profit_per_unit-self.collected_shipping_charges + \
                                  self.flat_rate_charges

But after doing this the Unit Price from sale order's order line is not grabbing value of Sales Price from product.template

1

1 Answers

0
votes

THIS IS NOT A SOLUTION. But I cant really put this suggestion in a comment.

I am not sure if you should use list_price in your depends decorator arguments. Try placing some logging in and see what is happening when you load the page.

import logging
_logger = logging.getLogger(__name__)

@api.multi
@api.depends('profit_per_unit', 'estimated_shipping_charges', 'flat_rate_charges')
def _calculate_sale_price(self):
    _logger.info("EXECUTING _calculate_sale_price() function")
    if self.category_parent_id == 33:
        _logger.info("CATEGORY PARENT ID IS 33!")
        _logger.info("list_price = {} + {} + {}".format(self.standard_price, self.profit_per_unit, self.estimated_shipping_charges))
        self.list_price = self.standard_price+self.profit_per_unit + self.estimated_shipping_charges
    else:
        _logger.info("CATEGORY PARENT ID IS NOT 33! REPEAT NOT")
        _logger.info("list_price = {} + {} + {} - {} + {}".format(self.standard_price, self.profit_per_unit, self.collected_shipping_charges, self.flat_rate_charges))
        self.list_price = self.standard_price + self.profit_per_unit -self.collected_shipping_charges + self.flat_rate_charges