Skip to content

Commit

Permalink
Merge pull request odoo-brazil#12 from kmee/fix/refactory_module_paym…
Browse files Browse the repository at this point in the history
…ent_mode

Fix/refactory module payment mode
  • Loading branch information
mileo authored Jul 10, 2017
2 parents ae7b0ec + ba4902a commit d485b9c
Show file tree
Hide file tree
Showing 64 changed files with 650 additions and 349 deletions.
69 changes: 15 additions & 54 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,37 @@
language: python
sudo: false
cache:
apt: true
directories:
- $HOME/.cache/pip

python:
- "2.7"

addons:
apt:
# only add the two lines below if you need wkhtmltopdf for your tests
# sources:
# - pov-wkhtmltopdf
# Search your sources alias here:
# https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
packages:
- poppler-utils # For pdftohtml
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow
- python-simplejson
- python-serial
- python-yaml
# Search your packages here:
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
# - wkhtmltopdf # only add if needed and check the before_install section below
- poppler-utils # For pdftohtml

# set up an X server to run wkhtmltopdf.
#before_install:
# - "export DISPLAY=:99.0"
# - "sh -e /etc/init.d/xvfb start"

env:
global:
- VERSION="8.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- TRANSIFEX_USER='[email protected]'
# This line contains the encrypted transifex password
# To encrypt transifex password, install travis ruby utils with:
# $ gem install travis --user-install
# and use:
# $ travis encrypt TRANSIFEX_PASSWORD=your-password -r owner/project
- secure: PjP88tPSwimBv4tsgn3UcQAD1heK/wcuSaSfhi2xUt/jSrOaTmWzjaW2gH/eKM1ilxPXwlPGyAIShJ2JJdBiA97hQufOeiqxdkWDctnNVVEDx2Tk0BiG3PPYyhXPgUZ+FNOnjZFF3pNWvzXTQaB0Nvz8plqp93Ov/DEyhrCxHDs=
# Use the following lines if you need to manually change the transifex project slug or/and the transifex organization.
# The default project slug is owner-repo_name-version (with dash in the version string).
# The default organization is the owner of the repo.
# The default fill up resources (TM) is True.
# The default team is 23907. https://www.transifex.com/organization/oca/team/23907/
# - TRANSIFEX_PROJECT_SLUG=
# - TRANSIFEX_ORGANIZATION=
# - TRANSIFEX_FILL_UP_RESOURCES=
# - TRANSIFEX_TEAM=

matrix:
- LINT_CHECK="1"
- TRANSIFEX="1"
- TESTS="1" ODOO_REPO="odoo/odoo"
- TESTS="1" ODOO_REPO="OCA/OCB"
# either use the two lines above or the two below. Don't change the default if
# it's not necessary (it is only necessary if modules in your repository can't
# be installed in the same database. And you get a huge speed penalty in your
# tests)
# - TESTS="1.0" ODOO_REPO="odoo/odoo" UNIT_TEST="1"
# - TESTS="1.0" ODOO_REPO="OCA/OCB" UNIT_TEST="1"
- VERSION="8.0" LINT_CHECK="1"
- VERSION="8.0" ODOO_REPO="odoo/odoo" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="OCA/OCB" LINT_CHECK="0"

virtualenv:
system_site_packages: true

install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- pip install pillow==3.4.2
- pip install -U pip wheel
- pip install unidecode
- pip install python-dateutil
- pip install pytz
- pip install pyparsing
- pip install git+https://github.com/aricaldeira/pybrasil.git
- pip install pyboleto
- pip install https://github.com/odoo-brazil/cnab240/archive/develop.zip
- pip install fixedwidth
- pip install https://github.com/kmee/cnab240/archive/master.zip
- travis_install_nightly

before_script:
Expand All @@ -80,4 +41,4 @@ script:
- travis_run_tests

after_success:
- travis_after_tests_success
coveralls
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################

