POS 订单产品总计
POS order product total
我的目标是在产品表单视图中添加一个字段,以显示使用 POS 购买此产品的次数。真的坚持这个,并且很高兴知道如何做到这一点。
class Product(models.Model):
_inherit = 'product.product'
pos_product_order_total = fields.Char(
string='Product POS Orders', compute='_product_pos_orders')
def _product_pos_orders(self):
Order = self.env['pos.order']
for product in self:
domain = [('product_id', '=', product.id)]
for o in Order.search(domain):
pass
尝试以下解决方案:
class Product(models.Model):
_inherit = 'product.product'
pos_product_order_total = fields.Char(
string='Product POS Orders', compute='_product_pos_orders')
def _product_pos_orders(self):
OrderLine = self.env['pos.order.line']
for product in self:
domain = [('product_id', '=', product.id)]
product.pos_product_order_total = sum(OrderLine.search(domain).mapped('qty'))
我的目标是在产品表单视图中添加一个字段,以显示使用 POS 购买此产品的次数。真的坚持这个,并且很高兴知道如何做到这一点。
class Product(models.Model):
_inherit = 'product.product'
pos_product_order_total = fields.Char(
string='Product POS Orders', compute='_product_pos_orders')
def _product_pos_orders(self):
Order = self.env['pos.order']
for product in self:
domain = [('product_id', '=', product.id)]
for o in Order.search(domain):
pass
尝试以下解决方案:
class Product(models.Model):
_inherit = 'product.product'
pos_product_order_total = fields.Char(
string='Product POS Orders', compute='_product_pos_orders')
def _product_pos_orders(self):
OrderLine = self.env['pos.order.line']
for product in self:
domain = [('product_id', '=', product.id)]
product.pos_product_order_total = sum(OrderLine.search(domain).mapped('qty'))