[MERGE] forward port branch saas-11 up to a989680
This commit is contained in:
@@ -4,10 +4,18 @@
|
|||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.addons import decimal_precision as dp
|
from odoo.addons import decimal_precision as dp
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools.safe_eval import safe_eval as eval
|
|
||||||
from odoo.tools.float_utils import float_round
|
from odoo.tools.float_utils import float_round
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import operator as py_operator
|
||||||
|
|
||||||
|
OPERATORS = {
|
||||||
|
'<': py_operator.lt,
|
||||||
|
'>': py_operator.gt,
|
||||||
|
'<=': py_operator.le,
|
||||||
|
'>=': py_operator.ge,
|
||||||
|
'==': py_operator.eq,
|
||||||
|
'!=': py_operator.ne
|
||||||
|
}
|
||||||
|
|
||||||
class Product(models.Model):
|
class Product(models.Model):
|
||||||
_inherit = "product.product"
|
_inherit = "product.product"
|
||||||
@@ -258,7 +266,7 @@ class Product(models.Model):
|
|||||||
# TODO: Still optimization possible when searching virtual quantities
|
# TODO: Still optimization possible when searching virtual quantities
|
||||||
ids = []
|
ids = []
|
||||||
for product in self.search([]):
|
for product in self.search([]):
|
||||||
if eval(str(product[field]) + operator + str(value)):
|
if OPERATORS[operator](product[field], value):
|
||||||
ids.append(product.id)
|
ids.append(product.id)
|
||||||
return [('id', 'in', ids)]
|
return [('id', 'in', ids)]
|
||||||
|
|
||||||
@@ -281,7 +289,7 @@ class Product(models.Model):
|
|||||||
domain_quant.append(('package_id', '=', package_id))
|
domain_quant.append(('package_id', '=', package_id))
|
||||||
quants_groupby = self.env['stock.quant'].read_group(domain_quant, ['product_id', 'qty'], ['product_id'])
|
quants_groupby = self.env['stock.quant'].read_group(domain_quant, ['product_id', 'qty'], ['product_id'])
|
||||||
for quant in quants_groupby:
|
for quant in quants_groupby:
|
||||||
if eval('%s %s %s' % (quant['qty'], operator, value)):
|
if OPERATORS[operator](quant['qty'], value):
|
||||||
product_ids.add(quant['product_id'][0])
|
product_ids.add(quant['product_id'][0])
|
||||||
return list(product_ids)
|
return list(product_ids)
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Cilene Oliveira cilene.oliveira@akretion.com https://github.com/cileneoliveira
|
|||||||
David Beal david.beal@akretion.com https://github.com/bealdav
|
David Beal david.beal@akretion.com https://github.com/bealdav
|
||||||
Florian da Costa florian.dacosta@akretion.com https://github.com/florian-dacosta
|
Florian da Costa florian.dacosta@akretion.com https://github.com/florian-dacosta
|
||||||
Magno Barcelo da Costa magno.costa@akretion.com.br https://github.com/mbcosta
|
Magno Barcelo da Costa magno.costa@akretion.com.br https://github.com/mbcosta
|
||||||
|
Raphaël Reverdy raphael.reverdy@akretion.com https://github.com/hparfr
|
||||||
Raphaël Valyi raphael.valyi@akretion.com https://github.com/rvalyi
|
Raphaël Valyi raphael.valyi@akretion.com https://github.com/rvalyi
|
||||||
Renato Lima renato.lima@akretion.com https://github.com/renatonlima
|
Renato Lima renato.lima@akretion.com https://github.com/renatonlima
|
||||||
Sebastien Beau sebastien.beau@akretion.com https://github.com/sebastienbeau
|
Sebastien Beau sebastien.beau@akretion.com https://github.com/sebastienbeau
|
||||||
|
|||||||
Reference in New Issue
Block a user