{'name': "Bank statement CNAB 240 import",
'version': '1.0.0',
'version': '7.0.1.0.0',
'author': 'KMEE',
'maintainer': 'Luis Felipe Mileo',
'category': 'Finance',
Expand All @@ -42,7 +42,7 @@
'website': 'http://www.kmee.com.br',
'data': [],
'test': [],
'installable': True,
'installable': False,
'images': [],
'auto_install': False,
'license': 'AGPL-3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#
##############################################################################

import tempfile
import datetime
from openerp.tools.translate import _
import tempfile

from openerp.addons.account_statement_base_import.parser import \
BankStatementImportParser
from openerp.tools.translate import _

try:
import cnab240
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tools.translate import _
from openerp.osv import orm
from openerp.tools.translate import _


class AccountStatementProfil(orm.Model):
Expand Down
6 changes: 3 additions & 3 deletions l10n_br_account_banking_payment/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
##############################################################################

{
'name': 'Brazilian Account Banking - Debit and Payments Export Infrastructure',
'name': 'Brazilian Banking - Debit and Payments Export Infrastructure',
'version': '8.0.0.0.0',
'license': 'AGPL-3',
'author': "KMEE, "
Expand All @@ -35,7 +35,7 @@
'l10n_br_account',
'l10n_br_account',
'account_banking_payment_export',
],
],
'data': [
'views/account_due_list.xml',
'views/account_payment.xml',
Expand All @@ -45,6 +45,6 @@
'data/payment_mode_type.xml',
],
'demo': [
],
],
'installable': True,
}
1 change: 0 additions & 1 deletion l10n_br_account_banking_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import account_payment
from . import account_move_line

Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def get_balance(self):
return total

# TODO: Criar metodos para implementação de juros e outros
# detalhes pertinentes.
# detalhes pertinentes.
18 changes: 8 additions & 10 deletions l10n_br_account_banking_payment/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
##############################################################################

from openerp import models, fields, api, exceptions, workflow, _
from openerp import models, fields, api
from openerp.addons import decimal_precision as dp
from openerp.tools.float_utils import float_round as round

Expand All @@ -45,21 +45,21 @@ def _compute_total(self):
class PaymentLine(models.Model):
_inherit = 'payment.line'

def _get_info_partner(self,cr, uid, partner_record, context=None):
def _get_info_partner(self, cr, uid, partner_record, context=None):
if not partner_record:
return False
st = partner_record.street or ''
n = partner_record.number or ''
st1 = partner_record.street2 or ''
zip = partner_record.zip or ''
city = partner_record.l10n_br_city_id.name or ''
uf = partner_record.state_id.code or ''
city = partner_record.l10n_br_city_id.name or ''
uf = partner_record.state_id.code or ''
zip_city = city + '-' + uf + '\n' + zip
cntry = partner_record.country_id and \
partner_record.country_id.name or ''
partner_record.country_id.name or ''
cnpj = partner_record.cnpj_cpf or ''
return partner_record.legal_name + "\n" + cnpj + "\n" + st + ", " \
+ n + " " + st1 + "\n" + zip_city + "\n" + cntry
+ n + " " + st1 + "\n" + zip_city + "\n" + cntry

@api.one
@api.depends('percent_interest', 'amount_currency')
Expand All @@ -68,20 +68,18 @@ def _compute_interest(self):
self.amount_interest = round(self.amount_currency *
(self.percent_interest / 100),
precision)
#self.line.mode.percent_interest
# self.line.mode.percent_interest

linha_digitavel = fields.Char(string=u"Linha Digitável")
percent_interest = fields.Float(string=u"Percentual de Juros",
digits=dp.get_precision('Account'))
amount_interest = fields.Float(string=u"Valor Juros",
compute='_compute_interest',
digits=dp.get_precision('Account'))
digits=dp.get_precision('Account'))

