Skip to content

Commit

Permalink
Merge branch '11.0' into 11.0-payment-receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaGD committed Dec 3, 2018
2 parents 176c88e + 31c72fd commit bb2eaee
Show file tree
Hide file tree
Showing 33 changed files with 741 additions and 127 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Este repositório adapta o Odoo 11 para ser usado no Brasil
* Emissão de NFSe Paulistana, GINFES, Susesu, SimplISS
* Emissão de Boletos (boletos homologados: Bradesco, Sicoob, Cecred, BB, Santander, Caixa Econômica, Itaú)
* Integração Bancária (cnab240)
* Integração de Pagamentos (cnab240)
* Folha de Pagamento
* Importação de extratos bancários (OFX)
* Contas a pagar e Receber
Expand Down
4 changes: 4 additions & 0 deletions br_account/models/account_invoice_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class AccountInvoiceRefund(models.TransientModel):
@api.multi
def invoice_refund(self):
res = super(AccountInvoiceRefund, self).invoice_refund()
if type(res) is bool:
return res
if "domain" not in res:
return res

invoice_id = res['domain'][1][2][0]
invoice_id = self.env['account.invoice'].search([
Expand Down
1 change: 0 additions & 1 deletion br_account_payment/views/payment_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</group>
<group>
<field name="journal_id" />
<field name="bank_account_id" />
<field name="active"/>
</group>
</group>
Expand Down
7 changes: 6 additions & 1 deletion br_boleto/reports/boleto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'

def render_qweb_pdf(self, res_ids, data=None):
def render_qweb_html(self, res_ids, data=None):
if self.name == 'boleto-payment-order-line':
return
return super(IrActionsReport, self).render_qweb_html(
res_ids, data=data)

def render_qweb_pdf(self, res_ids, data=None):
if not self.name == 'boleto-payment-order-line':
return super(IrActionsReport, self).render_qweb_pdf(
res_ids, data=data)
Expand Down
7 changes: 6 additions & 1 deletion br_boleto/reports/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'

def render_qweb_pdf(self, res_ids, data=None):
def render_qweb_html(self, res_ids, data=None):
if self.name == 'Boleto':
return
return super(IrActionsReport, self).render_qweb_html(
res_ids, data=data)

def render_qweb_pdf(self, res_ids, data=None):
if not self.name == 'Boleto':
return super(IrActionsReport, self).render_qweb_pdf(
res_ids, data=data)
Expand Down
4 changes: 2 additions & 2 deletions br_delivery/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def _prepare_invoice(self):
if pick:
result.update({
'carrier_id': pick[0].carrier_id.id,
'incoterm': pick[0].incoterm.id,
'shipping_supplier': pick[0].carrier_id.partner_id.id,
'incoterm_id': pick[0].incoterm.id,
'shipping_supplier_id': pick[0].carrier_id.partner_id.id,
'freight_responsibility': pick[0].freight_responsibility,
'vehicle_plate': pick[0].vehicle_plate,
'vehicle_state_id': pick[0].vehicle_state_id.id,
Expand Down
2 changes: 1 addition & 1 deletion br_nfe/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _prepare_edoc_vals(self, inv, inv_lines, serie_id):
res['fiscal_document_related_ids'] = documentos

# NFC-e
res['valor_troco'] = 0.0
res['troco'] = 0.0
res['metodo_pagamento'] = inv.payment_mode_id.tipo_pagamento or '01'
res['valor_pago'] = inv.amount_total
return res
Expand Down
2 changes: 1 addition & 1 deletion br_nfe/models/invoice_eletronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def _prepare_eletronic_invoice_item(self, item, invoice):
imposto.update({
'ISSQN': {
'vBC': "%.02f" % item.issqn_base_calculo,
'vAliq': "%.02f" % item.issqn_base_calculo,
'vAliq': "%.02f" % item.issqn_aliquota,
'vISSQN': "%.02f" % item.issqn_valor,
'cMunFG': "%s%s" % (invoice.company_id.state_id.ibge_code,
invoice.company_id.city_id.ibge_code),
Expand Down
7 changes: 7 additions & 0 deletions br_nfe/reports/danfe_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'

def render_qweb_html(self, res_ids, data=None):
if self.report_name == 'br_nfe.main_template_br_nfe_danfe':
return

return super(IrActionsReport, self).render_qweb_html(
res_ids, data=data)

def render_qweb_pdf(self, res_ids, data=None):
if self.report_name != 'br_nfe.main_template_br_nfe_danfe':
return super(IrActionsReport, self).render_qweb_pdf(
Expand Down
9 changes: 6 additions & 3 deletions br_payment_cnab/bancos/bradesco.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ def _get_segmento(self, line, lot_sequency, num_lot):
segmento.get('favorecido_agencia'), 0),
'favorecido_cep': self._string_to_num(
str(segmento.get('favorecido_cep'))[:5]),
'finalidade_doc_ted': get_ted_doc_finality(
'bradesco', segmento.get('finalidade_doc_ted'),
line.payment_information_id.payment_type, ignore),
'finalidade_ted': get_ted_doc_finality(
'bradesco', '01',
segmento.get('finalidade_doc_ted'), ignore),
'finalidade_doc': get_ted_doc_finality(
'bradesco', '02',
segmento.get('finalidade_doc_ted'), ignore),
})
return segmento

Expand Down
25 changes: 5 additions & 20 deletions br_payment_cnab/bancos/itau.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def _get_segmento(self, line, lot_sequency, num_lot):
segmento = super(Itau240, self)._get_segmento(
line, lot_sequency, num_lot)

if not segmento.get('favorecido_cidade'):
segmento.update({'favorecido_cidade': ''}) # Verificar se isso
# deve existir mesmo. Talvez tratar o erro da cidade faltando,
# pro caso de obrigatoriedade desse campo
ignore = not self.is_doc_or_ted(
line.payment_information_id.payment_type)
del(segmento['codigo_camara_compensacao'])
Expand All @@ -96,22 +92,11 @@ def _get_segmento(self, line, lot_sequency, num_lot):
'valor_real_pagamento': self._string_to_monetary(
segmento.get('valor_real_pagamento')),
'favorecido_banco': int(line.bank_account_id.bank_id.bic),
'finalidade_doc_ted': get_ted_doc_finality(
'itau', segmento.get('finalidade_doc_ted'),
line.payment_information_id.payment_type, ignore),
'finalidade_ted': get_ted_doc_finality(
'itau', '01', segmento.get('finalidade_doc_ted'), ignore),
'finalidade_doc': get_ted_doc_finality(
'itau', '02', segmento.get('finalidade_doc_ted'), ignore),
'codigo_receita_tributo': int(
segmento.get('codigo_receita_tributo'))
segmento.get('codigo_receita_tributo') or 0)
})
return segmento

def _get_trailer_lot(self, total, num_lot):
trailer = super(Itau240, self)._get_trailer_lot(total, num_lot)
trailer.update({
})
return trailer

def _get_trailer_arq(self):
trailer = super(Itau240, self)._get_trailer_arq()
trailer.update({
})
return trailer
17 changes: 6 additions & 11 deletions br_payment_cnab/bancos/santander.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,15 @@ def _get_segmento(self, line, lot_sequency, num_lot):
segmento.get('favorecido_cidade', '')[:15],
'nome_concessionaria':
segmento.get('nome_concessionaria', '')[:30],
'finalidade_doc_ted': get_ted_doc_finality(
'santander', segmento.get('finalidade_doc_ted'),
line.payment_information_id.payment_type, ignore),
'finalidade_ted': get_ted_doc_finality(
'santander', '01',
segmento.get('finalidade_doc_ted'), ignore),
'finalidade_doc': get_ted_doc_finality(
'santander', '02',
segmento.get('finalidade_doc_ted'), ignore),
})
return segmento

