1234567891011121314151617181920212223242526 |
- # -*- coding: utf-8 -*-
- ##############################################################################
- from openerp import tools, api
- from openerp import api, fields, models, _
- # class PickingTotalQty(models.Model):
- # _inherit = 'purchase.order'
- #
- # tot_purchase_qty = fields.Float(compute='_calculate_purchase_qty', string='Total Cantidad Comprado', help="Total cantidad comprado")
- #
- # def _calculate_purchase_qty(self):
- # for rs in self:
- # sumqty = 0
- # for line in rs.order_line:
- # sumqty += line.product_qty
- # rs.tot_purchase_qty = sumqty
- class PurchaseOrder(models.Model):
- _inherit = 'purchase.order'
- tot_purchase_qty = fields.Float(string='Cantidad de Productos de Compra', compute='_calculate_purchase_qty')
- @api.depends('order_line.product_qty')
- def _calculate_purchase_qty(self):
- for order in self:
- order.tot_purchase_qty = sum(order.order_line.mapped('product_qty'))
|