#
# # TODO: Implementar total de juros e outras despesas acessórias.
# @api.depends('line_ids', 'line_ids.amount')
# @api.one
# def _compute_total(self):
# self.total = sum(self.mapped('line_ids.amount') or [0.0])


2 changes: 1 addition & 1 deletion l10n_br_account_banking_payment/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
from . import payment_order_create
from . import payment_order_create
11 changes: 5 additions & 6 deletions l10n_br_account_banking_payment/wizard/payment_order_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def extend_payment_order_domain(self, payment_order, domain):
self.ensure_one()

# Search for all posted moves
if self.all_posted_moves == True:
if self.all_posted_moves:
index = domain.index(('date_maturity', '<=', self.duedate))
domain[index + 1] = ('date_maturity', '>', self.duedate)

Expand Down Expand Up @@ -137,23 +137,22 @@ def search_entries(self):

@api.multi
def _prepare_payment_line(self, payment, line):
res = super(PaymentOrderCreate, self)._prepare_payment_line(payment, line)
res = super(PaymentOrderCreate, self)._prepare_payment_line(
payment, line)
if line.invoice:
if line.invoice.type in ('in_invoice', 'in_refund'):
if line.invoice.reference_type == 'structured':
state = 'structured'
res['communication'] = line.invoice.reference
else:
if line.invoice.reference:
res['communication'] = line.invoice.reference
elif line.invoice.supplier_invoice_number:
res['communication'] = line.invoice.supplier_invoice_number
res['communication'] = \
line.invoice.supplier_invoice_number
else:
# Make sure that the communication includes the
# customer invoice number (in the case of debit order)
res['communication'] = line.name
state = 'structured'

return res

@api.multi
Expand Down
13 changes: 0 additions & 13 deletions l10n_br_account_banking_payment_bradesco_tributos/.travis.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

{
'name': 'Account Payment Tributos Bradesco',
'version': '0.1',
'version': '8.0.1.0.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'author': 'KMEE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@
#
##############################################################################

from fixedwidth.fixedwidth import FixedWidth
from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
from decimal import Decimal
import unicodedata
import logging

from openerp.addons.l10n_br_base.tools.misc import punctuation_rm

_logger = logging.getLogger(__name__)

try:
from fixedwidth.fixedwidth import FixedWidth
except ImportError as err:
_logger.debug = err


def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')


class BradescoTax(object):

def __init__(self):
pass

Expand Down Expand Up @@ -346,7 +356,6 @@ def __init__(self):
},
}


def remessa(self, order):
result = ''
for line in order.line_ids:
Expand All @@ -370,13 +379,15 @@ def remessa(self, order):
'telefone_cliente': str(punctuation_rm(line.partner_id.phone)),
'numero_inscricao': str(
punctuation_rm(line.partner_id.cnpj_cpf)
),
'valor_do_principal': punctuation_rm(str(line.amount_currency)),
),
'valor_do_principal': punctuation_rm(
str(line.amount_currency)),
'data_pagamento_tributo': punctuation_rm(line.date),
'data_vencimento_tributo': punctuation_rm(line.date),
'codigo_de_receita': str(punctuation_rm(
line.order_id.mode.gnre_type.code)),
'num_doc_origem': str(punctuation_rm(line.ml_inv_ref.internal_number)),
'num_doc_origem': str(
punctuation_rm(line.ml_inv_ref.internal_number)),
}
result += "%s\n" % self._remessa(**vals)
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ class AccountMoveLine(models.Model):

has_gnre = fields.Boolean(
related='stored_invoice_id.has_gnre',
string="Tem GNRE")
string="Tem GNRE")
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
##############################################################################
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
#
##############################################################################

from openerp import models, api, workflow, fields
import base64

from openerp import models, api, workflow, fields

from ..bradesco.bradesco_tax import BradescoGnre


Expand Down
Loading

0 comments on commit d485b9c

Please sign in to comment.