Skip to content

Commit

Permalink
criacao de nfe.volume na nfe
Browse files Browse the repository at this point in the history
  • Loading branch information
carcaroff committed Jun 7, 2021
1 parent 7ad58dc commit f6f47c8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
10 changes: 10 additions & 0 deletions l10n_br_eletronic_document/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,18 @@ def _create_product_eletronic_document(self, move, products):
vals['document_line_ids'] = move._prepare_eletronic_line_vals(products)
vals.update(self.sum_line_taxes(vals))
nfe = self.env['eletronic.document'].create(vals)
self._compute_nfe_volumes(nfe, move)
nfe._compute_legal_information()

def _compute_nfe_volumes(self, nfe, move):
self.env['nfe.volume'].create({
'eletronic_document_id': nfe.id,
'quantidade_volumes': move.quantidade_volumes,
'peso_liquido': move.peso_bruto,
'peso_bruto': move.peso_bruto,
})


def _create_related_doc(self, vals):
related_move_id = self.env['account.move'].search([
('reversal_move_id', 'in', self.id)], limit=1)
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ # pylint: disable=C8101,C8103
"name": "Odoo Next - Enable tax calculations on Sale",
"description": "Enable Tax Calculations",
"version": "13.0.1.0.1",
"version": "13.0.1.0.2",
"category": "Localization",
"author": "Code 137",
'license': 'Other OSI approved licence',
Expand Down
48 changes: 17 additions & 31 deletions l10n_br_sale/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ 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', compute="_compute_volumes")
stock_picking_ids = fields.Integer('Stock Pickings', compute="_compute_volumes")
quant_peso = fields.Float('Peso')
# peso_uom = fields.Many2one('uom.uom')
quantidade_volumes = fields.Integer('Qtde. Volumes', compute="_compute_volumes", readonly=False)
# peso_liquido = fields.Float(string=u"Peso Líquido")
peso_bruto = fields.Float(string="Peso Bruto")

nfe_number = fields.Integer(
string=u"Número NFe", compute="_compute_nfe_number")
Expand All @@ -31,31 +30,18 @@ def _compute_nfe_number(self):
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
picking_ids = self.env['stock.picking'].search([
('origin', '=', self.invoice_origin),
('state', '=', 'done')])

if picking_ids:
self.write({
'quantidade_volumes': len(picking_ids),
})

@api.onchange('carrier_partner_id')
def _update_modalidade_frete(self):
if self.carrier_partner_id and self.modalidade_frete == '9':
self.write({
'num_volumes': len(lotes),
'stock_picking_ids': lotes.ids,
})
'modalidade_frete': '1'
})
5 changes: 2 additions & 3 deletions l10n_br_sale/views/account_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
<group string="Informações da Transportadora">
<field name="carrier_partner_id"/>
<field name="modalidade_frete"/>
<field name="num_volumes"/>
<field name="quant_peso"/>
<!-- <field name="peso_uom"/>-->
<field name="quantidade_volumes"/>
<field name="peso_bruto"/>
</group>
</group>
</page>
Expand Down

0 comments on commit f6f47c8

Please sign in to comment.