Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I've made some custom code that needs to filter out particular purchase invoices.
The domain has to look at multiple conditions:
The invoice has to be a purchase invoice, not a sales invoice (controlled by in_invoice or out_invoice on the type field from the model)
The state has to be either open or paid, not concept.
The create_date has to be bigger, or equal, than the start_date, which is a custom field I made.
The create_date has to be smaller, or equal, than the end_date, which is a custom field I made.
When I write a domain for getting only the purchase invoices that are only in the state open or paid it'll work and it looks like this:
invoices = self.env['account.invoice'].search((['&',('type', 'in', ['in_invoice', 'in_refund']),('state', 'in', ['open', 'paid'])]))
When I write a domain to only get purchase invoices that are created after start_date and that are created before the end_date it will work fine too:
invoices = invoices.search(['&',('create_date', '>=', self.start_date), ('create_date', '<=', self.end_date)])
However, when I now want to combine those two in one statement I get incorrect results. My domain with the combination of both domains merged:
invoices = self.env['account.invoice'].search(['&', '&', ('type', 'in', ['in_invoice', 'in_refund']),('state', 'in', ['open', 'paid']), ('create_date', '>=', self.start_date), ('create_date', '<=', self.end_date)])
However when I do this the domain does not seem to look at the start_date and end_date anymore.
So, what is wrong with this domain? I thought that the polish annotation read from left to right, meaning that my first '&' tells Odoo to both comply with the invoice state AND the dates, but this does not seem to be the case?
Could anybody explain me why this is the case and what I did wrong in this domain?
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/11/16, 5:27 AM|
|Seen: 1787 times|
|Last updated: 5/11/16, 9:49 AM|