Skip to content

Commit

Permalink
Merge branch '11.0' into fix/inutilizacao-multi-empresa
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Dec 12, 2018
2 parents 7006bf8 + f263fb6 commit 1c5f69d
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 40 deletions.
1 change: 1 addition & 0 deletions br_account_payment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'views/account_journal.xml',
'views/account_move.xml',
'views/payment_order.xml',
'views/res_settings.xml',
'views/payment_statement.xml',
'security/account_security.xml',
'wizard/payment_cnab_import.xml',
Expand Down
2 changes: 2 additions & 0 deletions br_account_payment/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
from . import account_journal
from . import payment_order
from . import payment_statement
from . import res_config_settings
from . import company
25 changes: 25 additions & 0 deletions br_account_payment/models/company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

l10n_br_pymt_fine_account_id = fields.Many2one(
'account.account',
string="Conta para pagamento de multa",
domain=[('user_type_id.type', '=', 'payable')])

l10n_br_pymt_interest_account_id = fields.Many2one(
'account.account',
string="Conta para pagamento de juros",
domain=[('user_type_id.type', '=', 'payable')])

l10n_br_interest_account_id = fields.Many2one(
'account.account',
string="Conta para recebimento de juros",
domain=[('user_type_id', '=', 'receivable')])

l10n_br_fine_account_id = fields.Many2one(
'account.account',
string="Conta para recebimento de multa",
domain=[('user_type_id.type', '=', 'receivable')])
38 changes: 38 additions & 0 deletions br_account_payment/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# © 2018 Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models, fields


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

l10n_br_pymt_interest_account_id = fields.Many2one(
'account.account',
related='company_id.l10n_br_pymt_interest_account_id',
string="Conta para pagamento de juros",
domain="[('company_id', '=', company_id),\
('user_type_id.type', '=', 'payable')]",
help='Conta onde será debitado o montante dos juros pagos'
)

l10n_br_pymt_fine_account_id = fields.Many2one(
'account.account',
related='company_id.l10n_br_pymt_fine_account_id',
string="Conta para pagamento de multa",
help='Conta onde será debitado o montante das multas pagas'
)

l10n_br_interest_account_id = fields.Many2one(
'account.account',
related='company_id.l10n_br_interest_account_id',
string="Conta para recebimento de juros",
help='Conta onde será creditado o montante dos juros recebidos'
)

l10n_br_fine_account_id = fields.Many2one(
'account.account',
related='company_id.l10n_br_fine_account_id',
string="Conta para recebimento de multa",
help='Conta onde será creditado o montante das multas recebidas'
)
50 changes: 50 additions & 0 deletions br_account_payment/views/res_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="res_config_settings_account_payment" model="ir.ui.view">
<field name="name">res_config_settings.account.payment</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='module_account_batch_deposit']/parent::div/parent::div" position="after">
<div class="col-xs-12 col-md-6 o_setting_box" title="Define accounts to use for fine and interest.">
<div class="o_setting_right_pane">
<label string="Fines and Interests Accounts"/>
<div class="text-muted">
Select account to pay interests and fines values
</div>
<div class="content-group">
<div class="row mt16">
<label string="Interest Account" for="l10n_br_interest_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_interest_account_id" domain="[('company_id', '=', company_id), ('user_type_id.type', '=', 'receivable')]"/>
</div>
<div class="row">
<label string="Fines Account" for="l10n_br_fine_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_fine_account_id" domain="[('company_id', '=', company_id), ('user_type_id.type', '=', 'receivable')]"/>
</div>
</div>
</div>
</div>
</xpath>
<xpath expr="//field[@name='module_account_sepa']/parent::div/parent::div" position="after">
<div class="col-xs-12 col-md-6 o_setting_box" title="Define accounts to use for fine and interest.">
<div class="o_setting_right_pane">
<label string="Fines and Interests Accounts"/>
<div class="text-muted">
Select account to receive interests and fines values
</div>
<div class="content-group">
<div class="row mt16">
<label string="Interest Account" for="l10n_br_pymt_interest_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_pymt_interest_account_id" domain="[('company_id', '=', company_id), ('user_type_id.type', '=', 'payable')]"/>
</div>
<div class="row">
<label string="Fines Account" for="l10n_br_pymt_fine_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_pymt_fine_account_id" domain="[('company_id', '=', company_id), ('user_type_id.type', '=', 'payable')]"/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
4 changes: 4 additions & 0 deletions br_payment_cnab/models/payment_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def name_get(self):

identificacao_fgts = fields.Integer('Número de Identificação do FGTS')

