POS订单产品总数

时间:2017-11-07 14:35:47

标签: openerp odoo-8 odoo-9 odoo-10

我的目标是在产品表单视图中添加一个字段,该字段将显示使用POS购买此产品的时间。真的坚持这个,并很高兴有一个想法如何做到这一点。

Thread 3finished
Thread 4finished
Thread 1finished
Thread 2finished
[1470, 2794, 4343, 5924, 7388, 9015, 10533, 12064, 13713, 15672, 17354, 18916, 20524, 22086, 23370, 24982]
[1464, 2782, 4325, 5900, 7358, 8979, 10491, 12016, 13659, 15612, 17288, 18844, 20446, 22002, 23280, 24886]
[1629, 3112, 4820, 6560, 8183, 9969, 11646, 13336, 15144, 17262, 19103, 20824, 22591, 24312, 25755, 27526]
[1466, 2786, 4331, 5908, 7368, 8991, 10505, 12032, 13677, 15632, 17310, 18868, 20472, 22030, 23310, 24918]
[1487, 2828, 4394, 5992, 7473, 9117, 10652, 12200, 13866, 15842, 17541, 19120, 20745, 22324, 23625, 25254]
[1570, 2994, 4643, 6324, 7888, 9615, 11233, 12864, 14613, 16672, 18454, 20116, 21824, 23486, 24870, 26582]
[1345, 2544, 3968, 5424, 6763, 8265, 9658, 11064, 12588, 14422, 15979, 17416, 18899, 20336, 21495, 22982]
[1622, 3098, 4799, 6532, 8148, 9927, 11597, 13280, 15081, 17192, 19026, 20740, 22500, 24214, 25650, 27414]
[1557, 2968, 4604, 6272, 7823, 9537, 11142, 12760, 14496, 16542, 18311, 19960, 21655, 23304, 24675, 26374]
[1477, 2808, 4364, 5952, 7423, 9057, 10582, 12120, 13776, 15742, 17431, 19000, 20615, 22184, 23475, 25094]
[1447, 2748, 4274, 5832, 7273, 8877, 10372, 11880, 13506, 15442, 17101, 18640, 20225, 21764, 23025, 24614]
[1473, 2800, 4352, 5936, 7403, 9033, 10554, 12088, 13740, 15702, 17387, 18952, 20563, 22128, 23415, 25030]
[1727, 3308, 5114, 6952, 8673, 10557, 12332, 14120, 16026, 18242, 20181, 22000, 23865, 25684, 27225, 29094]
[1483, 2820, 4382, 5976, 7453, 9093, 10624, 12168, 13830, 15802, 17497, 19072, 20693, 22268, 23565, 25190]
[1575, 3004, 4658, 6344, 7913, 9645, 11268, 12904, 14658, 16722, 18509, 20176, 21889, 23556, 24945, 26662]
[1474, 2802, 4355, 5940, 7408, 9039, 10561, 12096, 13749, 15712, 17398, 18964, 20576, 22142, 23430, 25046]

1 个答案:

答案 0 :(得分:1)

尝试以下解决方案:

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'))