pycharm-odoo icon indicating copy to clipboard operation
pycharm-odoo copied to clipboard

Singleton error inspection

Open trinhanhngoc opened this issue 3 years ago • 2 comments

For example, the following code can lead to a singleton error:

    @api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id')
    def _compute_amount(self):
        """
        Compute the amounts of the SO line.
        """
        for line in self:
            price = self.price_unit * (1 - (line.discount or 0.0) / 100.0) 

self.price_unit => error

trinhanhngoc avatar Aug 13 '22 15:08 trinhanhngoc

Nice, but please don't force the use of ensure_one.

jcfernandez-890825 avatar Aug 13 '22 16:08 jcfernandez-890825

Nice, but please don't force the use of ensure_one.

Yup! :))

trinhanhngoc avatar Aug 13 '22 16:08 trinhanhngoc