conec_social_dv_fgts = fields.Integer("DV do conectividade Social")

conec_social_fgts = fields.Integer("Lacre do conectividade social")

tax_identification = fields.Selection(
[('16', 'DARF Normal'),
('18', 'DARF Simples'),
Expand Down
20 changes: 0 additions & 20 deletions br_payment_cnab/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,20 @@ class ResConfigSettings(models.TransientModel):
l10n_br_multi_company_payment = fields.Boolean(
string="Pay Bills in Head Office?")

l10n_br_interest_account_id = fields.Many2one(
comodel_name='account.account',
string='Interests Account'
)

l10n_br_fine_account_id = fields.Many2one(
comodel_name='account.account',
string='Fines Account'
)

@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
params = self.env['ir.config_parameter'].sudo()
multi_company = params.get_param(
'br_payment_cnab.l10n_br_multi_company_payment', default=0)
res.update(
l10n_br_interest_account_id=int(params.get_param(
'br_payment_cnab.l10n_br_interest_account_id', default=0)),
l10n_br_fine_account_id=int(params.get_param(
'br_payment_cnab.l10n_br_fine_account_id', default=0)),
l10n_br_multi_company_payment=(multi_company == 'True')
)
return res

@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param(
'br_payment_cnab.l10n_br_interest_account_id',
self.l10n_br_interest_account_id.id)
self.env['ir.config_parameter'].sudo().set_param(
'br_payment_cnab.l10n_br_fine_account_id',
self.l10n_br_fine_account_id.id)
self.env['ir.config_parameter'].sudo().set_param(
'br_payment_cnab.l10n_br_multi_company_payment',
self.l10n_br_multi_company_payment)
7 changes: 6 additions & 1 deletion br_payment_cnab/serialize/cnab240.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def _get_header_arq(self):
def _get_segmento(self, line, lot_sequency, num_lot, nome_segmento):
information_id = line.payment_information_id
segmento = {
"cedente_inscricao_numero": self._string_to_num(
self._order.company_id.cnpj_cpf),
"identificador_fgts": information_id.identificacao_fgts,
"lacre_conectividade_social": information_id.conec_social_fgts,
"lacre_conectividade_social_dv":
information_id.conec_social_dv_fgts,
"controle_lote": num_lot,
"sequencial_registro_lote": lot_sequency,
"tipo_movimento": information_id.mov_type,
Expand Down Expand Up @@ -191,7 +196,7 @@ def _get_header_lot(self, line, num_lot, lot):
information_id = line.payment_information_id
bank = self._order.src_bank_account_id
header_lot = {
'forma_lancamento': lot,
"forma_lancamento": lot,
"controle_lote": num_lot,
"tipo_servico": int(information_id.service_type),
"cedente_inscricao_tipo": 2,
Expand Down
18 changes: 0 additions & 18 deletions br_payment_cnab/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='module_account_sepa']/parent::div/parent::div" position="after">
<div class="col-xs-12 col-md-6 o_setting_box" title="Define accounts to use for fine and interest.">
<div class="o_setting_right_pane">
<label string="Fines and Interests Accounts"/>
<div class="text-muted">
Select account to insert interests and fines values
</div>
<div class="content-group">
<div class="row mt16">
<label string="Interest Account" for="l10n_br_interest_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_interest_account_id" domain="[('company_id', '=', company_id)]"/>
</div>
<div class="row">
<label string="Fines Account" for="l10n_br_fine_account_id" class="col-md-3 o_light_label"/>
<field name="l10n_br_fine_account_id" domain="[('company_id', '=', company_id)]"/>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="l10n_br_multi_company_payment" />
Expand Down
2 changes: 2 additions & 0 deletions br_payment_cnab_voucher/models/account_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def _prepare_payment_order_vals(self):
'invoice_date': self.date,
'barcode': self.barcode,
'linha_digitavel': self.linha_digitavel,
'conec_social_fgts': self.conec_social_fgts,
'conec_social_dv_fgts': self.conec_social_dv_fgts,
# TODO Ajustar o valor de multa e de juros
# 'fine_value': self.fine_value,
# 'interest_value': self.interest_value,
Expand Down
2 changes: 1 addition & 1 deletion br_payment_cnab_voucher/tests/test_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_boletos_titulos(self):
'linha': '858700000049 800001791819 107622050820 415823300017',
},
'237': {
'valor': '2546.06',
'valor': '2546.05',
'linha': '858000000259 460503281831 240720183202 339122710600'
},
'341': {
Expand Down

0 comments on commit 1c5f69d

Please sign in to comment.