def _get_trailer_arq(self):
trailer = super(Santander240, self)._get_trailer_arq()
return trailer

def _get_trailer_lot(self, total, num_lot):
trailer = super(Santander240, self)._get_trailer_lot(total, num_lot)
return trailer

def segments_per_operation(self):
segments = super(Santander240, self).segments_per_operation()
segments.update({
Expand Down
20 changes: 3 additions & 17 deletions br_payment_cnab/bancos/sicoob.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,13 @@ def _get_segmento(self, line, lot_sequency, num_lot):
segmento.get('codigo_instrucao_movimento')),
'codigo_camara_compensacao': self._string_to_num(
segmento.get('codigo_camara_compensacao')),
'finalidade_doc_ted': get_ted_doc_finality(
'sicoob', line.payment_information_id.payment_type,
segmento.get('finalidade_doc_ted'), ignore),
'finalidade_ted': get_ted_doc_finality(
'sicoob', line.payment_information_id.payment_type,
segmento.get('finalidade_doc_ted'), ignore)
'sicoob', '01', segmento.get('finalidade_doc_ted'), ignore),
'finalidade_doc': get_ted_doc_finality(
'sicoob', '02', segmento.get('finalidade_doc_ted'), ignore)
})
return segmento

def _get_trailer_lot(self, total, num_lot):
trailer = super(Sicoob240, self)._get_trailer_lot(total, num_lot)
trailer.update({
})
return trailer

