Search code examples
odooodoo-11

How to write python code to get sum of all sales orders between certain periods in compute field in Odoo?


I'm fairly new to Odoo and trying to calculate my employee's salary based on monthly income of my business.

So now I'm trying to write a Python code in compute field of salary rule, and have no idea how to get sales orders between, say, June 21 to July 20 and get the sum of total prices.

Can anyone please help me out? Maybe some example codes would be very helpful! Thank you in advance!


Solution

  • You can use self.env['model.name']

    self.env['model.name'].search([your_condition])
    EX:
    self.env['model.name'].search([('field1', '>=', 'value1'), ('field2', '<=', 'value2')])