Skip to content

Commit

Permalink
add compute para volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
carcaroff committed Jun 2, 2021
1 parent ba78c1e commit 7ad58dc
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions l10n_br_sale/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class AccountMove(models.Model):
('4', '4 - Transporte Próprio por conta do Destinatário'),
('9', '9 - Sem Ocorrência de Transporte')],
string=u'Modalidade do frete', default="9")
num_volumes = fields.Integer('Quant. total de volumes')
num_volumes = fields.Integer('Quant. total de volumes', compute="_compute_volumes")
stock_picking_ids = fields.Integer('Stock Pickings', compute="_compute_volumes")
quant_peso = fields.Float('Peso')
# peso_uom = fields.Many2one('uom.uom')

Expand All @@ -27,4 +28,34 @@ def _compute_nfe_number(self):
if docs:
item.nfe_number = docs[0].numero
else:
item.nfe_number = 0
item.nfe_number = 0

def _compute_volumes(self):
# if item.informacao_adicional:
# infAdProd = item.informacao_adicional
# else:
# infAdProd = ''
if item.product_id.tracking == 'lot':
pick = self.env['stock.picking'].search([
('origin', '=', self.invoice_id.origin),
('state', '=', 'done')])
for line in pick.move_line_ids:
lotes = []
# if line.product_id.id == item.product_id.id:
# for lot in line.lot_id:
# lote = {
# 'nLote': lot.name,
# 'qLote': line.qty_done,
# 'dVal': lot.life_date.strftime('%Y-%m-%d'),
# 'dFab': lot.use_date.strftime('%Y-%m-%d'),
# }
# lotes.append(lote)
# fab = fields.Datetime.from_string(lot.use_date)
# vcto = fields.Datetime.from_string(lot.life_date)
# infAdProd += ' Lote: %s, Fab.: %s, Vencto.: %s' \
# % (lot.name, fab, vcto)
# prod["rastro"] = lotes
self.write({
'num_volumes': len(lotes),
'stock_picking_ids': lotes.ids,
})

0 comments on commit 7ad58dc

Please sign in to comment.