def _get_trailer_arq(self):
trailer = super(Sicoob240, self)._get_trailer_arq()
trailer.update({
})
return trailer

def segments_per_operation(self):
segments = super(Sicoob240, self).segments_per_operation()
segments.update({
Expand Down
2 changes: 0 additions & 2 deletions br_payment_cnab/models/payment_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def name_get(self):
('04', 'Tributos com código de barras'),
('05', 'GPS - Guia de previdencia Social'),
('06', 'DARF Normal'),
('07', 'DARF Simples'),
('08', 'FGTS'),
('09', 'ICMS')],
string="Tipo de Operação")

Expand Down
2 changes: 0 additions & 2 deletions br_payment_cnab/models/payment_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class PaymentMode(models.Model):
('04', 'Tributos com código de barras'),
('05', 'GPS - Guia de previdencia Social'),
('06', 'DARF Normal'),
('07', 'DARF Simples'),
('08', 'FGTS'),
('09', 'ICMS')],
string="Tipo de Operação")

Expand Down
32 changes: 14 additions & 18 deletions br_payment_cnab/models/payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def get_file_number(self):
else:
return '1'

def action_approve_all(self):
lines = self.line_ids.filtered(lambda x: x.state == 'draft')
lines.write({'state': 'approved'})

def action_generate_payable_cnab(self):
lines = self.line_ids.filtered(
lambda x: x.state in ('approved', 'sent'))
Expand All @@ -57,16 +53,6 @@ def action_generate_payable_cnab(self):
self.name = self.env['ir.sequence'].next_by_code(
'payment.cnab.name')

remaining_lines = self.line_ids - lines
if remaining_lines:
new_order = self.copy({
'data_emissao_cnab': False, 'cnab_file': False,
'file_number': 0,
'name': self.env['ir.sequence'].next_by_code(
'payment.order')
})
remaining_lines.write({'payment_order_id': new_order.id})


class PaymentOrderLine(models.Model):
_inherit = 'payment.order.line'
Expand Down Expand Up @@ -330,15 +316,24 @@ def mark_order_line_processed(self, cnab_code, cnab_message,
if rejected:
state = 'rejected'

if self.state in ('rejected', 'paid', 'cancelled'):
cnab_message = 'Registro já processado anteriormente'
state = self.state
cnab_code = '00'
self.write({
'state': state, 'cnab_code': cnab_code,
'cnab_message': cnab_message
})
if not statement_id:
journal_id = self.env['account.journal'].search(
[('bank_account_id', '=', self.src_bank_account_id.id)],
limit=1)
if not journal_id.l10n_br_sequence_statements:
raise UserError('Configure a sequência de extrato no diário')
statement_id = self.env['l10n_br.payment.statement'].create({
'name': '0001/Manual',
'name': journal_id.l10n_br_sequence_statements.next_by_id(),
'date': date.today(),
'state': 'validated',
'journal_id': journal_id.id,
})
for item in self:
self.env['l10n_br.payment.statement.line'].create({
Expand All @@ -353,7 +348,7 @@ def mark_order_line_processed(self, cnab_code, cnab_message,
return statement_id

def mark_order_line_paid(self, cnab_code, cnab_message, statement_id=None):
if self.type != 'payable':
if self.filtered(lambda x: x.type != 'payable'):
return super(PaymentOrderLine, self).mark_order_line_paid(
cnab_code, cnab_message, statement_id)

Expand All @@ -364,12 +359,13 @@ def mark_order_line_paid(self, cnab_code, cnab_message, statement_id=None):
journal_id = self.env['account.journal'].search(
[('bank_account_id', '=', account.id)], limit=1)

if not journal_id.l10n_br_sequence_statements:
raise UserError('Configure a sequência de extrato no diário')
if not statement_id:
statement_id = self.env['l10n_br.payment.statement'].create({
'name':
journal_id.l10n_br_sequence_statements.next_by_id(),
'date': date.today(),
'state': 'validated',
'journal_id': journal_id.id,
})
for item in order_lines:
Expand Down
1 change: 1 addition & 0 deletions br_payment_cnab/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import test_common
from . import test_cnab

0 comments on commit bb2eaee

Please sign in to comment.