From 9f5ff1b31d7738c36714c27319ac95d2d8d797bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Wed, 26 May 2021 03:44:05 -0300
Subject: [PATCH 001/612] spec currency_field is brl_currency_id
---
l10n_br_nfe_spec/models/spec_models.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_nfe_spec/models/spec_models.py b/l10n_br_nfe_spec/models/spec_models.py
index 1b8fb26061cd..75114135f51c 100644
--- a/l10n_br_nfe_spec/models/spec_models.py
+++ b/l10n_br_nfe_spec/models/spec_models.py
@@ -24,4 +24,4 @@ class NfeSpecMixin(models.AbstractModel):
def _compute_brl_currency_id(self):
for item in self:
- item.currency_id = self.env.ref('base.BRL').id
+ item.brl_currency_id = self.env.ref('base.BRL').id
From c35244414a78a2f2a818dfbe0916bdc3c94bacd3 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 11 Feb 2021 14:08:47 -0300
Subject: [PATCH 002/612] [NEW] L10n BR Product Contract
---
l10n_br_product_contract/README.rst | 91 ++++++++++++++++++
l10n_br_product_contract/__init__.py | 1 +
l10n_br_product_contract/__manifest__.py | 22 +++++
l10n_br_product_contract/demo/sale_order.xml | 13 +++
.../demo/sale_order_line.xml | 13 +++
l10n_br_product_contract/models/__init__.py | 2 +
l10n_br_product_contract/models/sale_order.py | 16 +++
.../models/sale_order_line.py | 20 ++++
l10n_br_product_contract/readme/CONFIGURE.rst | 6 ++
.../readme/CONTRIBUTORS.rst | 2 +
l10n_br_product_contract/readme/CREDITS.rst | 6 ++
.../readme/DESCRIPTION.rst | 5 +
l10n_br_product_contract/readme/HISTORY.rst | 14 +++
l10n_br_product_contract/readme/INSTALL.rst | 7 ++
l10n_br_product_contract/readme/ROADMAP.rst | 5 +
l10n_br_product_contract/readme/USAGE.rst | 13 +++
.../readme/newsfragments/.gitkeep | 0
.../static/description/icon.png | Bin 0 -> 9455 bytes
18 files changed, 236 insertions(+)
create mode 100644 l10n_br_product_contract/README.rst
create mode 100644 l10n_br_product_contract/__init__.py
create mode 100644 l10n_br_product_contract/__manifest__.py
create mode 100644 l10n_br_product_contract/demo/sale_order.xml
create mode 100644 l10n_br_product_contract/demo/sale_order_line.xml
create mode 100644 l10n_br_product_contract/models/__init__.py
create mode 100644 l10n_br_product_contract/models/sale_order.py
create mode 100644 l10n_br_product_contract/models/sale_order_line.py
create mode 100644 l10n_br_product_contract/readme/CONFIGURE.rst
create mode 100644 l10n_br_product_contract/readme/CONTRIBUTORS.rst
create mode 100644 l10n_br_product_contract/readme/CREDITS.rst
create mode 100644 l10n_br_product_contract/readme/DESCRIPTION.rst
create mode 100644 l10n_br_product_contract/readme/HISTORY.rst
create mode 100644 l10n_br_product_contract/readme/INSTALL.rst
create mode 100644 l10n_br_product_contract/readme/ROADMAP.rst
create mode 100644 l10n_br_product_contract/readme/USAGE.rst
create mode 100644 l10n_br_product_contract/readme/newsfragments/.gitkeep
create mode 100644 l10n_br_product_contract/static/description/icon.png
diff --git a/l10n_br_product_contract/README.rst b/l10n_br_product_contract/README.rst
new file mode 100644
index 000000000000..b7cfa49eaacf
--- /dev/null
+++ b/l10n_br_product_contract/README.rst
@@ -0,0 +1,91 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+
+========================
+L10n Br Product Contract
+========================
+
+Criação de contratos através dos Pedidos de Vendas
+
+Installation
+============
+
+To install this module, you need to:
+
+#. Do this ...
+
+Configuration
+=============
+
+To configure this module, you need to:
+
+#. Go to ...
+
+.. figure:: path/to/local/image.png
+ :alt: alternative description
+ :width: 600 px
+
+Usage
+=====
+
+To use this module, you need to:
+
+#. Go to ...
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+ :alt: Try me on Runbot
+ :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
+
+.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
+.. branch is "8.0" for example
+
+Known issues / Roadmap
+======================
+
+* ...
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues
+`_. In case of trouble, please
+check there if your issue has already been reported. If you spotted it first,
+help us smash it by providing detailed and welcomed feedback.
+
+Credits
+=======
+
+Images
+------
+
+* Odoo Community Association: `Icon `_.
+
+Contributors
+------------
+
+* Firstname Lastname
+* Second Person
+
+Funders
+-------
+
+The development of this module has been financially supported by:
+
+* Company 1 name
+* Company 2 name
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+To contribute to this module, please visit https://odoo-community.org.
diff --git a/l10n_br_product_contract/__init__.py b/l10n_br_product_contract/__init__.py
new file mode 100644
index 000000000000..0650744f6bc6
--- /dev/null
+++ b/l10n_br_product_contract/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/l10n_br_product_contract/__manifest__.py b/l10n_br_product_contract/__manifest__.py
new file mode 100644
index 000000000000..8f6f036feeac
--- /dev/null
+++ b/l10n_br_product_contract/__manifest__.py
@@ -0,0 +1,22 @@
+# Copyright 2021 KMEE
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+{
+ 'name': 'L10n Br Product Contract',
+ 'summary': """
+ Criação de contratos através dos Pedidos de Vendas""",
+ 'version': '12.0.1.0.0',
+ 'license': 'AGPL-3',
+ 'author': 'KMEE,Odoo Community Association (OCA)',
+ 'website': 'https://github.com/oca/l10n-brazil.git',
+ 'depends': [
+ 'l10n_br_contract',
+ 'product_contract',
+ ],
+ 'data': [
+ ],
+ 'demo': [
+ 'demo/sale_order_line.xml',
+ 'demo/sale_order.xml',
+ ],
+}
diff --git a/l10n_br_product_contract/demo/sale_order.xml b/l10n_br_product_contract/demo/sale_order.xml
new file mode 100644
index 000000000000..3552a23a6dd8
--- /dev/null
+++ b/l10n_br_product_contract/demo/sale_order.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/l10n_br_product_contract/demo/sale_order_line.xml b/l10n_br_product_contract/demo/sale_order_line.xml
new file mode 100644
index 000000000000..4ed8cf469fa8
--- /dev/null
+++ b/l10n_br_product_contract/demo/sale_order_line.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/l10n_br_product_contract/models/__init__.py b/l10n_br_product_contract/models/__init__.py
new file mode 100644
index 000000000000..2d7ee6c3dc75
--- /dev/null
+++ b/l10n_br_product_contract/models/__init__.py
@@ -0,0 +1,2 @@
+from . import sale_order
+from . import sale_order_line
diff --git a/l10n_br_product_contract/models/sale_order.py b/l10n_br_product_contract/models/sale_order.py
new file mode 100644
index 000000000000..142bec505a58
--- /dev/null
+++ b/l10n_br_product_contract/models/sale_order.py
@@ -0,0 +1,16 @@
+# Copyright 2021 KMEE
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, fields, models, _
+
+
+class SaleOrder(models.Model):
+
+ _inherit = 'sale.order'
+
+ @api.multi
+ def _prepare_contract_value(self, contract_template):
+ self.ensure_one()
+ vals = self._prepare_br_fiscal_dict()
+ vals.update(super()._prepare_contract_value(contract_template))
+ return vals
diff --git a/l10n_br_product_contract/models/sale_order_line.py b/l10n_br_product_contract/models/sale_order_line.py
new file mode 100644
index 000000000000..13e82b5e341b
--- /dev/null
+++ b/l10n_br_product_contract/models/sale_order_line.py
@@ -0,0 +1,20 @@
+# Copyright 2021 KMEE
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, fields, models, _
+
+
+class SaleOrderLine(models.Model):
+
+ _inherit = 'sale.order.line'
+
+
+ @api.multi
+ def _prepare_contract_line_values(
+ self, contract, predecessor_contract_line_id=False
+ ):
+ vals = self._prepare_br_fiscal_dict()
+ vals.update(super()._prepare_contract_line_values(
+ contract, predecessor_contract_line_id
+ ))
+ return vals
diff --git a/l10n_br_product_contract/readme/CONFIGURE.rst b/l10n_br_product_contract/readme/CONFIGURE.rst
new file mode 100644
index 000000000000..348d947ee594
--- /dev/null
+++ b/l10n_br_product_contract/readme/CONFIGURE.rst
@@ -0,0 +1,6 @@
+[ This file is optional, it should explain how to configure
+ the module before using it; it is aimed at advanced users. ]
+
+To configure this module, you need to:
+
+#. Go to do nothing
diff --git a/l10n_br_product_contract/readme/CONTRIBUTORS.rst b/l10n_br_product_contract/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000000..0b43fe9818c9
--- /dev/null
+++ b/l10n_br_product_contract/readme/CONTRIBUTORS.rst
@@ -0,0 +1,2 @@
+* Luis Felipe Mileo
+
diff --git a/l10n_br_product_contract/readme/CREDITS.rst b/l10n_br_product_contract/readme/CREDITS.rst
new file mode 100644
index 000000000000..e38eec44e563
--- /dev/null
+++ b/l10n_br_product_contract/readme/CREDITS.rst
@@ -0,0 +1,6 @@
+[ This file is optional and contains additional credits, other than
+ authors, contributors, and maintainers. ]
+
+The development of this module has been financially supported by:
+
+* KMEE
diff --git a/l10n_br_product_contract/readme/DESCRIPTION.rst b/l10n_br_product_contract/readme/DESCRIPTION.rst
new file mode 100644
index 000000000000..3c022df93240
--- /dev/null
+++ b/l10n_br_product_contract/readme/DESCRIPTION.rst
@@ -0,0 +1,5 @@
+[ This file must be max 2-3 paragraphs, and is required. ]
+
+This module extends the functionality of product_contact to support l10n_br_contract
+and to allow you to create fiscal documents with the same fiscal configuration of the sale orders.
+
diff --git a/l10n_br_product_contract/readme/HISTORY.rst b/l10n_br_product_contract/readme/HISTORY.rst
new file mode 100644
index 000000000000..0b12215cd12f
--- /dev/null
+++ b/l10n_br_product_contract/readme/HISTORY.rst
@@ -0,0 +1,14 @@
+[ The change log. The goal of this file is to help readers
+ understand changes between version. The primary audience is
+ end users and integrators. Purely technical changes such as
+ code refactoring must not be mentioned here.
+
+ This file may contain ONE level of section titles, underlined
+ with the ~ (tilde) character. Other section markers are
+ forbidden and will likely break the structure of the README.rst
+ or other documents where this fragment is included. ]
+
+12.0.1.0.0 (2021-02-11)
+~~~~~~~~~~~~~~~~~~~~~~~
+
+* [NEW] First Release
diff --git a/l10n_br_product_contract/readme/INSTALL.rst b/l10n_br_product_contract/readme/INSTALL.rst
new file mode 100644
index 000000000000..ee57bca1996c
--- /dev/null
+++ b/l10n_br_product_contract/readme/INSTALL.rst
@@ -0,0 +1,7 @@
+[ This file must only be present if there are very specific
+ installation instructions, such as installing non-python
+ dependencies. The audience is systems administrators. ]
+
+To install this module, you need to:
+
+#. Do nothing
diff --git a/l10n_br_product_contract/readme/ROADMAP.rst b/l10n_br_product_contract/readme/ROADMAP.rst
new file mode 100644
index 000000000000..207233013b40
--- /dev/null
+++ b/l10n_br_product_contract/readme/ROADMAP.rst
@@ -0,0 +1,5 @@
+[ Enumerate known caveats and future potential improvements.
+ It is mostly intended for end-users, and can also help
+ potential new contributors discovering new features to implement. ]
+
+* ...
diff --git a/l10n_br_product_contract/readme/USAGE.rst b/l10n_br_product_contract/readme/USAGE.rst
new file mode 100644
index 000000000000..7969eea52f69
--- /dev/null
+++ b/l10n_br_product_contract/readme/USAGE.rst
@@ -0,0 +1,13 @@
+[ This file must be present and contains the usage instructions
+ for end-users. As all other rst files included in the README,
+ it MUST NOT contain reStructuredText sections
+ only body text (paragraphs, lists, tables, etc). Should you need
+ a more elaborate structure to explain the addon, please create a
+ Sphinx documentation (which may include this file as a "quick start"
+ section). ]
+
+To use this module, you need to:
+
+#. Configure the products as contracts;
+#. Create a sale order, with this product and confirm.
+
diff --git a/l10n_br_product_contract/readme/newsfragments/.gitkeep b/l10n_br_product_contract/readme/newsfragments/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/l10n_br_product_contract/static/description/icon.png b/l10n_br_product_contract/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d
GIT binary patch
literal 9455
zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~!
zVpnB`o+K7|Al`Q_U;eD$B
zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA
z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__
zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_
zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I
z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U
z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)(
z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH
zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW
z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx
zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h
zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9
zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz#
z-5EK$o(!F?hmX*2Yt6+coY`6jGbb7tF#6nHA
zuKk=GGJ;ZwON1iAfG$E#Y7MnZVmrY|j0eVI(DN_MNFJmyZ|;w4tf@=CCDZ#5N_0K=
z$;R~bbk?}TpfDjfB&aiQ$VA}s?P}xPERJG{kxk5~R`iRS(SK5d+Xs9swCozZISbnS
zk!)I0>t=A<-^z(cmSFz3=jZ23u13X><0b)P)^1T_))Kr`e!-pb#q&J*Q`p+B6la%C
zuVl&0duN<;uOsB3%T9Fp8t{ED108)`y_~Hnd9AUX7h-H?jVuU|}My+C=TjH(jKz
zqMVr0re3S$H@t{zI95qa)+Crz*5Zj}Ao%4Z><+W(nOZd?gDnfNBC3>M8WE61$So|P
zVvqH0SNtDTcsUdzaMDpT=Ty0pDHHNL@Z0w$Y`XO
z2M-_r1S+GaH%pz#Uy0*w$Vdl=X=rQXEzO}d6J^R6zjM1u&c9vYLvLp?W7w(?np9x1
zE_0JSAJCPB%i7p*Wvg)pn5T`8k3-uR?*NT|J`eS#_#54p>!p(mLDvmc-3o0mX*mp_
zN*AeS<>#^-{S%W<*mz^!X$w_2dHWpcJ6^j64qFBft-o}o_Vx80o0>}Du;>kLts;$8
zC`7q$QI(dKYG`Wa8#wl@V4jVWBRGQ@1dr-hstpQL)Tl+aqVpGpbSfN>5i&QMXfiZ>
zaA?T1VGe?rpQ@;+pkrVdd{klI&jVS@I5_iz!=UMpTsa~mBga?1r}aRBm1WS;TT*s0f0lY=JBl66Upy)-k4J}lh=P^8(SXk~0xW=T9v*B|gzIhN
z>qsO7dFd~mgxAy4V?&)=5ieYq?zi?ZEoj)&2o)RLy=@hbCRcfT5jigwtQGE{L*8<@Yd{zg;CsL5mvzfDY}P-wos_6PfprFVaeqNE%h
zKZhLtcQld;ZD+>=nqN~>GvROfueSzJD&BE*}XfU|H&(FssBqY=hPCt`d
zH?@s2>I(|;fcW&YM6#V#!kUIP8$Nkdh0A(bEVj``-AAyYgwY~jB
zT|I7Bf@%;7aL7Wf4dZ%VqF$eiaC38OV6oy3Z#TER2G+fOCd9Iaoy6aLYbPTN{XRPz
z;U!V|vBf%H!}52L2gH_+j;`bTcQRXB+y9onc^wLm5wi3-Be}U>k_u>2Eg$=k!(l@I
zcCg+flakT2Nej3i0yn+g+}%NYb?ta;R?(g5SnwsQ49U8Wng8d|{B+lyRcEDvR3+`O{zfmrmvFrL6acVP%yG98X
zo&+VBg@px@i)%o?dG(`T;n*$S5*rnyiR#=wW}}GsAcfyQpE|>a{=$Hjg=-*_K;UtD
z#z-)AXwSRY?OPefw^iI+
z)AXz#PfEjlwTes|_{sB?4(O@fg0AJ^g8gP}ex9Ucf*@_^J(s_5jJV}c)s$`Myn|Kd
z$6>}#q^n{4vN@+Os$m7KV+`}c%4)4pv@06af4-x5#wj!KKb%caK{A&Y#Rfs
z-po?Dcb1({W=6FKIUirH&(yg=*6aLCekcKwyfK^JN5{wcA3nhO(o}SK#!CINhI`-I
z1)6&n7O&ZmyFMuNwvEic#IiOAwNkR=u5it{B9n2sAJV5pNhar=j5`*N!Na;c7g!l$
z3aYBqUkqqTJ=Re-;)s!EOeij=7SQZ3Hq}ZRds%IM*PtM$wV
z@;rlc*NRK7i3y5BETSKuumEN`Xu_8GP1Ri=OKQ$@I^ko8>H6)4rjiG5{VBM>B|%`&&s^)jS|-_95&yc=GqjNo{zFkw%%HHhS~e=s
zD#sfS+-?*t|J!+ozP6KvtOl!R)@@-z24}`9{QaVLD^9VCSR2b`b!KC#o;Ki<+wXB6
zx3&O0LOWcg4&rv4QG0)4yb}7BFSEg~=IR5#ZRj8kg}dS7_V&^%#Do==#`u
zpy6{ox?jWuR(;pg+f@mT>#HGWHAJRRDDDv~@(IDw&R>9643kK#HN`!1vBJHnC+RM&yIh8{gG2q
zA%e*U3|N0XSRa~oX-3EAneep)@{h2vvd3Xvy$7og(sayr@95+e6~Xvi1tUqnIxoIH
zVWo*OwYElb#uyW{Imam6f2rGbjR!Y3`#gPqkv57dB6K^wRGxc9B(t|aYDGS=m$&S!NmCtrMMaUg(c
zc2qC=2Z`EEFMW-me5B)24AqF*bV5Dr-M5ig(l-WPS%CgaPzs6p_gnCIvTJ=Y<6!gT
zVt@AfYCzjjsMEGi=rDQHo0yc;HqoRNnNFeWZgcm?f;cp(6CNylj36DoL(?TS7eU#+
z7&mfr#y))+CJOXQKUMZ7QIdS9@#-}7y2K1{8)cCt0~-X0O!O?Qx#E4Og+;A2SjalQ
zs7r?qn0H044=sDN$SRG$arw~n=+T_DNdSrarmu)V6@|?1-ZB#hRn`uilTGPJ@fqEy
zGt(f0B+^JDP&f=r{#Y_wi#AVDf-y!RIXU^0jXsFpf>=Ji*TeqSY!H~AMbJdCGLhC)
zn7Rx+sXw6uYj;WRYrLd^5IZq@6JI1C^YkgnedZEYy<&4(z%Q$5yv#Boo{AH8n$a
zhb4Y3PWdr269&?V%uI$xMcUrMzl=;w<_nm*qr=c3Rl@i5wWB;e-`t7D&c-mcQl7x!
zZWB`UGcw=Y2=}~wzrfLx=uet<;m3~=8I~ZRuzvMQUQdr+yTV|ATf1Uuomr__nDf=X
zZ3WYJtHp_ri(}SQAPjv+Y+0=fH4krOP@S&=zZ-t1jW1o@}z;xk8
z(Nz1co&El^HK^NrhVHa-_;&88vTU>_J33=%{if;BEY*J#1n59=07jrGQ#IP>@u#3A
z;!q+E1Rj3ZJ+!4bq9F8PXJ@yMgZL;>&gYA0%_Kbi8?S=XGM~dnQZQ!yBSgcZhY96H
zrWnU;k)qy`rX&&xlDyA%(a1Hhi5CWkmg(`Gb%m(HKi-7Z!LKGRP_B8@`7&hdDy5n=
z`OIxqxiVfX@OX1p(mQu>0Ai*v_cTMiw4qRt3~NBvr9oBy0)r>w3p~V0SCm=An6@3n)>@z!|o-$HvDK
z|3D2ZMJkLE5loMKl6R^ez@Zz%S$&mbeoqH5`Bb){Ei21q&VP)hWS2tjShfFtGE+$z
zzCR$P#uktu+#!w)cX!lWN1XU%K-r=s{|j?)Akf@q#3b#{6cZCuJ~gCxuMXRmI$nGtnH+-h
z+GEi!*X=AP<|fG`1>MBdTb?28JYc=fGvAi2I<$B(rs$;eoJCyR6_bc~p!XR@O-+sD
z=eH`-ye})I5ic1eL~TDmtfJ|8`0VJ*Yr=hNCd)G1p2MMz4C3^Mj?7;!w|Ly%JqmuW
zlIEW^Ft%z?*|fpXda>Jr^1noFZEwFgVV%|*XhH@acv8rdGxeEX{M$(vG{Zw+x(ei@
zmfXb22}8-?Fi`vo-YVrTH*C?a8%M=Hv9MqVH7H^J$KsD?>!SFZ;ZsvnHr_gn=7acz
z#W?0eCdVhVMWN12VV^$>WlQ?f;P^{(&pYTops|btm6aj>_Uz+hqpGwB)vWp0Cf5y<
zft8-je~nn?W11plq}N)4A{l8I7$!ks_x$PXW-2XaRFswX_BnF{R#6YIwMhAgd5F9X
zGmwdadS6(a^fjHtXg8=l?Rc0Sm%hk6E9!5cLVloEy4eh(=FwgP`)~I^5~pBEWo+F6
zSf2ncyMurJN91#cJTy_u8Y}@%!bq1RkGC~-bV@SXRd4F{R-*V`bS+6;W5vZ(&+I<9$;-V|eNfLa5n-6%
z2(}&uGRF;p92eS*sE*oR$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(|
z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4PdpwWDop%^}n;dD#K4s#DYA8SHZ
z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H
zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^WYu2u5kubqmwp%drJ6
z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d}
z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A
zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k&YOi-3|1QKB
z
z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp
zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zls4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@QS0TEL_?njX|@vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6#
z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f#
zuT7fvjSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC
zC}~H#WXlkUW*H5CDOo<)#x7%RY)A;ShGhI5s*#cRDA8YgqG(HeKDx+#(ZQ?386dv!
zlXCO)w91~Vw4AmOcATuV653fa9R$fyK8ul%rG
z-wfS
zihugoZyr38Im?Zuh6@RcF~t1anQu7>#lPpb#}4cOA!EM11`%f*07RqOVkmX{p~KJ9
z^zP;K#|)$`^Rb{rnHGH{~>1(fawV0*Z#)}M`m8-?ZJV<+e}s9wE#
z)l&az?w^5{)`S(%MRzxdNqrs1n*-=jS^_jqE*5XDrA0+VE`5^*p3CuM<&dZEeCjoz
zR;uu_H9ZPZV|fQq`Cyw4nscrVwi!fE6ciMmX$!_hN7uF;jjKG)d2@aC4ropY)8etW=xJvni)8eHi`H$%#zn^WJ5NLc-rqk|u&&4Z6fD_m&JfSI1Bvb?b<*n&sfl0^t
z=HnmRl`XrFvMKB%9}>PaA`m-fK6a0(8=qPkWS5bb4=v?XcWi&hRY?O5HdulRi4?fN
zlsJ*N-0Qw+Yic@s0(2uy%F@ib;GjXt01Fmx5XbRo6+n|pP(&nodMoap^z{~q
ziEeaUT@Mxe3vJSfI6?uLND(CNr=#^W<1b}jzW58bIfyWTDle$mmS(|x-0|2UlX+9k
zQ^EX7Nw}?EzVoBfT(-LT|=9N@^hcn-_p&sqG
z&*oVs2JSU+N4ZD`FhCAWaS;>|wH2G*Id|?pa#@>tyxX`+4HyIArWDvVrX)2WAOQff
z0qyHu&-S@i^MS-+j--!pr4fPBj~_8({~e1bfcl0wI1kaoN>mJL6KUPQm5N7lB(ui1
zE-o%kq)&djzWJ}ob<-GfDlkB;F31j-VHKvQUGQ3sp`CwyGJk_i!y^sD0fqC@$9|jO
zOqN!r!8-p==F@ZVP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$
zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV(
z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb
zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4
z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{
zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx}
z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov
zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22
zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq
zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t<
z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k
z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp
z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{}
zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N
Xviia!U7SGha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
From 082860e7434ee96b0fb548beb31d9556128bdee3 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Mon, 19 Apr 2021 00:48:22 -0300
Subject: [PATCH 003/612] [FIX] flake8
---
l10n_br_product_contract/models/sale_order.py | 4 ++--
l10n_br_product_contract/models/sale_order_line.py | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/l10n_br_product_contract/models/sale_order.py b/l10n_br_product_contract/models/sale_order.py
index 142bec505a58..643db6c778e6 100644
--- a/l10n_br_product_contract/models/sale_order.py
+++ b/l10n_br_product_contract/models/sale_order.py
@@ -1,7 +1,7 @@
-# Copyright 2021 KMEE
+# Copyright 2021 KMEE - Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models, _
+from odoo import api, models
class SaleOrder(models.Model):
diff --git a/l10n_br_product_contract/models/sale_order_line.py b/l10n_br_product_contract/models/sale_order_line.py
index 13e82b5e341b..8d9fe9f244f8 100644
--- a/l10n_br_product_contract/models/sale_order_line.py
+++ b/l10n_br_product_contract/models/sale_order_line.py
@@ -1,14 +1,13 @@
-# Copyright 2021 KMEE
+# Copyright 2021 KMEE - Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models, _
+from odoo import api, models
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
-
@api.multi
def _prepare_contract_line_values(
self, contract, predecessor_contract_line_id=False
From b1448a31a5c52c098362720b0c67affc254296c2 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Mon, 19 Apr 2021 00:48:39 -0300
Subject: [PATCH 004/612] [REF] Module readme
---
l10n_br_product_contract/README.rst | 100 ++--
l10n_br_product_contract/readme/CONFIGURE.rst | 5 +-
l10n_br_product_contract/readme/CREDITS.rst | 3 -
.../readme/DESCRIPTION.rst | 3 -
l10n_br_product_contract/readme/HISTORY.rst | 10 -
l10n_br_product_contract/readme/INSTALL.rst | 4 -
l10n_br_product_contract/readme/ROADMAP.rst | 5 -
l10n_br_product_contract/readme/USAGE.rst | 8 -
.../static/description/index.html | 466 ++++++++++++++++++
9 files changed, 528 insertions(+), 76 deletions(-)
delete mode 100644 l10n_br_product_contract/readme/ROADMAP.rst
create mode 100644 l10n_br_product_contract/static/description/index.html
diff --git a/l10n_br_product_contract/README.rst b/l10n_br_product_contract/README.rst
index b7cfa49eaacf..fddcfc262ffc 100644
--- a/l10n_br_product_contract/README.rst
+++ b/l10n_br_product_contract/README.rst
@@ -1,91 +1,113 @@
-.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
- :alt: License: AGPL-3
-
========================
L10n Br Product Contract
========================
-Criação de contratos através dos Pedidos de Vendas
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
+ :target: https://github.com/OCA/l10n-brazil/tree/12.0/l10n_br_product_contract
+ :alt: OCA/l10n-brazil
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/l10n-brazil-12-0/l10n-brazil-12-0-l10n_br_product_contract
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/124/12.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+This module extends the functionality of product_contact to support l10n_br_contract
+and to allow you to create fiscal documents with the same fiscal configuration of the sale orders.
+
+**Table of contents**
+
+.. contents::
+ :local:
Installation
============
To install this module, you need to:
-#. Do this ...
+#. Do nothing
Configuration
=============
To configure this module, you need to:
-#. Go to ...
-
-.. figure:: path/to/local/image.png
- :alt: alternative description
- :width: 600 px
+#. Do nothing
Usage
=====
To use this module, you need to:
-#. Go to ...
+#. Configure the products as contracts;
+#. Create a sale order, with this product and confirm.
-.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
- :alt: Try me on Runbot
- :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
-.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
-.. branch is "8.0" for example
+Changelog
+=========
-Known issues / Roadmap
-======================
+12.0.1.0.0 (2021-02-11)
+~~~~~~~~~~~~~~~~~~~~~~~
-* ...
+* [NEW] First Release
Bug Tracker
===========
-Bugs are tracked on `GitHub Issues
-`_. In case of trouble, please
-check there if your issue has already been reported. If you spotted it first,
-help us smash it by providing detailed and welcomed feedback.
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
Credits
=======
-Images
-------
+Authors
+~~~~~~~
-* Odoo Community Association: `Icon `_.
+* KMEE
Contributors
-------------
+~~~~~~~~~~~~
-* Firstname Lastname
-* Second Person
+* Luis Felipe Mileo
-Funders
--------
+
+Other credits
+~~~~~~~~~~~~~
The development of this module has been financially supported by:
-* Company 1 name
-* Company 2 name
+* KMEE
-Maintainer
-----------
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
-This module is maintained by the OCA.
-
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-To contribute to this module, please visit https://odoo-community.org.
+This module is part of the `OCA/l10n-brazil `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/l10n_br_product_contract/readme/CONFIGURE.rst b/l10n_br_product_contract/readme/CONFIGURE.rst
index 348d947ee594..e680b3cf9200 100644
--- a/l10n_br_product_contract/readme/CONFIGURE.rst
+++ b/l10n_br_product_contract/readme/CONFIGURE.rst
@@ -1,6 +1,3 @@
-[ This file is optional, it should explain how to configure
- the module before using it; it is aimed at advanced users. ]
-
To configure this module, you need to:
-#. Go to do nothing
+#. Do nothing
diff --git a/l10n_br_product_contract/readme/CREDITS.rst b/l10n_br_product_contract/readme/CREDITS.rst
index e38eec44e563..b8d308aafa52 100644
--- a/l10n_br_product_contract/readme/CREDITS.rst
+++ b/l10n_br_product_contract/readme/CREDITS.rst
@@ -1,6 +1,3 @@
-[ This file is optional and contains additional credits, other than
- authors, contributors, and maintainers. ]
-
The development of this module has been financially supported by:
* KMEE
diff --git a/l10n_br_product_contract/readme/DESCRIPTION.rst b/l10n_br_product_contract/readme/DESCRIPTION.rst
index 3c022df93240..c923518703d7 100644
--- a/l10n_br_product_contract/readme/DESCRIPTION.rst
+++ b/l10n_br_product_contract/readme/DESCRIPTION.rst
@@ -1,5 +1,2 @@
-[ This file must be max 2-3 paragraphs, and is required. ]
-
This module extends the functionality of product_contact to support l10n_br_contract
and to allow you to create fiscal documents with the same fiscal configuration of the sale orders.
-
diff --git a/l10n_br_product_contract/readme/HISTORY.rst b/l10n_br_product_contract/readme/HISTORY.rst
index 0b12215cd12f..0f4ee58ce26d 100644
--- a/l10n_br_product_contract/readme/HISTORY.rst
+++ b/l10n_br_product_contract/readme/HISTORY.rst
@@ -1,13 +1,3 @@
-[ The change log. The goal of this file is to help readers
- understand changes between version. The primary audience is
- end users and integrators. Purely technical changes such as
- code refactoring must not be mentioned here.
-
- This file may contain ONE level of section titles, underlined
- with the ~ (tilde) character. Other section markers are
- forbidden and will likely break the structure of the README.rst
- or other documents where this fragment is included. ]
-
12.0.1.0.0 (2021-02-11)
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/l10n_br_product_contract/readme/INSTALL.rst b/l10n_br_product_contract/readme/INSTALL.rst
index ee57bca1996c..0c927341d2d6 100644
--- a/l10n_br_product_contract/readme/INSTALL.rst
+++ b/l10n_br_product_contract/readme/INSTALL.rst
@@ -1,7 +1,3 @@
-[ This file must only be present if there are very specific
- installation instructions, such as installing non-python
- dependencies. The audience is systems administrators. ]
-
To install this module, you need to:
#. Do nothing
diff --git a/l10n_br_product_contract/readme/ROADMAP.rst b/l10n_br_product_contract/readme/ROADMAP.rst
deleted file mode 100644
index 207233013b40..000000000000
--- a/l10n_br_product_contract/readme/ROADMAP.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-[ Enumerate known caveats and future potential improvements.
- It is mostly intended for end-users, and can also help
- potential new contributors discovering new features to implement. ]
-
-* ...
diff --git a/l10n_br_product_contract/readme/USAGE.rst b/l10n_br_product_contract/readme/USAGE.rst
index 7969eea52f69..6c23cabeb5a6 100644
--- a/l10n_br_product_contract/readme/USAGE.rst
+++ b/l10n_br_product_contract/readme/USAGE.rst
@@ -1,11 +1,3 @@
-[ This file must be present and contains the usage instructions
- for end-users. As all other rst files included in the README,
- it MUST NOT contain reStructuredText sections
- only body text (paragraphs, lists, tables, etc). Should you need
- a more elaborate structure to explain the addon, please create a
- Sphinx documentation (which may include this file as a "quick start"
- section). ]
-
To use this module, you need to:
#. Configure the products as contracts;
diff --git a/l10n_br_product_contract/static/description/index.html b/l10n_br_product_contract/static/description/index.html
new file mode 100644
index 000000000000..3b6d3465bedc
--- /dev/null
+++ b/l10n_br_product_contract/static/description/index.html
@@ -0,0 +1,466 @@
+
+
+
+
+
+
+L10n Br Product Contract
+
+
+
+
+
L10n Br Product Contract
+
+
+
+
This module extends the functionality of product_contact to support l10n_br_contract
+and to allow you to create fiscal documents with the same fiscal configuration of the sale orders.
+
Table of contents
+
+
+
+
To install this module, you need to:
+
+Do nothing
+
+
+
+
+
To configure this module, you need to:
+
+Do nothing
+
+
+
+
+
To use this module, you need to:
+
+Configure the products as contracts;
+Create a sale order, with this product and confirm.
+
+
+
+
+
+
Bugs are tracked on GitHub Issues .
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback .
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+
+
The development of this module has been financially supported by:
+
+
+
+
+
This module is maintained by the OCA.
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/l10n-brazil project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute .
+
+
+
+
+
From 6061ebe901c0cb952d50be6a1bb0312eaf58a4f6 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Mon, 19 Apr 2021 00:59:51 -0300
Subject: [PATCH 005/612] [REM] demo/sale_order_line
---
l10n_br_product_contract/__manifest__.py | 3 ++-
l10n_br_product_contract/demo/sale_order_line.xml | 13 -------------
2 files changed, 2 insertions(+), 14 deletions(-)
delete mode 100644 l10n_br_product_contract/demo/sale_order_line.xml
diff --git a/l10n_br_product_contract/__manifest__.py b/l10n_br_product_contract/__manifest__.py
index 8f6f036feeac..21c3352bb071 100644
--- a/l10n_br_product_contract/__manifest__.py
+++ b/l10n_br_product_contract/__manifest__.py
@@ -9,6 +9,8 @@
'license': 'AGPL-3',
'author': 'KMEE,Odoo Community Association (OCA)',
'website': 'https://github.com/oca/l10n-brazil.git',
+ 'development_status': 'Beta',
+ 'maintainers': ['mileo'],
'depends': [
'l10n_br_contract',
'product_contract',
@@ -16,7 +18,6 @@
'data': [
],
'demo': [
- 'demo/sale_order_line.xml',
'demo/sale_order.xml',
],
}
diff --git a/l10n_br_product_contract/demo/sale_order_line.xml b/l10n_br_product_contract/demo/sale_order_line.xml
deleted file mode 100644
index 4ed8cf469fa8..000000000000
--- a/l10n_br_product_contract/demo/sale_order_line.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
From e1102bef093a03850224fe37ea4eeadfd7669ed7 Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Thu, 20 May 2021 16:39:20 -0300
Subject: [PATCH 006/612] [IMP] demo data
---
l10n_br_product_contract/__manifest__.py | 2 +
.../demo/contract_template.xml | 13 ++++++
l10n_br_product_contract/demo/product.xml | 28 ++++++++++++
l10n_br_product_contract/demo/sale_order.xml | 43 ++++++++++++++++---
4 files changed, 80 insertions(+), 6 deletions(-)
create mode 100644 l10n_br_product_contract/demo/contract_template.xml
create mode 100644 l10n_br_product_contract/demo/product.xml
diff --git a/l10n_br_product_contract/__manifest__.py b/l10n_br_product_contract/__manifest__.py
index 21c3352bb071..38018bd42eef 100644
--- a/l10n_br_product_contract/__manifest__.py
+++ b/l10n_br_product_contract/__manifest__.py
@@ -18,6 +18,8 @@
'data': [
],
'demo': [
+ 'demo/contract_template.xml',
+ 'demo/product.xml',
'demo/sale_order.xml',
],
}
diff --git a/l10n_br_product_contract/demo/contract_template.xml b/l10n_br_product_contract/demo/contract_template.xml
new file mode 100644
index 000000000000..fda0f1ed0538
--- /dev/null
+++ b/l10n_br_product_contract/demo/contract_template.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Main Company - Sale Contract Template
+ sale
+
+
+
+
diff --git a/l10n_br_product_contract/demo/product.xml b/l10n_br_product_contract/demo/product.xml
new file mode 100644
index 000000000000..5aeed5d5e529
--- /dev/null
+++ b/l10n_br_product_contract/demo/product.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+ Recurrency Service
+ 100.0
+ 0.0
+ service
+ RECURRENCY_01
+
+
+
+
+ 09
+ issqn
+
+
+
+ True
+
+
+
+
+
diff --git a/l10n_br_product_contract/demo/sale_order.xml b/l10n_br_product_contract/demo/sale_order.xml
index 3552a23a6dd8..ddee5fcd67a5 100644
--- a/l10n_br_product_contract/demo/sale_order.xml
+++ b/l10n_br_product_contract/demo/sale_order.xml
@@ -1,13 +1,44 @@
-
-
+
+
+
+
+ Main l10n_br_product_contract - Serviço Recorrente
+
+
+
+
+
+
+ draft
+
+ TESTE
+
+
-
+
+
+
+
+
+
+
+
From ddceaf5bf3a6e673588f38c1bcf63151e5e18491 Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Thu, 20 May 2021 16:39:44 -0300
Subject: [PATCH 007/612] [IMP] add dependency l10n_br_sale
---
l10n_br_product_contract/__manifest__.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_product_contract/__manifest__.py b/l10n_br_product_contract/__manifest__.py
index 38018bd42eef..7e976eef89b4 100644
--- a/l10n_br_product_contract/__manifest__.py
+++ b/l10n_br_product_contract/__manifest__.py
@@ -12,6 +12,7 @@
'development_status': 'Beta',
'maintainers': ['mileo'],
'depends': [
+ 'l10n_br_sale',
'l10n_br_contract',
'product_contract',
],
From 382737d1fec62e4cff9ba615eba604b2794998a6 Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Thu, 20 May 2021 16:40:06 -0300
Subject: [PATCH 008/612] [FIX] remove .gitkeep file
---
l10n_br_product_contract/readme/newsfragments/.gitkeep | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 l10n_br_product_contract/readme/newsfragments/.gitkeep
diff --git a/l10n_br_product_contract/readme/newsfragments/.gitkeep b/l10n_br_product_contract/readme/newsfragments/.gitkeep
deleted file mode 100644
index e69de29bb2d1..000000000000
From f47b2a03a4072232dbd5e1982c9a034b37e207d5 Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Thu, 20 May 2021 18:27:15 -0300
Subject: [PATCH 009/612] [IMP] Teste basico
---
l10n_br_product_contract/tests/__init__.py | 4 ++++
.../tests/test_l10n_br_product_contract.py | 20 +++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 l10n_br_product_contract/tests/__init__.py
create mode 100644 l10n_br_product_contract/tests/test_l10n_br_product_contract.py
diff --git a/l10n_br_product_contract/tests/__init__.py b/l10n_br_product_contract/tests/__init__.py
new file mode 100644
index 000000000000..e98aff00a9ae
--- /dev/null
+++ b/l10n_br_product_contract/tests/__init__.py
@@ -0,0 +1,4 @@
+# Copyright 2021 - TODAY, Marcel Savegnago
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from . import test_l10n_br_product_contract
diff --git a/l10n_br_product_contract/tests/test_l10n_br_product_contract.py b/l10n_br_product_contract/tests/test_l10n_br_product_contract.py
new file mode 100644
index 000000000000..fbc32f41bdda
--- /dev/null
+++ b/l10n_br_product_contract/tests/test_l10n_br_product_contract.py
@@ -0,0 +1,20 @@
+# Copyright 2021 - TODAY, Marcel Savegnago
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.tests import SavepointCase
+
+
+class L10nBrSaleBaseTest(SavepointCase):
+
+ @classmethod
+ def setUpClass(self):
+ super().setUpClass()
+ self.main_company = self.env.ref('base.main_company')
+ self.company = self.env.ref('base.main_company')
+ self.so_recurrency_service = self.env.ref('l10n_br_product_contract.main_so_recurrency_service')
+ self.sl_recurrency_service = self.env.ref('l10n_br_product_contract.main_sl_recurrency_service_1_1')
+
+ def test_l10n_br_product_contract_confirm_so(self):
+ self.so_recurrency_service.action_confirm()
+ self.assertTrue(self.sl_recurrency_service.contract_id.contract_line_ids[0].fiscal_operation_id)
+ self.assertTrue(self.sl_recurrency_service.contract_id.contract_line_ids[0].fiscal_operation_line_id)
From f6e8237739d04f0ea27a3533e37113fb5283addd Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Thu, 20 May 2021 20:29:28 -0300
Subject: [PATCH 010/612] [FIX] fix flake8
---
.../tests/test_l10n_br_product_contract.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/l10n_br_product_contract/tests/test_l10n_br_product_contract.py b/l10n_br_product_contract/tests/test_l10n_br_product_contract.py
index fbc32f41bdda..c6f39ec697f9 100644
--- a/l10n_br_product_contract/tests/test_l10n_br_product_contract.py
+++ b/l10n_br_product_contract/tests/test_l10n_br_product_contract.py
@@ -11,10 +11,14 @@ def setUpClass(self):
super().setUpClass()
self.main_company = self.env.ref('base.main_company')
self.company = self.env.ref('base.main_company')
- self.so_recurrency_service = self.env.ref('l10n_br_product_contract.main_so_recurrency_service')
- self.sl_recurrency_service = self.env.ref('l10n_br_product_contract.main_sl_recurrency_service_1_1')
+ self.so_recurrency_service = \
+ self.env.ref('l10n_br_product_contract.main_so_recurrency_service')
+ self.sl_recurrency_service = \
+ self.env.ref('l10n_br_product_contract.main_sl_recurrency_service_1_1')
def test_l10n_br_product_contract_confirm_so(self):
self.so_recurrency_service.action_confirm()
- self.assertTrue(self.sl_recurrency_service.contract_id.contract_line_ids[0].fiscal_operation_id)
- self.assertTrue(self.sl_recurrency_service.contract_id.contract_line_ids[0].fiscal_operation_line_id)
+ self.assertTrue(self.sl_recurrency_service.contract_id.
+ contract_line_ids[0].fiscal_operation_id)
+ self.assertTrue(self.sl_recurrency_service.contract_id.
+ contract_line_ids[0].fiscal_operation_line_id)
From 40a239a8327ecdc8662bf62d5eab6d64fc5c254e Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 26 May 2021 19:38:49 -0300
Subject: [PATCH 011/612] [REF] api.multi
---
l10n_br_product_contract/models/sale_order.py | 3 +--
l10n_br_product_contract/models/sale_order_line.py | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/l10n_br_product_contract/models/sale_order.py b/l10n_br_product_contract/models/sale_order.py
index 643db6c778e6..2c28804cafc4 100644
--- a/l10n_br_product_contract/models/sale_order.py
+++ b/l10n_br_product_contract/models/sale_order.py
@@ -1,14 +1,13 @@
# Copyright 2021 KMEE - Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, models
+from odoo import models
class SaleOrder(models.Model):
_inherit = 'sale.order'
- @api.multi
def _prepare_contract_value(self, contract_template):
self.ensure_one()
vals = self._prepare_br_fiscal_dict()
diff --git a/l10n_br_product_contract/models/sale_order_line.py b/l10n_br_product_contract/models/sale_order_line.py
index 8d9fe9f244f8..c58198a26937 100644
--- a/l10n_br_product_contract/models/sale_order_line.py
+++ b/l10n_br_product_contract/models/sale_order_line.py
@@ -1,14 +1,13 @@
# Copyright 2021 KMEE - Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, models
+from odoo import models
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
- @api.multi
def _prepare_contract_line_values(
self, contract, predecessor_contract_line_id=False
):
From d67722be340ae52f0178dc32c50c254dd1887d15 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 17 Nov 2015 17:29:16 -0200
Subject: [PATCH 012/612] change version and added readme file in
l10n_br_stock_account
---
l10n_br_stock_account/README.md | 77 +++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 l10n_br_stock_account/README.md
diff --git a/l10n_br_stock_account/README.md b/l10n_br_stock_account/README.md
new file mode 100644
index 000000000000..f238fe1a96b2
--- /dev/null
+++ b/l10n_br_stock_account/README.md
@@ -0,0 +1,77 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+
+==========================================
+Módulo Stock Account
+==========================================
+
+ * do this ...
+
+Installation
+============
+
+To install this module, you need to:
+
+* do this ...
+
+Configuration
+=============
+
+To configure this module, you need to:
+
+* go to ...
+
+Usage
+=====
+
+To use this module, you need to:
+
+* go to ...
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+ :alt: Try me on Runbot
+ :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
+
+
+.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
+.. branch is "8.0" for example
+
+Known issues / Roadmap
+======================
+
+TODO
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_.
+
+
+Credits
+=======
+
+Contributors
+------------
+
+* Renato Lima
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+To contribute to this module, please visit http://odoo-community.org.
From ff057e81a3579523bb852a64a37c1b0e52297bc3 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Thu, 19 Nov 2015 12:44:46 -0200
Subject: [PATCH 013/612] added tests
---
.../test/stock_internal_picking.yml | 51 +++++++++++++++++++
.../test/stock_return_internal_picking.yml | 24 +++++++++
2 files changed, 75 insertions(+)
create mode 100644 l10n_br_stock_account/test/stock_internal_picking.yml
create mode 100644 l10n_br_stock_account/test/stock_return_internal_picking.yml
diff --git a/l10n_br_stock_account/test/stock_internal_picking.yml b/l10n_br_stock_account/test/stock_internal_picking.yml
new file mode 100644
index 000000000000..33f081b25f53
--- /dev/null
+++ b/l10n_br_stock_account/test/stock_internal_picking.yml
@@ -0,0 +1,51 @@
+-
+ I prepare tunneling extra args in the context
+-
+ !python {model: stock.move}: |
+ context.update({'parent_fiscal_category_id': ref('l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a'), 'invoice_state': '2binvoiced'})
+-
+ Create a picking to be invoice from SP to SP fiscal contributor
+-
+ !record {model: stock.picking, id: stock_picking_sp, view: l10n_br_view_picking_form1}:
+ partner_id: l10n_br_base.res_partner_cliente1_sp
+ invoice_state: 2binvoiced
+ picking_type_id: stock.picking_type_internal
+ fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
+ fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
+ name: Outgoing picking
+ move_lines:
+ - product_id: product.product_product_10
+ product_uom_qty: 5.00
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ invoice_state: 2binvoiced
+ fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
+ fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
+ - product_id: product.product_product_18
+ product_uom_qty: 10.00
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ invoice_state: 2binvoiced
+ fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
+ fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
+-
+ Assign and confirm
+-
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref('stock_picking_sp')], context=context)
+ self.action_assign(cr, uid, [ref('stock_picking_sp')])
+ self.do_prepare_partial(cr, uid, [ref('stock_picking_sp')])
+ self.do_transfer(cr, uid, [ref('stock_picking_sp')], context=context)
+-
+ I create a invoice
+-
+ !python {model: stock.invoice.onshipping}: |
+ context.update({"active_model": 'stock.picking', "active_ids": [ref("stock_picking_sp")]})
+ wizard_id = self.create(cr, uid, {'fiscal_category_journal': True}, context=context)
+ invoice_id = self.create_invoice(cr, uid, [wizard_id], context=context)
+ assert invoice_id, "Invoice refund not created!"
+ invoices = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
+ for invoice in invoices:
+ assert invoice.fiscal_category_id.id == ref('l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a'), "Wrong refund fiscal category!"
+ for line in invoice.invoice_line:
+ assert line.cfop_id.code == '5949', "Wrong CFOP Code"
diff --git a/l10n_br_stock_account/test/stock_return_internal_picking.yml b/l10n_br_stock_account/test/stock_return_internal_picking.yml
new file mode 100644
index 000000000000..10e05585773e
--- /dev/null
+++ b/l10n_br_stock_account/test/stock_return_internal_picking.yml
@@ -0,0 +1,24 @@
+-
+ I create a reverse picking
+-
+ !python {model: stock.return.picking}: |
+ ctx = context.copy()
+ ctx.update({"active_model": 'stock.picking', "active_id": [ref("stock_picking_sp")]})
+ wizard_id = self.create(cr, uid, {'invoice_state': '2binvoiced'}, context=ctx)
+ wizard = self.browse(cr, uid, wizard_id, context=ctx)
+ for line in wizard.product_return_moves:
+ self.pool.get('stock.return.picking.line').write(cr, uid, line.id, {'quantity': line.move_id.product_uom_qty})
+ result = self.create_returns(cr, uid, [wizard_id], context=ctx)
+ from openerp.tools.safe_eval import safe_eval
+ if result['domain']:
+ domain = safe_eval(result['domain'])
+ picking_return_id = self.pool.get('stock.picking').search(cr, uid, domain)
+ assert picking_return_id, "Can't create return picking"
+ ctx.update({"active_model": 'stock.picking', "active_ids": picking_return_id})
+ wizard_id = self.pool.get('stock.invoice.onshipping').create(cr, uid, {'fiscal_category_journal': True}, context=ctx)
+ invoice_id = self.pool.get('stock.invoice.onshipping').create_invoice(cr, uid, [wizard_id], context=ctx)
+ assert invoice_id, "Invoice refund not created!"
+ invoices = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
+ for invoice in invoices:
+ for line in invoice.invoice_line:
+ assert line.cfop_id.code == '1949', "Wrong CFOP Code"
From 0803d0557d9c982d7608fc91ec5cca33c27e7d68 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 15 Apr 2020 13:10:08 -0300
Subject: [PATCH 014/612] [12.0][MIG][REF] Views.
---
l10n_br_stock_account/views/stock_account_view.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_stock_account/views/stock_account_view.xml b/l10n_br_stock_account/views/stock_account_view.xml
index 3e83e9af52cd..03128dc6e86e 100644
--- a/l10n_br_stock_account/views/stock_account_view.xml
+++ b/l10n_br_stock_account/views/stock_account_view.xml
@@ -63,4 +63,5 @@
+
From 72ad2569f6ad640747a922221fbafe802c37ac46 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 15 Apr 2020 16:47:57 -0300
Subject: [PATCH 015/612] [12.0][MIG][FIX] Create new view to stock.move to
include Fiscal Data, Taxes and avoid inherit errors.
---
l10n_br_stock_account/views/stock_account_view.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/l10n_br_stock_account/views/stock_account_view.xml b/l10n_br_stock_account/views/stock_account_view.xml
index 03128dc6e86e..3e83e9af52cd 100644
--- a/l10n_br_stock_account/views/stock_account_view.xml
+++ b/l10n_br_stock_account/views/stock_account_view.xml
@@ -63,5 +63,4 @@
-
From c14e41552c3f5a583042e76e4379fce32bb63462 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Sat, 25 Oct 2014 01:26:07 -0200
Subject: [PATCH 016/612] begining split l10n_br_stock in l10n_br_stock and
l10n_br_stock_account
---
l10n_br_stock_account/__openerp__.py | 37 ++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 l10n_br_stock_account/__openerp__.py
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
new file mode 100644
index 000000000000..0fd4da0c0263
--- /dev/null
+++ b/l10n_br_stock_account/__openerp__.py
@@ -0,0 +1,37 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+# #
+# Copyright (C) 2014 Renato Lima - Akretion #
+# #
+#This program is free software: you can redistribute it and/or modify #
+#it under the terms of the GNU Affero General Public License as published by #
+#the Free Software Foundation, either version 3 of the License, or #
+#(at your option) any later version. #
+# #
+#This program is distributed in the hope that it will be useful, #
+#but WITHOUT ANY WARRANTY; without even the implied warranty of #
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+#GNU Affero General Public License for more details. #
+# #
+#You should have received a copy of the GNU Affero General Public License #
+#along with this program. If not, see . #
+###############################################################################
+
+{
+ 'name': 'Brazilian Localization WMS Accounting',
+ 'description': 'Brazilian Localization WMS Accounting',
+ 'category': 'Localisation',
+ 'license': 'AGPL-3',
+ 'author': 'Akretion, Odoo Brasil',
+ 'website': 'http://odoo-brasil.org',
+ 'version': '8.0',
+ 'depends': [
+ 'l10n_br_account_product',
+ 'account_fiscal_position_rule_stock',
+ ],
+ 'data': [
+ ],
+ 'demo': [],
+ 'installable': True,
+ 'auto_install': True,
+}
From 5473ba91ef2883ca38fcb63506c31f51dabc97e0 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Sat, 25 Oct 2014 01:31:37 -0200
Subject: [PATCH 017/612] move wizard and security folder to
l10n_br_stock_account
---
l10n_br_stock_account/__openerp__.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 0fd4da0c0263..32bfb4ef2900 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -30,6 +30,8 @@
'account_fiscal_position_rule_stock',
],
'data': [
+ 'wizard/stock_invoice_onshipping_view.xml',
+ 'security/ir.model.access.csv',
],
'demo': [],
'installable': True,
From c958e2b99e4def2f8a4eb5f7cb4c967b15ec8e19 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 7 Jan 2015 14:43:52 -0200
Subject: [PATCH 018/612] added l10n_br_stock dependency
---
l10n_br_stock_account/__openerp__.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 32bfb4ef2900..088113696095 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -27,6 +27,7 @@
'version': '8.0',
'depends': [
'l10n_br_account_product',
+ 'l10n_br_stock',
'account_fiscal_position_rule_stock',
],
'data': [
From 2ad6f9a56d840c71be46ee9758522e02558cc29a Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 17 Nov 2015 17:29:16 -0200
Subject: [PATCH 019/612] change version and added readme file in
l10n_br_stock_account
---
l10n_br_stock_account/__openerp__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 088113696095..08d5b48b324d 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -22,9 +22,9 @@
'description': 'Brazilian Localization WMS Accounting',
'category': 'Localisation',
'license': 'AGPL-3',
- 'author': 'Akretion, Odoo Brasil',
+ 'author': 'Akretion, Odoo Community Association (OCA)',
'website': 'http://odoo-brasil.org',
- 'version': '8.0',
+ 'version': '8.0.1.0.0',
'depends': [
'l10n_br_account_product',
'l10n_br_stock',
From 0c58d80b27eaa491beb8bd027b91145226244efb Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 17 Nov 2015 17:47:02 -0200
Subject: [PATCH 020/612] pep8
remove from __openerp__ invalid key
pep8
---
l10n_br_stock_account/README.md | 77 ----------------------------
l10n_br_stock_account/__openerp__.py | 1 -
2 files changed, 78 deletions(-)
delete mode 100644 l10n_br_stock_account/README.md
diff --git a/l10n_br_stock_account/README.md b/l10n_br_stock_account/README.md
deleted file mode 100644
index f238fe1a96b2..000000000000
--- a/l10n_br_stock_account/README.md
+++ /dev/null
@@ -1,77 +0,0 @@
-.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
- :alt: License: AGPL-3
-
-==========================================
-Módulo Stock Account
-==========================================
-
- * do this ...
-
-Installation
-============
-
-To install this module, you need to:
-
-* do this ...
-
-Configuration
-=============
-
-To configure this module, you need to:
-
-* go to ...
-
-Usage
-=====
-
-To use this module, you need to:
-
-* go to ...
-
-.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
- :alt: Try me on Runbot
- :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
-
-
-.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
-.. branch is "8.0" for example
-
-Known issues / Roadmap
-======================
-
-TODO
-
-Bug Tracker
-===========
-
-Bugs are tracked on `GitHub Issues `_.
-In case of trouble, please check there if your issue has already been reported.
-If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_.
-
-
-Credits
-=======
-
-Contributors
-------------
-
-* Renato Lima
-
-Maintainer
-----------
-
-.. image:: https://odoo-community.org/logo.png
- :alt: Odoo Community Association
- :target: https://odoo-community.org
-
-This module is maintained by the OCA.
-
-OCA, or the Odoo Community Association, is a nonprofit organization whose
-mission is to support the collaborative development of Odoo features and
-promote its widespread use.
-
-To contribute to this module, please visit http://odoo-community.org.
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 08d5b48b324d..77d31ca853a3 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -19,7 +19,6 @@
{
'name': 'Brazilian Localization WMS Accounting',
- 'description': 'Brazilian Localization WMS Accounting',
'category': 'Localisation',
'license': 'AGPL-3',
'author': 'Akretion, Odoo Community Association (OCA)',
From 4d30cca72f060adc9dfe70a7a33c29bc19a9c628 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Thu, 19 Nov 2015 12:44:46 -0200
Subject: [PATCH 021/612] added tests
---
l10n_br_stock_account/__openerp__.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 77d31ca853a3..e5cc2d01e873 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -34,6 +34,10 @@
'security/ir.model.access.csv',
],
'demo': [],
+ 'test': [
+ 'test/stock_internal_picking.yml',
+ 'test/stock_return_internal_picking.yml',
+ ],
'installable': True,
'auto_install': True,
}
From 2f16f5569fe0c55af7eb3db492817b36b5c0119f Mon Sep 17 00:00:00 2001
From: Alexandre Fayolle
Date: Mon, 15 Feb 2016 09:02:35 +0100
Subject: [PATCH 022/612] [SEC] l10n_br_stock_account: fix unsafe eval
---
l10n_br_stock_account/__openerp__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index e5cc2d01e873..efa84b5146ae 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -23,7 +23,7 @@
'license': 'AGPL-3',
'author': 'Akretion, Odoo Community Association (OCA)',
'website': 'http://odoo-brasil.org',
- 'version': '8.0.1.0.0',
+ 'version': '8.0.1.0.1',
'depends': [
'l10n_br_account_product',
'l10n_br_stock',
From 9f20381e84377d9c7752141a2e8f689ac70b0cae Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 15 Apr 2016 16:37:25 -0300
Subject: [PATCH 023/612] [WIP][NEW] Stock Account Report
---
l10n_br_stock_account/__openerp__.py | 2 +
l10n_br_stock_account/report/__init__.py | 5 ++
.../report/stock_valuation_history_xls.py | 73 +++++++++++++++++++
l10n_br_stock_account/wizards/__init__.py | 1 +
4 files changed, 81 insertions(+)
create mode 100644 l10n_br_stock_account/report/__init__.py
create mode 100644 l10n_br_stock_account/report/stock_valuation_history_xls.py
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index efa84b5146ae..6503b3d33219 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -28,9 +28,11 @@
'l10n_br_account_product',
'l10n_br_stock',
'account_fiscal_position_rule_stock',
+ 'report_xls',
],
'data': [
'wizard/stock_invoice_onshipping_view.xml',
+ 'wizard/stock_valuation_history_view.xml',
'security/ir.model.access.csv',
],
'demo': [],
diff --git a/l10n_br_stock_account/report/__init__.py b/l10n_br_stock_account/report/__init__.py
new file mode 100644
index 000000000000..e2fd9d96cb3a
--- /dev/null
+++ b/l10n_br_stock_account/report/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# © 2016 KMEE INFORMATICA LTDA ()
+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+
+from . import stock_valuation_history_xls
\ No newline at end of file
diff --git a/l10n_br_stock_account/report/stock_valuation_history_xls.py b/l10n_br_stock_account/report/stock_valuation_history_xls.py
new file mode 100644
index 000000000000..2242dd16c4c6
--- /dev/null
+++ b/l10n_br_stock_account/report/stock_valuation_history_xls.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# © 2016 KMEE INFORMATICA LTDA ()
+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+
+import xlwt
+from openerp.report import report_sxw
+from openerp.addons.report_xls.report_xls import report_xls
+import logging
+_logger = logging.getLogger(__name__)
+
+
+class StockHistoryXlsParser(report_sxw.rml_parse):
+
+ def __init__(self, cr, uid, name, context):
+ super(StockHistoryXlsParser, self).__init__(
+ cr, uid, name, context=context)
+ self.context = context
+
+
+class StockHistoryXls(report_xls):
+
+ def __init__(self, name, table, rml=False, parser=False, header=True,
+ store=False):
+ super(StockHistoryXls, self).__init__(
+ name, table, rml, parser, header, store)
+
+ # Cell Styles
+ _xs = self.xls_styles
+ # header
+ rh_cell_format = _xs['bold'] + _xs['fill'] + \
+ _xs['borders_all'] + _xs['right']
+ self.rh_cell_style = xlwt.easyxf(rh_cell_format)
+ self.rh_cell_style_date = xlwt.easyxf(
+ rh_cell_format, num_format_str=report_xls.date_format)
+ # lines
+ self.mis_rh_cell_style = xlwt.easyxf(
+ _xs['borders_all'] + _xs['bold'] + _xs['fill'])
+
+ def generate_xls_report(self, _p, _xs, data, objects, wb):
+
+ report_name = 'Relatório de Valorização de Estoque'
+ ws = wb.add_sheet(report_name[:31])
+ ws.panes_frozen = True
+ ws.remove_splits = True
+ ws.portrait = 0 # Landscape
+ ws.fit_width_to_pages = 1
+ row_pos = 0
+
+ # set print header/footer
+ ws.header_str = self.xls_headers['standard']
+ ws.footer_str = self.xls_footers['standard']
+
+ # Title
+ c_specs = [
+ ('report_name', 1, 0, 'text', report_name),
+ ]
+ row_data = self.xls_row_template(c_specs, ['report_name'])
+ row_pos = self.xls_write_row(
+ ws, row_pos, row_data, row_style=xlwt.easyxf(_xs['xls_title']))
+ row_pos += 1
+
+ active_ids = self.context.get('active_ids')
+ wizard_obj = self.pool.get('wizard.valuation.history').browse(
+ self.cr, self.uid, active_ids)
+
+ wizard_obj.compute(self.cr, self.uid, objects[0].id, date=wizard_obj.date)
+ from pprint import pprint
+ pprint(data)
+ pass
+
+
+StockHistoryXls('report.wizard.valuation.history.xls',
+ 'wizard.valuation.history.xls', parser=StockHistoryXlsParser)
diff --git a/l10n_br_stock_account/wizards/__init__.py b/l10n_br_stock_account/wizards/__init__.py
index d82a2b40d2c5..af362ebe51cc 100644
--- a/l10n_br_stock_account/wizards/__init__.py
+++ b/l10n_br_stock_account/wizards/__init__.py
@@ -3,3 +3,4 @@
from . import stock_invoice_onshipping
from . import stock_return_picking
+from . import stock_valuation_history
From 4443429cd20b8b09a7d2c04b600c277c8a6897b6 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 27 Apr 2016 14:24:03 -0300
Subject: [PATCH 024/612] [NEW] XLS Stock History Report
---
l10n_br_stock_account/__openerp__.py | 1 +
l10n_br_stock_account/report/__init__.py | 23 +++-
.../report/stock_valuation_history_xls.py | 109 ++++++++++++++++--
3 files changed, 120 insertions(+), 13 deletions(-)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 6503b3d33219..6264f400436f 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -29,6 +29,7 @@
'l10n_br_stock',
'account_fiscal_position_rule_stock',
'report_xls',
+ 'stock_account',
],
'data': [
'wizard/stock_invoice_onshipping_view.xml',
diff --git a/l10n_br_stock_account/report/__init__.py b/l10n_br_stock_account/report/__init__.py
index e2fd9d96cb3a..09bcc117468e 100644
--- a/l10n_br_stock_account/report/__init__.py
+++ b/l10n_br_stock_account/report/__init__.py
@@ -1,5 +1,22 @@
# -*- coding: utf-8 -*-
-# © 2016 KMEE INFORMATICA LTDA ()
-# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+##############################################################################
+#
+# Copyright (c) 2016 Kmee - www.kmee.com.br
+# @authors Daniel Sadamo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
-from . import stock_valuation_history_xls
\ No newline at end of file
+from . import stock_valuation_history_xls
diff --git a/l10n_br_stock_account/report/stock_valuation_history_xls.py b/l10n_br_stock_account/report/stock_valuation_history_xls.py
index 2242dd16c4c6..74cd5feed652 100644
--- a/l10n_br_stock_account/report/stock_valuation_history_xls.py
+++ b/l10n_br_stock_account/report/stock_valuation_history_xls.py
@@ -1,10 +1,28 @@
# -*- coding: utf-8 -*-
-# © 2016 KMEE INFORMATICA LTDA ()
-# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+##############################################################################
+#
+# Copyright (c) 2016 Kmee - www.kmee.com.br
+# @authors Daniel Sadamo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
import xlwt
from openerp.report import report_sxw
from openerp.addons.report_xls.report_xls import report_xls
+from openerp.addons.report_xls.utils import _render
import logging
_logger = logging.getLogger(__name__)
@@ -30,11 +48,52 @@ def __init__(self, name, table, rml=False, parser=False, header=True,
rh_cell_format = _xs['bold'] + _xs['fill'] + \
_xs['borders_all'] + _xs['right']
self.rh_cell_style = xlwt.easyxf(rh_cell_format)
+ self.rh_cell_style_center = xlwt.easyxf(rh_cell_format + _xs['center'])
+ self.rh_cell_style_right = xlwt.easyxf(rh_cell_format + _xs['right'])
self.rh_cell_style_date = xlwt.easyxf(
rh_cell_format, num_format_str=report_xls.date_format)
# lines
- self.mis_rh_cell_style = xlwt.easyxf(
- _xs['borders_all'] + _xs['bold'] + _xs['fill'])
+ line_cell_format = _xs['borders_all']
+ self.line_cell_style_decimal = xlwt.easyxf(
+ line_cell_format + _xs['right'],
+ num_format_str=report_xls.decimal_format)
+ self.line_cell_style = xlwt.easyxf(line_cell_format)
+
+ self.col_specs_template = {
+ 'fiscal_classification_id': {
+ 'header': [1, 10, 'text', _render("('NCM')")],
+ 'lines': [1, 0, 'text',
+ _render("line.get('fiscal_classification_id', '')")],
+ 'totals': [1, 0, 'text', None]},
+ 'product_id': {
+ 'header': [1, 50, 'text', _render("('Produto')")],
+ 'lines': [1, 0, 'text',
+ _render("line.get('product_id', False) and "
+ "line.get('product_id')[1] or ''")],
+ 'totals': [1, 0, 'text', None]},
+ # 'product_id_count': {
+ # 'header': [1, 20, 'text', _render("('Contagem')")],
+ # 'lines': [1, 0, 'text',
+ # _render("str(line.get('product_id_count', "") or '')")],
+ # 'totals': [1, 0, 'text', None]},
+ 'price_unit_on_quant': {
+ 'header': [1, 25, 'text',
+ _render("('Preço de custo no periodo')")],
+ 'lines': [1, 0, 'number',
+ _render("line.get('price_unit_on_quant')"),
+ None, self.line_cell_style_decimal],
+ 'totals': [1, 0, 'text', None]},
+ 'quantity': {
+ 'header': [1, 15, 'text', _render("('Quantidade')")],
+ 'lines': [1, 0, 'number', _render("line.get('quantity', 0)")],
+ 'totals': [1, 0, 'text', None]},
+ 'inventory_value': {
+ 'header': [1, 15, 'text', _render("('Valor Total')")],
+ 'lines': [1, 0, 'number',
+ _render("line.get('inventory_value', 0)"),
+ None, self.line_cell_style_decimal],
+ 'totals': [1, 0, 'text', None]},
+ }
def generate_xls_report(self, _p, _xs, data, objects, wb):
@@ -59,15 +118,45 @@ def generate_xls_report(self, _p, _xs, data, objects, wb):
ws, row_pos, row_data, row_style=xlwt.easyxf(_xs['xls_title']))
row_pos += 1
+ # Column headers
+ c_specs = map(lambda x: self.render(
+ x, self.col_specs_template, 'header'),
+ [
+ 'product_id',
+ 'fiscal_classification_id',
+ # 'product_id_count',
+ 'quantity',
+ 'price_unit_on_quant',
+ 'inventory_value'
+ ])
+ row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+ row_pos = self.xls_write_row(
+ ws, row_pos, row_data, row_style=self.rh_cell_style_center,
+ set_column_size=True)
+ ws.set_horz_split_pos(row_pos)
+
+ # Lines
active_ids = self.context.get('active_ids')
wizard_obj = self.pool.get('wizard.valuation.history').browse(
self.cr, self.uid, active_ids)
-
- wizard_obj.compute(self.cr, self.uid, objects[0].id, date=wizard_obj.date)
- from pprint import pprint
- pprint(data)
+ data = wizard_obj.compute(
+ self.cr, self.uid, objects[0].id, date=wizard_obj.date)
+ for line in data:
+ c_specs = map(
+ lambda x: self.render(
+ x, self.col_specs_template, 'lines'), [
+ 'product_id',
+ 'fiscal_classification_id',
+ # 'product_id_count',
+ 'quantity',
+ 'price_unit_on_quant',
+ 'inventory_value'
+ ])
+ row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+ row_pos = self.xls_write_row(
+ ws, row_pos, row_data, row_style=self.line_cell_style)
pass
-StockHistoryXls('report.wizard.valuation.history.xls',
- 'wizard.valuation.history.xls', parser=StockHistoryXlsParser)
+StockHistoryXls('report.wizard.valuation.history',
+ 'wizard.valuation.history', parser=StockHistoryXlsParser)
From a916258ef7b8950c7928cead3a65dbebf54f6d39 Mon Sep 17 00:00:00 2001
From: Magno Costa - Akretion
Date: Wed, 18 May 2016 12:06:14 -0300
Subject: [PATCH 025/612] Modify the methods to use old API because the Context
is not being pass to method read_group, the reason seems because this method
still remains in the old API.
---
l10n_br_stock_account/report/stock_valuation_history_xls.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/report/stock_valuation_history_xls.py b/l10n_br_stock_account/report/stock_valuation_history_xls.py
index 74cd5feed652..8129fffe4a3e 100644
--- a/l10n_br_stock_account/report/stock_valuation_history_xls.py
+++ b/l10n_br_stock_account/report/stock_valuation_history_xls.py
@@ -140,7 +140,8 @@ def generate_xls_report(self, _p, _xs, data, objects, wb):
wizard_obj = self.pool.get('wizard.valuation.history').browse(
self.cr, self.uid, active_ids)
data = wizard_obj.compute(
- self.cr, self.uid, objects[0].id, date=wizard_obj.date)
+ self.cr, self.uid, objects[0].id, date=wizard_obj.date,
+ context=self.context)
for line in data:
c_specs = map(
lambda x: self.render(
From bca7e0f94bd3f02c97d2d6976421a347b659eb51 Mon Sep 17 00:00:00 2001
From: Magno Costa - Akretion
Date: Mon, 23 May 2016 14:23:45 -0300
Subject: [PATCH 026/612] Remove unused lines.
---
l10n_br_stock_account/report/stock_valuation_history_xls.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/l10n_br_stock_account/report/stock_valuation_history_xls.py b/l10n_br_stock_account/report/stock_valuation_history_xls.py
index 8129fffe4a3e..a478b30db561 100644
--- a/l10n_br_stock_account/report/stock_valuation_history_xls.py
+++ b/l10n_br_stock_account/report/stock_valuation_history_xls.py
@@ -71,11 +71,6 @@ def __init__(self, name, table, rml=False, parser=False, header=True,
_render("line.get('product_id', False) and "
"line.get('product_id')[1] or ''")],
'totals': [1, 0, 'text', None]},
- # 'product_id_count': {
- # 'header': [1, 20, 'text', _render("('Contagem')")],
- # 'lines': [1, 0, 'text',
- # _render("str(line.get('product_id_count', "") or '')")],
- # 'totals': [1, 0, 'text', None]},
'price_unit_on_quant': {
'header': [1, 25, 'text',
_render("('Preço de custo no periodo')")],
@@ -148,7 +143,6 @@ def generate_xls_report(self, _p, _xs, data, objects, wb):
x, self.col_specs_template, 'lines'), [
'product_id',
'fiscal_classification_id',
- # 'product_id_count',
'quantity',
'price_unit_on_quant',
'inventory_value'
From 191bbf4880fcdc6bf140afc34aa82433c7fdab35 Mon Sep 17 00:00:00 2001
From: Magno Costa - Akretion
Date: Mon, 6 Jun 2016 18:12:57 -0300
Subject: [PATCH 027/612] [REF] Move Stock Valution XLS Report to new module,
because of direct dependencie of report_xls module.
---
l10n_br_stock_account/__openerp__.py | 2 -
l10n_br_stock_account/report/__init__.py | 22 ---
.../report/stock_valuation_history_xls.py | 157 ------------------
l10n_br_stock_account/wizards/__init__.py | 1 -
4 files changed, 182 deletions(-)
delete mode 100644 l10n_br_stock_account/report/__init__.py
delete mode 100644 l10n_br_stock_account/report/stock_valuation_history_xls.py
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 6264f400436f..29957e860ea3 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -28,12 +28,10 @@
'l10n_br_account_product',
'l10n_br_stock',
'account_fiscal_position_rule_stock',
- 'report_xls',
'stock_account',
],
'data': [
'wizard/stock_invoice_onshipping_view.xml',
- 'wizard/stock_valuation_history_view.xml',
'security/ir.model.access.csv',
],
'demo': [],
diff --git a/l10n_br_stock_account/report/__init__.py b/l10n_br_stock_account/report/__init__.py
deleted file mode 100644
index 09bcc117468e..000000000000
--- a/l10n_br_stock_account/report/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2016 Kmee - www.kmee.com.br
-# @authors Daniel Sadamo
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from . import stock_valuation_history_xls
diff --git a/l10n_br_stock_account/report/stock_valuation_history_xls.py b/l10n_br_stock_account/report/stock_valuation_history_xls.py
deleted file mode 100644
index a478b30db561..000000000000
--- a/l10n_br_stock_account/report/stock_valuation_history_xls.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2016 Kmee - www.kmee.com.br
-# @authors Daniel Sadamo
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import xlwt
-from openerp.report import report_sxw
-from openerp.addons.report_xls.report_xls import report_xls
-from openerp.addons.report_xls.utils import _render
-import logging
-_logger = logging.getLogger(__name__)
-
-
-class StockHistoryXlsParser(report_sxw.rml_parse):
-
- def __init__(self, cr, uid, name, context):
- super(StockHistoryXlsParser, self).__init__(
- cr, uid, name, context=context)
- self.context = context
-
-
-class StockHistoryXls(report_xls):
-
- def __init__(self, name, table, rml=False, parser=False, header=True,
- store=False):
- super(StockHistoryXls, self).__init__(
- name, table, rml, parser, header, store)
-
- # Cell Styles
- _xs = self.xls_styles
- # header
- rh_cell_format = _xs['bold'] + _xs['fill'] + \
- _xs['borders_all'] + _xs['right']
- self.rh_cell_style = xlwt.easyxf(rh_cell_format)
- self.rh_cell_style_center = xlwt.easyxf(rh_cell_format + _xs['center'])
- self.rh_cell_style_right = xlwt.easyxf(rh_cell_format + _xs['right'])
- self.rh_cell_style_date = xlwt.easyxf(
- rh_cell_format, num_format_str=report_xls.date_format)
- # lines
- line_cell_format = _xs['borders_all']
- self.line_cell_style_decimal = xlwt.easyxf(
- line_cell_format + _xs['right'],
- num_format_str=report_xls.decimal_format)
- self.line_cell_style = xlwt.easyxf(line_cell_format)
-
- self.col_specs_template = {
- 'fiscal_classification_id': {
- 'header': [1, 10, 'text', _render("('NCM')")],
- 'lines': [1, 0, 'text',
- _render("line.get('fiscal_classification_id', '')")],
- 'totals': [1, 0, 'text', None]},
- 'product_id': {
- 'header': [1, 50, 'text', _render("('Produto')")],
- 'lines': [1, 0, 'text',
- _render("line.get('product_id', False) and "
- "line.get('product_id')[1] or ''")],
- 'totals': [1, 0, 'text', None]},
- 'price_unit_on_quant': {
- 'header': [1, 25, 'text',
- _render("('Preço de custo no periodo')")],
- 'lines': [1, 0, 'number',
- _render("line.get('price_unit_on_quant')"),
- None, self.line_cell_style_decimal],
- 'totals': [1, 0, 'text', None]},
- 'quantity': {
- 'header': [1, 15, 'text', _render("('Quantidade')")],
- 'lines': [1, 0, 'number', _render("line.get('quantity', 0)")],
- 'totals': [1, 0, 'text', None]},
- 'inventory_value': {
- 'header': [1, 15, 'text', _render("('Valor Total')")],
- 'lines': [1, 0, 'number',
- _render("line.get('inventory_value', 0)"),
- None, self.line_cell_style_decimal],
- 'totals': [1, 0, 'text', None]},
- }
-
- def generate_xls_report(self, _p, _xs, data, objects, wb):
-
- report_name = 'Relatório de Valorização de Estoque'
- ws = wb.add_sheet(report_name[:31])
- ws.panes_frozen = True
- ws.remove_splits = True
- ws.portrait = 0 # Landscape
- ws.fit_width_to_pages = 1
- row_pos = 0
-
- # set print header/footer
- ws.header_str = self.xls_headers['standard']
- ws.footer_str = self.xls_footers['standard']
-
- # Title
- c_specs = [
- ('report_name', 1, 0, 'text', report_name),
- ]
- row_data = self.xls_row_template(c_specs, ['report_name'])
- row_pos = self.xls_write_row(
- ws, row_pos, row_data, row_style=xlwt.easyxf(_xs['xls_title']))
- row_pos += 1
-
- # Column headers
- c_specs = map(lambda x: self.render(
- x, self.col_specs_template, 'header'),
- [
- 'product_id',
- 'fiscal_classification_id',
- # 'product_id_count',
- 'quantity',
- 'price_unit_on_quant',
- 'inventory_value'
- ])
- row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
- row_pos = self.xls_write_row(
- ws, row_pos, row_data, row_style=self.rh_cell_style_center,
- set_column_size=True)
- ws.set_horz_split_pos(row_pos)
-
- # Lines
- active_ids = self.context.get('active_ids')
- wizard_obj = self.pool.get('wizard.valuation.history').browse(
- self.cr, self.uid, active_ids)
- data = wizard_obj.compute(
- self.cr, self.uid, objects[0].id, date=wizard_obj.date,
- context=self.context)
- for line in data:
- c_specs = map(
- lambda x: self.render(
- x, self.col_specs_template, 'lines'), [
- 'product_id',
- 'fiscal_classification_id',
- 'quantity',
- 'price_unit_on_quant',
- 'inventory_value'
- ])
- row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
- row_pos = self.xls_write_row(
- ws, row_pos, row_data, row_style=self.line_cell_style)
- pass
-
-
-StockHistoryXls('report.wizard.valuation.history',
- 'wizard.valuation.history', parser=StockHistoryXlsParser)
diff --git a/l10n_br_stock_account/wizards/__init__.py b/l10n_br_stock_account/wizards/__init__.py
index af362ebe51cc..d82a2b40d2c5 100644
--- a/l10n_br_stock_account/wizards/__init__.py
+++ b/l10n_br_stock_account/wizards/__init__.py
@@ -3,4 +3,3 @@
from . import stock_invoice_onshipping
from . import stock_return_picking
-from . import stock_valuation_history
From ae67140efc0f6a8623bf5ef392254404e6a5dcec Mon Sep 17 00:00:00 2001
From: renato
Date: Tue, 17 May 2016 14:42:04 -0300
Subject: [PATCH 028/612] added fiscal_category_id in stock.location.path
Conflicts:
l10n_br_stock_account/__openerp__.py
l10n_br_stock_account/models/__init__.py
Conflicts:
l10n_br_stock_account/__openerp__.py
l10n_br_stock_account/models/__init__.py
---
l10n_br_stock_account/models/stock.py | 68 ++++++++++++++++++++++
l10n_br_stock_account/views/stock_view.xml | 20 +++++++
2 files changed, 88 insertions(+)
create mode 100644 l10n_br_stock_account/models/stock.py
create mode 100644 l10n_br_stock_account/views/stock_view.xml
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
new file mode 100644
index 000000000000..c8e9791ad242
--- /dev/null
+++ b/l10n_br_stock_account/models/stock.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+# Copyright (C) 2016 Renato Lima - Akretion
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+###############################################################################
+
+from openerp import models, fields, api
+
+
+class StockPicking(models.Model):
+ _inherit = 'stock.location.path'
+
+ fiscal_category_id = fields.Many2one(
+ 'l10n_br_account.fiscal.category', 'Categoria Fiscal',
+ domain="[('state', '=', 'approved')]")
+
+ @api.model
+ def _prepare_push_apply(self, rule, move):
+ result = super(StockPicking, self)._prepare_push_apply(rule, move)
+ if rule.fiscal_category_id:
+
+ ctx = dict(self.env.context)
+ ctx.update({'use_domain': ('use_picking', '=', True)})
+
+ kwargs = {
+ 'partner_id': move.picking_id.partner_id.id,
+ 'product_id': move.product_id.id,
+ 'partner_invoice_id': move.picking_id.partner_id.id,
+ 'partner_shipping_id': move.picking_id.partner_id.id,
+ 'fiscal_category_id': rule.fiscal_category_id.id,
+ 'company_id': rule.company_id.id,
+ 'context': ctx
+ }
+
+ partner = move.picking_id.partner_id
+ obj_fp_rule = self.env['account.fiscal.position.rule']
+ product_fc_id = obj_fp_rule.with_context(
+ ctx).product_fiscal_category_map(
+ kwargs.get('product_id'),
+ kwargs.get('fiscal_category_id'),
+ partner.state_id.id)
+
+ if product_fc_id:
+ kwargs['fiscal_category_id'] = product_fc_id
+ result['fiscal_category_id'] = product_fc_id
+ else:
+ result['fiscal_category_id'] = kwargs.get(
+ 'fiscal_category_id')
+
+ result_fr = obj_fp_rule.with_context(ctx).apply_fiscal_mapping(
+ {'value': {}}, **kwargs)
+
+ result.update({
+ 'fiscal_position': result_fr['value']['fiscal_position']})
+ return result
diff --git a/l10n_br_stock_account/views/stock_view.xml b/l10n_br_stock_account/views/stock_view.xml
new file mode 100644
index 000000000000..c33a51497ae7
--- /dev/null
+++ b/l10n_br_stock_account/views/stock_view.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ l10n_br_stock_account.stock.location.path.form
+ stock.location.path
+
+ 32
+
+
+
+
+
+
+
+
+
+
From f92550e8ba29c42f64c4402a97a29df8bf4aa47c Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 15 Jun 2016 21:00:55 -0300
Subject: [PATCH 029/612] [ADD] Fiscal category to procurement.rule
---
l10n_br_stock_account/models/stock.py | 18 ++++++++-
l10n_br_stock_account/views/stock_view.xml | 45 ++++++++++++++--------
2 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index c8e9791ad242..c6e1ac7c5073 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -2,6 +2,7 @@
###############################################################################
#
# Copyright (C) 2016 Renato Lima - Akretion
+# Copyright (C) 2016 Luis Felipe Miléo - KMEE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -24,7 +25,8 @@ class StockPicking(models.Model):
_inherit = 'stock.location.path'
fiscal_category_id = fields.Many2one(
- 'l10n_br_account.fiscal.category', 'Categoria Fiscal',
+ comodel_name='l10n_br_account.fiscal.category',
+ string=u'Categoria Fiscal',
domain="[('state', '=', 'approved')]")
@api.model
@@ -66,3 +68,17 @@ def _prepare_push_apply(self, rule, move):
result.update({
'fiscal_position': result_fr['value']['fiscal_position']})
return result
+
+
+class ProcurementRule(models.Model):
+ """
+ Create relation with l10n-brazil fiscal category, used to select taxes
+ on branch / inter company transfers.
+ """
+ _inherit = 'procurement.rule'
+
+ fiscal_category_id = fields.Many2one(
+ comodel_name='l10n_br_account.fiscal.category',
+ string=u'Categoria Fiscal',
+ domain="[('state', '=', 'approved')]",
+ )
diff --git a/l10n_br_stock_account/views/stock_view.xml b/l10n_br_stock_account/views/stock_view.xml
index c33a51497ae7..b9ff0eef292a 100644
--- a/l10n_br_stock_account/views/stock_view.xml
+++ b/l10n_br_stock_account/views/stock_view.xml
@@ -1,20 +1,33 @@
+
+
+ l10n_br_stock_account.stock.location.path.form
+
+ stock.location.path
+
+ 32
+
+
+
+
+
+
-
-
-
- l10n_br_stock_account.stock.location.path.form
- stock.location.path
-
- 32
-
-
-
-
-
-
-
-
-
+
+
+ l10n_br_stock_account.procurement.rule.inherit.form
+
+ procurement.rule
+
+
+
+
+
+
+
+
From aa3003e7206500167096897c0c8dad29fafd8bc6 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 16 Jun 2016 00:32:19 -0300
Subject: [PATCH 030/612] [NEW] Add fiscal_position map to procurement.rule
Conflicts: l10n_br_stock_account/models/__init__.py
---
l10n_br_stock_account/models/procurement.py | 73 +++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 l10n_br_stock_account/models/procurement.py
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
new file mode 100644
index 000000000000..d54f1a90ce59
--- /dev/null
+++ b/l10n_br_stock_account/models/procurement.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+# #
+# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU Affero General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU Affero General Public License for more details. #
+# #
+# You should have received a copy of the GNU Affero General Public License #
+# along with this program. If not, see . #
+###############################################################################
+
+from openerp import models, api
+
+
+class ProcurementOrder(models.Model):
+ _inherit = "procurement.order"
+
+ @api.model
+ def _run_move_create(self, procurement):
+ result = super(ProcurementOrder, self)._run_move_create(procurement)
+ if procurement.rule_id and procurement.rule_id.fiscal_category_id:
+ result.update({
+ 'fiscal_category_id':
+ procurement.rule_id.fiscal_category_id.id,
+ })
+
+ if not procurement.move_dest_id:
+ return result
+
+ ctx = dict(self.env.context)
+ ctx.update({'use_domain': ('use_picking', '=', True)})
+ move = procurement.move_dest_id
+ rule = procurement.rule_id
+ kwargs = {
+ 'partner_id': move.partner_id.id,
+ 'product_id': procurement.product_id.id,
+ 'partner_invoice_id': move.partner_id.id,
+ # TODO: Implement fuction to compute partner invoice id
+ 'partner_shipping_id': move.partner_id.id,
+ 'fiscal_category_id': rule.fiscal_category_id.id,
+ 'company_id': procurement.company_id.id,
+ 'context': ctx,
+ }
+
+ partner = move.picking_id.partner_id
+ obj_fp_rule = self.env['account.fiscal.position.rule']
+ product_fc_id = obj_fp_rule.with_context(
+ ctx).product_fiscal_category_map(
+ kwargs.get('product_id'),
+ kwargs.get('fiscal_category_id'),
+ partner.state_id.id)
+
+ if product_fc_id:
+ kwargs['fiscal_category_id'] = product_fc_id
+ result['fiscal_category_id'] = product_fc_id
+ else:
+ result['fiscal_category_id'] = kwargs.get(
+ 'fiscal_category_id')
+
+ result_fr = obj_fp_rule.with_context(ctx).apply_fiscal_mapping(
+ {'value': {}}, **kwargs)
+
+ result.update({
+ 'fiscal_position': result_fr['value']['fiscal_position']})
+ return result
From eda2656ca8e6d82d6aea2fb18ac8c24a28f56ee1 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sun, 19 Jun 2016 16:27:17 -0300
Subject: [PATCH 031/612] [FIX] Fix procurement rule company_id
---
l10n_br_stock_account/models/procurement.py | 32 ++++++++++-----------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index d54f1a90ce59..5e77f360066c 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -26,31 +26,29 @@ class ProcurementOrder(models.Model):
@api.model
def _run_move_create(self, procurement):
result = super(ProcurementOrder, self)._run_move_create(procurement)
- if procurement.rule_id and procurement.rule_id.fiscal_category_id:
- result.update({
- 'fiscal_category_id':
- procurement.rule_id.fiscal_category_id.id,
- })
-
- if not procurement.move_dest_id:
- return result
-
+ if (procurement.rule_id and procurement.rule_id.fiscal_category_id and
+ procurement.move_dest_id):
ctx = dict(self.env.context)
ctx.update({'use_domain': ('use_picking', '=', True)})
- move = procurement.move_dest_id
- rule = procurement.rule_id
+ partner = (
+ procurement.rule_id.partner_address_id or (
+ procurement.group_id and procurement.group_id.partner_id)
+ )
+ company = (procurement.warehouse_id.company_id or
+ procurement.company_id)
kwargs = {
- 'partner_id': move.partner_id.id,
+ 'partner_id': partner.id,
'product_id': procurement.product_id.id,
- 'partner_invoice_id': move.partner_id.id,
+ 'partner_invoice_id': partner.id,
# TODO: Implement fuction to compute partner invoice id
- 'partner_shipping_id': move.partner_id.id,
- 'fiscal_category_id': rule.fiscal_category_id.id,
- 'company_id': procurement.company_id.id,
+ 'partner_shipping_id': partner.id,
+ 'fiscal_category_id': (
+ procurement.rule_id.fiscal_category_id.id
+ ),
+ 'company_id': company.id,
'context': ctx,
}
- partner = move.picking_id.partner_id
obj_fp_rule = self.env['account.fiscal.position.rule']
product_fc_id = obj_fp_rule.with_context(
ctx).product_fiscal_category_map(
From 388fca68943192adae4844e1ac364cea3bc38a94 Mon Sep 17 00:00:00 2001
From: Developer
Date: Wed, 13 Jul 2016 02:37:01 +0000
Subject: [PATCH 032/612] Change classe name
---
l10n_br_stock_account/models/stock.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index c6e1ac7c5073..60bcc16ee648 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -21,7 +21,7 @@
from openerp import models, fields, api
-class StockPicking(models.Model):
+class StockLocationPath(models.Model):
_inherit = 'stock.location.path'
fiscal_category_id = fields.Many2one(
@@ -31,7 +31,7 @@ class StockPicking(models.Model):
@api.model
def _prepare_push_apply(self, rule, move):
- result = super(StockPicking, self)._prepare_push_apply(rule, move)
+ result = super(StockLocationPath, self)._prepare_push_apply(rule, move)
if rule.fiscal_category_id:
ctx = dict(self.env.context)
From 9a29838e03bcd84f740015260bb03c934f813506 Mon Sep 17 00:00:00 2001
From: Developer
Date: Wed, 13 Jul 2016 02:48:30 +0000
Subject: [PATCH 033/612] PEP8
---
l10n_br_stock_account/models/procurement.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 5e77f360066c..61d352a30225 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -27,7 +27,7 @@ class ProcurementOrder(models.Model):
def _run_move_create(self, procurement):
result = super(ProcurementOrder, self)._run_move_create(procurement)
if (procurement.rule_id and procurement.rule_id.fiscal_category_id and
- procurement.move_dest_id):
+ procurement.move_dest_id):
ctx = dict(self.env.context)
ctx.update({'use_domain': ('use_picking', '=', True)})
partner = (
From ef47da598a06ff9ec3477b93e11d2fdf71213516 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Mon, 15 Aug 2016 17:29:15 -0300
Subject: [PATCH 034/612] lighter new style OCA license headers
---
l10n_br_stock_account/models/procurement.py | 17 +----------------
l10n_br_stock_account/models/stock.py | 17 +----------------
2 files changed, 2 insertions(+), 32 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 61d352a30225..01f4599058f1 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -1,21 +1,6 @@
# -*- coding: utf-8 -*-
-###############################################################################
-# #
# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU Affero General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU Affero General Public License for more details. #
-# #
-# You should have received a copy of the GNU Affero General Public License #
-# along with this program. If not, see . #
-###############################################################################
+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, api
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 60bcc16ee648..9c9c693c9d30 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -1,22 +1,7 @@
# -*- coding: utf-8 -*-
-###############################################################################
-#
# Copyright (C) 2016 Renato Lima - Akretion
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-###############################################################################
+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api
From 4727f94dfd57693284bae452478ed4e5a71d3b03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Domingues?=
Date: Fri, 18 Nov 2016 14:58:54 -0200
Subject: [PATCH 035/612] fixup! [FIX] Fix procurement rule company_id
`procurement.move_dest_id` is not necessary to add
fiscal_position map to procurement.rule.
`partner` was already located by
openerp.addons.stock.procurement:procurement_order
---
l10n_br_stock_account/models/procurement.py | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 01f4599058f1..8407590b7869 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -12,13 +12,10 @@ class ProcurementOrder(models.Model):
def _run_move_create(self, procurement):
result = super(ProcurementOrder, self)._run_move_create(procurement)
if (procurement.rule_id and procurement.rule_id.fiscal_category_id and
- procurement.move_dest_id):
+ result['partner_id']):
ctx = dict(self.env.context)
ctx.update({'use_domain': ('use_picking', '=', True)})
- partner = (
- procurement.rule_id.partner_address_id or (
- procurement.group_id and procurement.group_id.partner_id)
- )
+ partner = self.env['res.partner'].browse(result['partner_id'])
company = (procurement.warehouse_id.company_id or
procurement.company_id)
kwargs = {
From ba107bdc5506b196035d68f4c6f72fe1f454eb44 Mon Sep 17 00:00:00 2001
From: renato
Date: Fri, 2 Dec 2016 01:33:20 -0200
Subject: [PATCH 036/612] [MIG] Make modules uninstallable
---
l10n_br_stock_account/__openerp__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
index 29957e860ea3..1e070c9ee196 100644
--- a/l10n_br_stock_account/__openerp__.py
+++ b/l10n_br_stock_account/__openerp__.py
@@ -39,6 +39,6 @@
'test/stock_internal_picking.yml',
'test/stock_return_internal_picking.yml',
],
- 'installable': True,
+ 'installable': False,
'auto_install': True,
}
From 0ca8872146026ce42e374ab44d051f868e1b1d80 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 6 Dec 2016 04:26:45 -0200
Subject: [PATCH 037/612] [MIG] Rename manifest files
---
l10n_br_stock_account/__openerp__.py | 44 ----------------------------
1 file changed, 44 deletions(-)
delete mode 100644 l10n_br_stock_account/__openerp__.py
diff --git a/l10n_br_stock_account/__openerp__.py b/l10n_br_stock_account/__openerp__.py
deleted file mode 100644
index 1e070c9ee196..000000000000
--- a/l10n_br_stock_account/__openerp__.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- encoding: utf-8 -*-
-###############################################################################
-# #
-# Copyright (C) 2014 Renato Lima - Akretion #
-# #
-#This program is free software: you can redistribute it and/or modify #
-#it under the terms of the GNU Affero General Public License as published by #
-#the Free Software Foundation, either version 3 of the License, or #
-#(at your option) any later version. #
-# #
-#This program is distributed in the hope that it will be useful, #
-#but WITHOUT ANY WARRANTY; without even the implied warranty of #
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-#GNU Affero General Public License for more details. #
-# #
-#You should have received a copy of the GNU Affero General Public License #
-#along with this program. If not, see . #
-###############################################################################
-
-{
- 'name': 'Brazilian Localization WMS Accounting',
- 'category': 'Localisation',
- 'license': 'AGPL-3',
- 'author': 'Akretion, Odoo Community Association (OCA)',
- 'website': 'http://odoo-brasil.org',
- 'version': '8.0.1.0.1',
- 'depends': [
- 'l10n_br_account_product',
- 'l10n_br_stock',
- 'account_fiscal_position_rule_stock',
- 'stock_account',
- ],
- 'data': [
- 'wizard/stock_invoice_onshipping_view.xml',
- 'security/ir.model.access.csv',
- ],
- 'demo': [],
- 'test': [
- 'test/stock_internal_picking.yml',
- 'test/stock_return_internal_picking.yml',
- ],
- 'installable': False,
- 'auto_install': True,
-}
From 4abcf16e2ea1aeab575e522bfff6df43a164b06b Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 Aug 2018 09:37:14 -0300
Subject: [PATCH 038/612] [MIG] odoo imports
---
l10n_br_stock_account/models/procurement.py | 2 +-
l10n_br_stock_account/models/stock.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 8407590b7869..7fa9625382c5 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -2,7 +2,7 @@
# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from openerp import models, api
+from odoo import models, api
class ProcurementOrder(models.Model):
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 9c9c693c9d30..d76b41f5a0f3 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -3,7 +3,7 @@
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from openerp import models, fields, api
+from odoo import models, fields, api
class StockLocationPath(models.Model):
From b8a219388156a9fe2011d25e5fd88523a5b3d14d Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 14 Aug 2019 16:17:30 -0300
Subject: [PATCH 039/612] [10.0][MIG] Code.
---
l10n_br_stock_account/models/procurement.py | 12 ++++---
l10n_br_stock_account/models/stock.py | 36 ++++++++++-----------
2 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 7fa9625382c5..0b30b3e5f653 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -6,7 +6,11 @@
class ProcurementOrder(models.Model):
- _inherit = "procurement.order"
+ _name = "procurement.order"
+ _inherit = [
+ _name,
+ "stock.invoice.state.mixin",
+ ]
@api.model
def _run_move_create(self, procurement):
@@ -25,7 +29,7 @@ def _run_move_create(self, procurement):
# TODO: Implement fuction to compute partner invoice id
'partner_shipping_id': partner.id,
'fiscal_category_id': (
- procurement.rule_id.fiscal_category_id.id
+ procurement.rule_id.fiscal_category_id
),
'company_id': company.id,
'context': ctx,
@@ -45,8 +49,8 @@ def _run_move_create(self, procurement):
result['fiscal_category_id'] = kwargs.get(
'fiscal_category_id')
- result_fr = obj_fp_rule.with_context(ctx).apply_fiscal_mapping(
- {'value': {}}, **kwargs)
+ result_fr = obj_fp_rule.with_context(
+ ctx).apply_fiscal_mapping(**kwargs)
result.update({
'fiscal_position': result_fr['value']['fiscal_position']})
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index d76b41f5a0f3..0b827991a788 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -14,31 +14,31 @@ class StockLocationPath(models.Model):
string=u'Categoria Fiscal',
domain="[('state', '=', 'approved')]")
- @api.model
- def _prepare_push_apply(self, rule, move):
- result = super(StockLocationPath, self)._prepare_push_apply(rule, move)
- if rule.fiscal_category_id:
-
+ def _prepare_move_copy_values(self, move_to_copy, new_date):
+ result = super(
+ StockLocationPath, self)._prepare_push_apply(
+ move_to_copy, new_date)
+ if self.fiscal_category_id:
ctx = dict(self.env.context)
ctx.update({'use_domain': ('use_picking', '=', True)})
kwargs = {
- 'partner_id': move.picking_id.partner_id.id,
- 'product_id': move.product_id.id,
- 'partner_invoice_id': move.picking_id.partner_id.id,
- 'partner_shipping_id': move.picking_id.partner_id.id,
- 'fiscal_category_id': rule.fiscal_category_id.id,
- 'company_id': rule.company_id.id,
+ 'partner_id': move_to_copy.picking_id.partner_id,
+ 'product_id': move_to_copy.product_id,
+ 'partner_invoice_id': move_to_copy.picking_id.partner_id,
+ 'partner_shipping_id': move_to_copy.picking_id.partner_id,
+ 'fiscal_category_id': self.fiscal_category_id.id,
+ 'company_id': self.company_id.id,
'context': ctx
}
- partner = move.picking_id.partner_id
+ partner = move_to_copy.picking_id.partner_id
obj_fp_rule = self.env['account.fiscal.position.rule']
product_fc_id = obj_fp_rule.with_context(
ctx).product_fiscal_category_map(
- kwargs.get('product_id'),
- kwargs.get('fiscal_category_id'),
- partner.state_id.id)
+ kwargs.get('product_id'),
+ kwargs.get('fiscal_category_id'),
+ partner.state_id.id)
if product_fc_id:
kwargs['fiscal_category_id'] = product_fc_id
@@ -47,11 +47,11 @@ def _prepare_push_apply(self, rule, move):
result['fiscal_category_id'] = kwargs.get(
'fiscal_category_id')
- result_fr = obj_fp_rule.with_context(ctx).apply_fiscal_mapping(
- {'value': {}}, **kwargs)
+ fiscal_position = obj_fp_rule.with_context(
+ ctx).apply_fiscal_mapping(**kwargs)
result.update({
- 'fiscal_position': result_fr['value']['fiscal_position']})
+ 'fiscal_position_id': fiscal_position.id})
return result
From 1a0aeb511b2836fbd685896cc75bcd37804d4fa6 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 14 Aug 2019 16:27:55 -0300
Subject: [PATCH 040/612] [10.0][MIG] Replace Yaml for Python tests.
---
.../test/stock_internal_picking.yml | 51 -------------------
.../test/stock_return_internal_picking.yml | 24 ---------
2 files changed, 75 deletions(-)
delete mode 100644 l10n_br_stock_account/test/stock_internal_picking.yml
delete mode 100644 l10n_br_stock_account/test/stock_return_internal_picking.yml
diff --git a/l10n_br_stock_account/test/stock_internal_picking.yml b/l10n_br_stock_account/test/stock_internal_picking.yml
deleted file mode 100644
index 33f081b25f53..000000000000
--- a/l10n_br_stock_account/test/stock_internal_picking.yml
+++ /dev/null
@@ -1,51 +0,0 @@
--
- I prepare tunneling extra args in the context
--
- !python {model: stock.move}: |
- context.update({'parent_fiscal_category_id': ref('l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a'), 'invoice_state': '2binvoiced'})
--
- Create a picking to be invoice from SP to SP fiscal contributor
--
- !record {model: stock.picking, id: stock_picking_sp, view: l10n_br_view_picking_form1}:
- partner_id: l10n_br_base.res_partner_cliente1_sp
- invoice_state: 2binvoiced
- picking_type_id: stock.picking_type_internal
- fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
- fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
- name: Outgoing picking
- move_lines:
- - product_id: product.product_product_10
- product_uom_qty: 5.00
- location_id: stock.stock_location_stock
- location_dest_id: stock.stock_location_customers
- invoice_state: 2binvoiced
- fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
- fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
- - product_id: product.product_product_18
- product_uom_qty: 10.00
- location_id: stock.stock_location_stock
- location_dest_id: stock.stock_location_customers
- invoice_state: 2binvoiced
- fiscal_category_id: l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a
- fiscal_position: l10n_br_account_product.fp_86d8c770fc2fb9d9fa242a3bdddd507a_internal_demo
--
- Assign and confirm
--
- !python {model: stock.picking}: |
- self.action_confirm(cr, uid, [ref('stock_picking_sp')], context=context)
- self.action_assign(cr, uid, [ref('stock_picking_sp')])
- self.do_prepare_partial(cr, uid, [ref('stock_picking_sp')])
- self.do_transfer(cr, uid, [ref('stock_picking_sp')], context=context)
--
- I create a invoice
--
- !python {model: stock.invoice.onshipping}: |
- context.update({"active_model": 'stock.picking', "active_ids": [ref("stock_picking_sp")]})
- wizard_id = self.create(cr, uid, {'fiscal_category_journal': True}, context=context)
- invoice_id = self.create_invoice(cr, uid, [wizard_id], context=context)
- assert invoice_id, "Invoice refund not created!"
- invoices = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
- for invoice in invoices:
- assert invoice.fiscal_category_id.id == ref('l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a'), "Wrong refund fiscal category!"
- for line in invoice.invoice_line:
- assert line.cfop_id.code == '5949', "Wrong CFOP Code"
diff --git a/l10n_br_stock_account/test/stock_return_internal_picking.yml b/l10n_br_stock_account/test/stock_return_internal_picking.yml
deleted file mode 100644
index 10e05585773e..000000000000
--- a/l10n_br_stock_account/test/stock_return_internal_picking.yml
+++ /dev/null
@@ -1,24 +0,0 @@
--
- I create a reverse picking
--
- !python {model: stock.return.picking}: |
- ctx = context.copy()
- ctx.update({"active_model": 'stock.picking', "active_id": [ref("stock_picking_sp")]})
- wizard_id = self.create(cr, uid, {'invoice_state': '2binvoiced'}, context=ctx)
- wizard = self.browse(cr, uid, wizard_id, context=ctx)
- for line in wizard.product_return_moves:
- self.pool.get('stock.return.picking.line').write(cr, uid, line.id, {'quantity': line.move_id.product_uom_qty})
- result = self.create_returns(cr, uid, [wizard_id], context=ctx)
- from openerp.tools.safe_eval import safe_eval
- if result['domain']:
- domain = safe_eval(result['domain'])
- picking_return_id = self.pool.get('stock.picking').search(cr, uid, domain)
- assert picking_return_id, "Can't create return picking"
- ctx.update({"active_model": 'stock.picking', "active_ids": picking_return_id})
- wizard_id = self.pool.get('stock.invoice.onshipping').create(cr, uid, {'fiscal_category_journal': True}, context=ctx)
- invoice_id = self.pool.get('stock.invoice.onshipping').create_invoice(cr, uid, [wizard_id], context=ctx)
- assert invoice_id, "Invoice refund not created!"
- invoices = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
- for invoice in invoices:
- for line in invoice.invoice_line:
- assert line.cfop_id.code == '1949', "Wrong CFOP Code"
From e11e2f6325981da71a09ff6b7a65bf276f34a368 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 14 Aug 2019 16:57:51 -0300
Subject: [PATCH 041/612] [10.0][MIG] PEP8.
---
l10n_br_stock_account/models/stock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 0b827991a788..64d803ca30d9 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -3,7 +3,7 @@
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from odoo import models, fields, api
+from odoo import models, fields
class StockLocationPath(models.Model):
From c084da4e2b0ecbc67e2192c557e4209a57da3637 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 4 Sep 2019 12:47:54 -0300
Subject: [PATCH 042/612] [10.0][MIG][FIX] Name of super method.
---
l10n_br_stock_account/models/stock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 64d803ca30d9..5df6e7eb1281 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -16,7 +16,7 @@ class StockLocationPath(models.Model):
def _prepare_move_copy_values(self, move_to_copy, new_date):
result = super(
- StockLocationPath, self)._prepare_push_apply(
+ StockLocationPath, self)._prepare_move_copy_values(
move_to_copy, new_date)
if self.fiscal_category_id:
ctx = dict(self.env.context)
From 51fe3c459c37171f342f2db6f0c791a999c9f5e4 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 6 Sep 2019 16:02:10 -0300
Subject: [PATCH 043/612] [10.0][MIG] Code.
---
l10n_br_stock_account/models/procurement.py | 33 +++++++++++----------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 0b30b3e5f653..025025e82646 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -13,25 +13,25 @@ class ProcurementOrder(models.Model):
]
@api.model
- def _run_move_create(self, procurement):
- result = super(ProcurementOrder, self)._run_move_create(procurement)
- if (procurement.rule_id and procurement.rule_id.fiscal_category_id and
+ def _get_stock_move_values(self):
+ result = super(ProcurementOrder, self)._get_stock_move_values()
+ if (self.rule_id and self.rule_id.fiscal_category_id and
result['partner_id']):
ctx = dict(self.env.context)
ctx.update({'use_domain': ('use_picking', '=', True)})
partner = self.env['res.partner'].browse(result['partner_id'])
- company = (procurement.warehouse_id.company_id or
- procurement.company_id)
+ company = (self.warehouse_id.company_id or
+ self.company_id)
kwargs = {
- 'partner_id': partner.id,
- 'product_id': procurement.product_id.id,
- 'partner_invoice_id': partner.id,
+ 'partner_id': partner,
+ 'product_id': self.product_id,
+ 'partner_invoice_id': partner,
# TODO: Implement fuction to compute partner invoice id
- 'partner_shipping_id': partner.id,
+ 'partner_shipping_id': partner,
'fiscal_category_id': (
- procurement.rule_id.fiscal_category_id
+ self.rule_id.fiscal_category_id
),
- 'company_id': company.id,
+ 'company_id': company,
'context': ctx,
}
@@ -44,14 +44,15 @@ def _run_move_create(self, procurement):
if product_fc_id:
kwargs['fiscal_category_id'] = product_fc_id
- result['fiscal_category_id'] = product_fc_id
+ result['fiscal_category_id'] = product_fc_id.id
else:
result['fiscal_category_id'] = kwargs.get(
- 'fiscal_category_id')
+ 'fiscal_category_id').id
- result_fr = obj_fp_rule.with_context(
+ fiscal_position = obj_fp_rule.with_context(
ctx).apply_fiscal_mapping(**kwargs)
- result.update({
- 'fiscal_position': result_fr['value']['fiscal_position']})
+ if fiscal_position:
+ result.update({'fiscal_position_id': fiscal_position.id})
+
return result
From 33681e8f85acb3deb44982e2e5f2340cd1c71e41 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 6 Sep 2019 16:03:25 -0300
Subject: [PATCH 044/612] [10.0][MIG][IMP] Tests.
---
.../tests/test_procurement_order.py | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 l10n_br_stock_account/tests/test_procurement_order.py
diff --git a/l10n_br_stock_account/tests/test_procurement_order.py b/l10n_br_stock_account/tests/test_procurement_order.py
new file mode 100644
index 000000000000..942a51c3ef84
--- /dev/null
+++ b/l10n_br_stock_account/tests/test_procurement_order.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+# @ 2019 Akretion - www.akretion.com.br -
+# Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.tests.common import TransactionCase
+
+
+class ProcurementOrderTest(TransactionCase):
+ """Test invoicing picking"""
+
+ def setUp(self):
+ super(ProcurementOrderTest, self).setUp()
+ self.product_1 = self.env.ref('stock.product_icecream')
+ self.uom_unit = self.env.ref('product.product_uom_unit')
+ # Warehouses
+ self.warehouse_1 = self.env['stock.warehouse'].create({
+ 'name': 'Base Warehouse',
+ 'reception_steps': 'one_step',
+ 'delivery_steps': 'ship_only',
+ 'code': 'BWH'})
+ # Locations
+ self.location_1 = self.env['stock.location'].create({
+ 'name': 'TestLocation1',
+ 'posx': 3,
+ 'location_id': self.warehouse_1.lot_stock_id.id,
+ })
+ self.warehouse_2 = self.env['stock.warehouse'].create({
+ 'name': 'Small Warehouse',
+ 'code': 'SWH',
+ 'default_resupply_wh_id': self.warehouse_1.id,
+ 'resupply_wh_ids': [(6, 0, [self.warehouse_1.id])]
+ })
+
+ # minimum stock rule for test product on this warehouse
+ self.env['stock.warehouse.orderpoint'].create({
+ 'warehouse_id': self.warehouse_2.id,
+ 'location_id': self.warehouse_2.lot_stock_id.id,
+ 'product_id': self.product_1.id,
+ 'product_min_qty': 10,
+ 'product_max_qty': 100,
+ 'product_uom': self.uom_unit.id,
+ })
+
+ def test_procument_order(self):
+ """Test Procurement Order"""
+
+ # Inform Partner and Fiscal Category in Procurement Rule just
+ # for test
+ self.procurement_rule = self.env['procurement.rule'].search([(
+ 'name', '=', 'SWH: YourCompany: Transit Location -> Stock'
+ )])
+ self.procurement_rule.partner_address_id = self.env.ref(
+ 'l10n_br_base.res_partner_amd').id
+ self.procurement_rule.fiscal_category_id = self.env.ref(
+ 'l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a').id
+
+ OrderScheduler = self.env['procurement.order']
+ OrderScheduler.run_scheduler()
+ # we generated 2 procurements for product A:
+ # one on small wh and the other one on the transit location
+ procs = OrderScheduler.search([('product_id', '=', self.product_1.id)])
+ self.assertEqual(len(procs), 2)
+
+ proc1 = procs.filtered(
+ lambda order: order.warehouse_id == self.warehouse_2)
+ self.assertEqual(proc1.state, 'running')
+
+ proc2 = procs.filtered(
+ lambda order: order.warehouse_id == self.warehouse_1)
+ self.assertEqual(proc2.location_id.usage, 'transit')
+ self.assertNotEqual(proc2.state, 'exception')
+
+ proc2.run()
+ self.assertEqual(proc2.state, 'running')
+ self.assertTrue(proc2.rule_id)
From 6bb07211174ab09ee2223cf32afae2b168b7b36c Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 15 Apr 2020 13:08:08 -0300
Subject: [PATCH 045/612] [12.0][MIG][WIP] Models does not exist in registry.
---
l10n_br_stock_account/models/procurement.py | 108 ++++++++---------
l10n_br_stock_account/models/stock.py | 123 ++++++++++----------
2 files changed, 116 insertions(+), 115 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index 025025e82646..cfa76833f510 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -2,57 +2,57 @@
# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from odoo import models, api
-
-
-class ProcurementOrder(models.Model):
- _name = "procurement.order"
- _inherit = [
- _name,
- "stock.invoice.state.mixin",
- ]
-
- @api.model
- def _get_stock_move_values(self):
- result = super(ProcurementOrder, self)._get_stock_move_values()
- if (self.rule_id and self.rule_id.fiscal_category_id and
- result['partner_id']):
- ctx = dict(self.env.context)
- ctx.update({'use_domain': ('use_picking', '=', True)})
- partner = self.env['res.partner'].browse(result['partner_id'])
- company = (self.warehouse_id.company_id or
- self.company_id)
- kwargs = {
- 'partner_id': partner,
- 'product_id': self.product_id,
- 'partner_invoice_id': partner,
- # TODO: Implement fuction to compute partner invoice id
- 'partner_shipping_id': partner,
- 'fiscal_category_id': (
- self.rule_id.fiscal_category_id
- ),
- 'company_id': company,
- 'context': ctx,
- }
-
- obj_fp_rule = self.env['account.fiscal.position.rule']
- product_fc_id = obj_fp_rule.with_context(
- ctx).product_fiscal_category_map(
- kwargs.get('product_id'),
- kwargs.get('fiscal_category_id'),
- partner.state_id.id)
-
- if product_fc_id:
- kwargs['fiscal_category_id'] = product_fc_id
- result['fiscal_category_id'] = product_fc_id.id
- else:
- result['fiscal_category_id'] = kwargs.get(
- 'fiscal_category_id').id
-
- fiscal_position = obj_fp_rule.with_context(
- ctx).apply_fiscal_mapping(**kwargs)
-
- if fiscal_position:
- result.update({'fiscal_position_id': fiscal_position.id})
-
- return result
+# from odoo import models, api
+
+# TODO - Model 'procurement.order' does not exist in registry.
+# class ProcurementOrder(models.Model):
+# _name = "procurement.order"
+# _inherit = [
+# _name,
+# "stock.invoice.state.mixin",
+# ]
+#
+# @api.model
+# def _get_stock_move_values(self):
+# result = super(ProcurementOrder, self)._get_stock_move_values()
+# if (self.rule_id and self.rule_id.fiscal_category_id and
+# result['partner_id']):
+# ctx = dict(self.env.context)
+# ctx.update({'use_domain': ('use_picking', '=', True)})
+# partner = self.env['res.partner'].browse(result['partner_id'])
+# company = (self.warehouse_id.company_id or
+# self.company_id)
+# kwargs = {
+# 'partner_id': partner,
+# 'product_id': self.product_id,
+# 'partner_invoice_id': partner,
+# # TODO: Implement fuction to compute partner invoice id
+# 'partner_shipping_id': partner,
+# 'fiscal_category_id': (
+# self.rule_id.fiscal_category_id
+# ),
+# 'company_id': company,
+# 'context': ctx,
+# }
+#
+# obj_fp_rule = self.env['account.fiscal.position.rule']
+# product_fc_id = obj_fp_rule.with_context(
+# ctx).product_fiscal_category_map(
+# kwargs.get('product_id'),
+# kwargs.get('fiscal_category_id'),
+# partner.state_id.id)
+#
+# if product_fc_id:
+# kwargs['fiscal_category_id'] = product_fc_id
+# result['fiscal_category_id'] = product_fc_id.id
+# else:
+# result['fiscal_category_id'] = kwargs.get(
+# 'fiscal_category_id').id
+#
+# fiscal_position = obj_fp_rule.with_context(
+# ctx).apply_fiscal_mapping(**kwargs)
+#
+# if fiscal_position:
+# result.update({'fiscal_position_id': fiscal_position.id})
+#
+# return result
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 5df6e7eb1281..ba5d7e42b852 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -3,67 +3,68 @@
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from odoo import models, fields
+# from odoo import models, fields
+# TODO - Model does not exist in registry.
+# class StockLocationPath(models.Model):
+# _inherit = 'stock.location.path'
+#
+# fiscal_category_id = fields.Many2one(
+# comodel_name='l10n_br_account.fiscal.category',
+# string=u'Categoria Fiscal',
+# domain="[('state', '=', 'approved')]")
+#
+# def _prepare_move_copy_values(self, move_to_copy, new_date):
+# result = super(
+# StockLocationPath, self)._prepare_move_copy_values(
+# move_to_copy, new_date)
+# if self.fiscal_category_id:
+# ctx = dict(self.env.context)
+# ctx.update({'use_domain': ('use_picking', '=', True)})
+#
+# kwargs = {
+# 'partner_id': move_to_copy.picking_id.partner_id,
+# 'product_id': move_to_copy.product_id,
+# 'partner_invoice_id': move_to_copy.picking_id.partner_id,
+# 'partner_shipping_id': move_to_copy.picking_id.partner_id,
+# 'fiscal_category_id': self.fiscal_category_id.id,
+# 'company_id': self.company_id.id,
+# 'context': ctx
+# }
+#
+# partner = move_to_copy.picking_id.partner_id
+# obj_fp_rule = self.env['account.fiscal.position.rule']
+# product_fc_id = obj_fp_rule.with_context(
+# ctx).product_fiscal_category_map(
+# kwargs.get('product_id'),
+# kwargs.get('fiscal_category_id'),
+# partner.state_id.id)
+#
+# if product_fc_id:
+# kwargs['fiscal_category_id'] = product_fc_id
+# result['fiscal_category_id'] = product_fc_id
+# else:
+# result['fiscal_category_id'] = kwargs.get(
+# 'fiscal_category_id')
+#
+# fiscal_position = obj_fp_rule.with_context(
+# ctx).apply_fiscal_mapping(**kwargs)
+#
+# result.update({
+# 'fiscal_position_id': fiscal_position.id})
+# return result
-class StockLocationPath(models.Model):
- _inherit = 'stock.location.path'
- fiscal_category_id = fields.Many2one(
- comodel_name='l10n_br_account.fiscal.category',
- string=u'Categoria Fiscal',
- domain="[('state', '=', 'approved')]")
-
- def _prepare_move_copy_values(self, move_to_copy, new_date):
- result = super(
- StockLocationPath, self)._prepare_move_copy_values(
- move_to_copy, new_date)
- if self.fiscal_category_id:
- ctx = dict(self.env.context)
- ctx.update({'use_domain': ('use_picking', '=', True)})
-
- kwargs = {
- 'partner_id': move_to_copy.picking_id.partner_id,
- 'product_id': move_to_copy.product_id,
- 'partner_invoice_id': move_to_copy.picking_id.partner_id,
- 'partner_shipping_id': move_to_copy.picking_id.partner_id,
- 'fiscal_category_id': self.fiscal_category_id.id,
- 'company_id': self.company_id.id,
- 'context': ctx
- }
-
- partner = move_to_copy.picking_id.partner_id
- obj_fp_rule = self.env['account.fiscal.position.rule']
- product_fc_id = obj_fp_rule.with_context(
- ctx).product_fiscal_category_map(
- kwargs.get('product_id'),
- kwargs.get('fiscal_category_id'),
- partner.state_id.id)
-
- if product_fc_id:
- kwargs['fiscal_category_id'] = product_fc_id
- result['fiscal_category_id'] = product_fc_id
- else:
- result['fiscal_category_id'] = kwargs.get(
- 'fiscal_category_id')
-
- fiscal_position = obj_fp_rule.with_context(
- ctx).apply_fiscal_mapping(**kwargs)
-
- result.update({
- 'fiscal_position_id': fiscal_position.id})
- return result
-
-
-class ProcurementRule(models.Model):
- """
- Create relation with l10n-brazil fiscal category, used to select taxes
- on branch / inter company transfers.
- """
- _inherit = 'procurement.rule'
-
- fiscal_category_id = fields.Many2one(
- comodel_name='l10n_br_account.fiscal.category',
- string=u'Categoria Fiscal',
- domain="[('state', '=', 'approved')]",
- )
+# TODO - Model does not exist in registry.
+# class ProcurementRule(models.Model):
+# """
+# Create relation with l10n-brazil fiscal category, used to select taxes
+# on branch / inter company transfers.
+# """
+# _inherit = 'procurement.rule'
+#
+# fiscal_category_id = fields.Many2one(
+# comodel_name='l10n_br_account.fiscal.category',
+# string=u'Categoria Fiscal',
+# domain="[('state', '=', 'approved')]",
+# )
From 4079e9415f394fb0b0170d6b3305ed074ad5dfd9 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 24 Apr 2020 18:18:14 -0300
Subject: [PATCH 046/612] [12.0][MIG][FIX] PEP8.
---
l10n_br_stock_account/models/procurement.py | 1 -
l10n_br_stock_account/models/stock.py | 1 -
l10n_br_stock_account/tests/test_procurement_order.py | 1 -
3 files changed, 3 deletions(-)
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
index cfa76833f510..4f6a45db3e7e 100644
--- a/l10n_br_stock_account/models/procurement.py
+++ b/l10n_br_stock_account/models/procurement.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index ba5d7e42b852..8b38677fb22b 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 Renato Lima - Akretion
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
diff --git a/l10n_br_stock_account/tests/test_procurement_order.py b/l10n_br_stock_account/tests/test_procurement_order.py
index 942a51c3ef84..0d11058fcfe2 100644
--- a/l10n_br_stock_account/tests/test_procurement_order.py
+++ b/l10n_br_stock_account/tests/test_procurement_order.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# @ 2019 Akretion - www.akretion.com.br -
# Magno Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
From e4988ac4f330fbabedea867f3e48d06aea65609d Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 27 Apr 2020 17:59:15 -0300
Subject: [PATCH 047/612] [12.0][MIG][REF] The objects stock.location.path,
procurement.rule and procurement.order were merged in stock.rule .
---
l10n_br_stock_account/models/stock.py | 132 +++++++++--------
.../tests/test_procurement_order.py | 135 ++++++++++--------
2 files changed, 148 insertions(+), 119 deletions(-)
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
index 8b38677fb22b..96a54683b870 100644
--- a/l10n_br_stock_account/models/stock.py
+++ b/l10n_br_stock_account/models/stock.py
@@ -1,69 +1,77 @@
+# Copyright (C) 2020 Magno Costa - Akretion
# Copyright (C) 2016 Renato Lima - Akretion
# Copyright (C) 2016 Luis Felipe Miléo - KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-# from odoo import models, fields
+from dateutil.relativedelta import relativedelta
-# TODO - Model does not exist in registry.
-# class StockLocationPath(models.Model):
-# _inherit = 'stock.location.path'
-#
-# fiscal_category_id = fields.Many2one(
-# comodel_name='l10n_br_account.fiscal.category',
-# string=u'Categoria Fiscal',
-# domain="[('state', '=', 'approved')]")
-#
-# def _prepare_move_copy_values(self, move_to_copy, new_date):
-# result = super(
-# StockLocationPath, self)._prepare_move_copy_values(
-# move_to_copy, new_date)
-# if self.fiscal_category_id:
-# ctx = dict(self.env.context)
-# ctx.update({'use_domain': ('use_picking', '=', True)})
-#
-# kwargs = {
-# 'partner_id': move_to_copy.picking_id.partner_id,
-# 'product_id': move_to_copy.product_id,
-# 'partner_invoice_id': move_to_copy.picking_id.partner_id,
-# 'partner_shipping_id': move_to_copy.picking_id.partner_id,
-# 'fiscal_category_id': self.fiscal_category_id.id,
-# 'company_id': self.company_id.id,
-# 'context': ctx
-# }
-#
-# partner = move_to_copy.picking_id.partner_id
-# obj_fp_rule = self.env['account.fiscal.position.rule']
-# product_fc_id = obj_fp_rule.with_context(
-# ctx).product_fiscal_category_map(
-# kwargs.get('product_id'),
-# kwargs.get('fiscal_category_id'),
-# partner.state_id.id)
-#
-# if product_fc_id:
-# kwargs['fiscal_category_id'] = product_fc_id
-# result['fiscal_category_id'] = product_fc_id
-# else:
-# result['fiscal_category_id'] = kwargs.get(
-# 'fiscal_category_id')
-#
-# fiscal_position = obj_fp_rule.with_context(
-# ctx).apply_fiscal_mapping(**kwargs)
-#
-# result.update({
-# 'fiscal_position_id': fiscal_position.id})
-# return result
+from odoo import models, api, fields
-# TODO - Model does not exist in registry.
-# class ProcurementRule(models.Model):
-# """
-# Create relation with l10n-brazil fiscal category, used to select taxes
-# on branch / inter company transfers.
-# """
-# _inherit = 'procurement.rule'
-#
-# fiscal_category_id = fields.Many2one(
-# comodel_name='l10n_br_account.fiscal.category',
-# string=u'Categoria Fiscal',
-# domain="[('state', '=', 'approved')]",
-# )
+class StockRule(models.Model):
+ _name = "stock.rule"
+ _inherit = [
+ _name,
+ "stock.invoice.state.mixin",
+ "l10n_br_fiscal.document.line.mixin"
+ ]
+
+ # TODO - The method don't work because in _get_stock_move_values
+ # at "if field in values:" the parameter values don't has the fields
+ def _get_custom_move_fields(self):
+ fields = super(StockRule, self)._get_custom_move_fields()
+ fields += ['invoice_state', 'operation_id', 'operation_line_id']
+ return fields
+
+ def _get_stock_move_values(
+ self, product_id, product_qty, product_uom, location_id, name, origin,
+ values, group_id):
+ """
+ Returns a dictionary of values that will be used to create a stock
+ move from a procurement. This function assumes that the given procurement
+ has a rule (action == 'pull' or 'pull_push') set on it.
+
+ :param procurement: browse record
+ :rtype: dictionary
+ """
+ date_expected = fields.Datetime.to_string(
+ fields.Datetime.from_string(
+ values['date_planned']) - relativedelta(days=self.delay or 0)
+ )
+ # it is possible that we've already got some move done, so check for the
+ # done qty and create
+ # a new move with the correct qty
+ qty_left = product_qty
+ move_values = {
+ 'name': name[:2000],
+ 'company_id': self.company_id.id or self.location_src_id.company_id.id or self.location_id.company_id.id or values['company_id'].id,
+ 'product_id': product_id.id,
+ 'product_uom': product_uom.id,
+ 'product_uom_qty': qty_left,
+ 'partner_id': self.partner_address_id.id or (values.get('group_id', False) and values['group_id'].partner_id.id) or False,
+ 'location_id': self.location_src_id.id,
+ 'location_dest_id': location_id.id,
+ 'move_dest_ids': values.get('move_dest_ids', False) and [(4, x.id) for x in values['move_dest_ids']] or [],
+ 'rule_id': self.id,
+ 'procure_method': self.procure_method,
+ 'origin': origin,
+ 'picking_type_id': self.picking_type_id.id,
+ 'group_id': group_id,
+ 'route_ids': [(4, route.id) for route in values.get('route_ids', [])],
+ 'warehouse_id': self.propagate_warehouse_id.id or self.warehouse_id.id,
+ 'date': date_expected,
+ 'date_expected': date_expected,
+ 'propagate': self.propagate,
+ 'priority': values.get('priority', "1"),
+ # TODO - Fields below should be in the method
+ # _get_custom_move_fields
+ 'invoice_state': self.invoice_state,
+ 'operation_id': self.operation_id.id,
+ 'operation_line_id': self.operation_line_id.id,
+ }
+ for field in self._get_custom_move_fields():
+ # TODO - The fields don't appear in parameter
+ # values, check from where come this
+ if field in values:
+ move_values[field] = values.get(field)
+ return move_values
diff --git a/l10n_br_stock_account/tests/test_procurement_order.py b/l10n_br_stock_account/tests/test_procurement_order.py
index 0d11058fcfe2..5e7afcc304fe 100644
--- a/l10n_br_stock_account/tests/test_procurement_order.py
+++ b/l10n_br_stock_account/tests/test_procurement_order.py
@@ -3,73 +3,94 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
+from odoo.tools import mute_logger
-class ProcurementOrderTest(TransactionCase):
- """Test invoicing picking"""
+class StockRuleTest(TransactionCase):
+ """Test Stock Rule"""
def setUp(self):
- super(ProcurementOrderTest, self).setUp()
- self.product_1 = self.env.ref('stock.product_icecream')
- self.uom_unit = self.env.ref('product.product_uom_unit')
- # Warehouses
- self.warehouse_1 = self.env['stock.warehouse'].create({
- 'name': 'Base Warehouse',
- 'reception_steps': 'one_step',
- 'delivery_steps': 'ship_only',
- 'code': 'BWH'})
- # Locations
- self.location_1 = self.env['stock.location'].create({
- 'name': 'TestLocation1',
- 'posx': 3,
- 'location_id': self.warehouse_1.lot_stock_id.id,
- })
- self.warehouse_2 = self.env['stock.warehouse'].create({
- 'name': 'Small Warehouse',
- 'code': 'SWH',
- 'default_resupply_wh_id': self.warehouse_1.id,
- 'resupply_wh_ids': [(6, 0, [self.warehouse_1.id])]
- })
+ super(StockRuleTest, self).setUp()
- # minimum stock rule for test product on this warehouse
- self.env['stock.warehouse.orderpoint'].create({
- 'warehouse_id': self.warehouse_2.id,
- 'location_id': self.warehouse_2.lot_stock_id.id,
- 'product_id': self.product_1.id,
- 'product_min_qty': 10,
- 'product_max_qty': 100,
- 'product_uom': self.uom_unit.id,
+ # Create a product route containing a stock rule that will
+ # generate a move from Stock for every procurement created in Output
+ self.product_route = self.env['stock.location.route'].create({
+ 'name': 'Stock -> output route',
+ 'product_selectable': True,
+ 'rule_ids': [(0, 0, {
+ 'name': 'Stock -> output rule',
+ 'action': 'pull',
+ 'picking_type_id': self.ref('stock.picking_type_internal'),
+ 'location_src_id': self.ref('stock.stock_location_stock'),
+ 'location_id': self.ref('stock.stock_location_output'),
+ 'invoice_state': '2binvoiced',
+ 'operation_id': self.ref('l10n_br_fiscal.fo_venda'),
+ 'operation_line_id': self.ref('l10n_br_fiscal.fo_venda_venda'),
+ })],
})
+ # Set this route on `product.product_product_3`
+ self.env.ref('product.product_product_3').write({
+ 'route_ids': [(4, self.product_route.id)]})
+
def test_procument_order(self):
- """Test Procurement Order"""
+ """Test Stock Rule create stock.move with Fiscal fields."""
+
+ # Set this route on `product.product_product_3`
+ self.env.ref('product.product_product_3').write({
+ 'route_ids': [(4, self.product_route.id)]})
- # Inform Partner and Fiscal Category in Procurement Rule just
- # for test
- self.procurement_rule = self.env['procurement.rule'].search([(
- 'name', '=', 'SWH: YourCompany: Transit Location -> Stock'
- )])
- self.procurement_rule.partner_address_id = self.env.ref(
- 'l10n_br_base.res_partner_amd').id
- self.procurement_rule.fiscal_category_id = self.env.ref(
- 'l10n_br_account_product.fc_86d8c770fc2fb9d9fa242a3bdddd507a').id
+ # Create Delivery Order of 10 `product.product_product_3` from Output -> Customer
+ product = self.env.ref('product.product_product_3')
+ vals = {
+ 'name': 'Delivery order for procurement',
+ 'partner_id': self.ref('base.res_partner_2'),
+ 'picking_type_id': self.ref('stock.picking_type_out'),
+ 'location_id': self.ref('stock.stock_location_output'),
+ 'location_dest_id': self.ref('stock.stock_location_customers'),
+ 'move_lines': [(0, 0, {
+ 'name': '/',
+ 'product_id': product.id,
+ 'product_uom': product.uom_id.id,
+ 'product_uom_qty': 10.00,
+ 'procure_method': 'make_to_order',
+ })],
+ }
+ pick_output = self.env['stock.picking'].create(vals)
+ pick_output.move_lines.onchange_product_id()
- OrderScheduler = self.env['procurement.order']
- OrderScheduler.run_scheduler()
- # we generated 2 procurements for product A:
- # one on small wh and the other one on the transit location
- procs = OrderScheduler.search([('product_id', '=', self.product_1.id)])
- self.assertEqual(len(procs), 2)
+ # Confirm delivery order.
+ pick_output.action_confirm()
- proc1 = procs.filtered(
- lambda order: order.warehouse_id == self.warehouse_2)
- self.assertEqual(proc1.state, 'running')
+ # I run the scheduler.
+ # Note: If purchase if already installed, the method _run_buy
+ # will be called due to the purchase demo data. As we update the
+ # stock module to run this test, the method won't be an attribute
+ # of stock.procurement at this moment. For that reason we mute the
+ # logger when running the scheduler.
+ with mute_logger('odoo.addons.stock.models.procurement'):
+ self.env['procurement.group'].run_scheduler()
- proc2 = procs.filtered(
- lambda order: order.warehouse_id == self.warehouse_1)
- self.assertEqual(proc2.location_id.usage, 'transit')
- self.assertNotEqual(proc2.state, 'exception')
+ # Check that a picking was created from stock to output.
+ moves = self.env['stock.move'].search([
+ ('product_id', '=', self.ref('product.product_product_3')),
+ ('location_id', '=', self.ref('stock.stock_location_stock')),
+ ('location_dest_id', '=', self.ref('stock.stock_location_output')),
+ ('move_dest_ids', 'in', [pick_output.move_lines[0].id])
+ ])
+ self.assertEqual(
+ len(moves.ids), 1,
+ "It should have created a picking from Stock to Output with the"
+ " original picking as destination")
- proc2.run()
- self.assertEqual(proc2.state, 'running')
- self.assertTrue(proc2.rule_id)
+ # Check if the fields included in l10n_br_stock_account was copied to move
+ for move in moves:
+ self.assertEqual(
+ move.invoice_state, '2binvoiced',
+ "The stock.move created has not invoice_state field 2binvoiced")
+ self.assertEqual(
+ move.operation_id.name, 'Venda',
+ "The stock.move created has not operation_id field Venda")
+ self.assertEqual(
+ move.operation_line_id.name, 'Venda',
+ "The stock.move created has not operation_line_id field Venda")
From 8d55b60e5f4710cbe6a4e464cffa8d5858f8d482 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 27 Apr 2020 18:04:52 -0300
Subject: [PATCH 048/612] [12.0][MIG][REF] Update the name of files and delete
unused file.
---
l10n_br_stock_account/models/procurement.py | 57 -----------
l10n_br_stock_account/models/stock.py | 77 ---------------
.../tests/test_procurement_order.py | 96 -------------------
l10n_br_stock_account/views/stock_view.xml | 33 -------
4 files changed, 263 deletions(-)
delete mode 100644 l10n_br_stock_account/models/procurement.py
delete mode 100644 l10n_br_stock_account/models/stock.py
delete mode 100644 l10n_br_stock_account/tests/test_procurement_order.py
delete mode 100644 l10n_br_stock_account/views/stock_view.xml
diff --git a/l10n_br_stock_account/models/procurement.py b/l10n_br_stock_account/models/procurement.py
deleted file mode 100644
index 4f6a45db3e7e..000000000000
--- a/l10n_br_stock_account/models/procurement.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (C) 2016 Luis Felipe Mileo - KMEE #
-# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-
-# from odoo import models, api
-
-# TODO - Model 'procurement.order' does not exist in registry.
-# class ProcurementOrder(models.Model):
-# _name = "procurement.order"
-# _inherit = [
-# _name,
-# "stock.invoice.state.mixin",
-# ]
-#
-# @api.model
-# def _get_stock_move_values(self):
-# result = super(ProcurementOrder, self)._get_stock_move_values()
-# if (self.rule_id and self.rule_id.fiscal_category_id and
-# result['partner_id']):
-# ctx = dict(self.env.context)
-# ctx.update({'use_domain': ('use_picking', '=', True)})
-# partner = self.env['res.partner'].browse(result['partner_id'])
-# company = (self.warehouse_id.company_id or
-# self.company_id)
-# kwargs = {
-# 'partner_id': partner,
-# 'product_id': self.product_id,
-# 'partner_invoice_id': partner,
-# # TODO: Implement fuction to compute partner invoice id
-# 'partner_shipping_id': partner,
-# 'fiscal_category_id': (
-# self.rule_id.fiscal_category_id
-# ),
-# 'company_id': company,
-# 'context': ctx,
-# }
-#
-# obj_fp_rule = self.env['account.fiscal.position.rule']
-# product_fc_id = obj_fp_rule.with_context(
-# ctx).product_fiscal_category_map(
-# kwargs.get('product_id'),
-# kwargs.get('fiscal_category_id'),
-# partner.state_id.id)
-#
-# if product_fc_id:
-# kwargs['fiscal_category_id'] = product_fc_id
-# result['fiscal_category_id'] = product_fc_id.id
-# else:
-# result['fiscal_category_id'] = kwargs.get(
-# 'fiscal_category_id').id
-#
-# fiscal_position = obj_fp_rule.with_context(
-# ctx).apply_fiscal_mapping(**kwargs)
-#
-# if fiscal_position:
-# result.update({'fiscal_position_id': fiscal_position.id})
-#
-# return result
diff --git a/l10n_br_stock_account/models/stock.py b/l10n_br_stock_account/models/stock.py
deleted file mode 100644
index 96a54683b870..000000000000
--- a/l10n_br_stock_account/models/stock.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright (C) 2020 Magno Costa - Akretion
-# Copyright (C) 2016 Renato Lima - Akretion
-# Copyright (C) 2016 Luis Felipe Miléo - KMEE
-# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-
-from dateutil.relativedelta import relativedelta
-
-from odoo import models, api, fields
-
-
-class StockRule(models.Model):
- _name = "stock.rule"
- _inherit = [
- _name,
- "stock.invoice.state.mixin",
- "l10n_br_fiscal.document.line.mixin"
- ]
-
- # TODO - The method don't work because in _get_stock_move_values
- # at "if field in values:" the parameter values don't has the fields
- def _get_custom_move_fields(self):
- fields = super(StockRule, self)._get_custom_move_fields()
- fields += ['invoice_state', 'operation_id', 'operation_line_id']
- return fields
-
- def _get_stock_move_values(
- self, product_id, product_qty, product_uom, location_id, name, origin,
- values, group_id):
- """
- Returns a dictionary of values that will be used to create a stock
- move from a procurement. This function assumes that the given procurement
- has a rule (action == 'pull' or 'pull_push') set on it.
-
- :param procurement: browse record
- :rtype: dictionary
- """
- date_expected = fields.Datetime.to_string(
- fields.Datetime.from_string(
- values['date_planned']) - relativedelta(days=self.delay or 0)
- )
- # it is possible that we've already got some move done, so check for the
- # done qty and create
- # a new move with the correct qty
- qty_left = product_qty
- move_values = {
- 'name': name[:2000],
- 'company_id': self.company_id.id or self.location_src_id.company_id.id or self.location_id.company_id.id or values['company_id'].id,
- 'product_id': product_id.id,
- 'product_uom': product_uom.id,
- 'product_uom_qty': qty_left,
- 'partner_id': self.partner_address_id.id or (values.get('group_id', False) and values['group_id'].partner_id.id) or False,
- 'location_id': self.location_src_id.id,
- 'location_dest_id': location_id.id,
- 'move_dest_ids': values.get('move_dest_ids', False) and [(4, x.id) for x in values['move_dest_ids']] or [],
- 'rule_id': self.id,
- 'procure_method': self.procure_method,
- 'origin': origin,
- 'picking_type_id': self.picking_type_id.id,
- 'group_id': group_id,
- 'route_ids': [(4, route.id) for route in values.get('route_ids', [])],
- 'warehouse_id': self.propagate_warehouse_id.id or self.warehouse_id.id,
- 'date': date_expected,
- 'date_expected': date_expected,
- 'propagate': self.propagate,
- 'priority': values.get('priority', "1"),
- # TODO - Fields below should be in the method
- # _get_custom_move_fields
- 'invoice_state': self.invoice_state,
- 'operation_id': self.operation_id.id,
- 'operation_line_id': self.operation_line_id.id,
- }
- for field in self._get_custom_move_fields():
- # TODO - The fields don't appear in parameter
- # values, check from where come this
- if field in values:
- move_values[field] = values.get(field)
- return move_values
diff --git a/l10n_br_stock_account/tests/test_procurement_order.py b/l10n_br_stock_account/tests/test_procurement_order.py
deleted file mode 100644
index 5e7afcc304fe..000000000000
--- a/l10n_br_stock_account/tests/test_procurement_order.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# @ 2019 Akretion - www.akretion.com.br -
-# Magno Costa
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo.tests.common import TransactionCase
-from odoo.tools import mute_logger
-
-
-class StockRuleTest(TransactionCase):
- """Test Stock Rule"""
-
- def setUp(self):
- super(StockRuleTest, self).setUp()
-
- # Create a product route containing a stock rule that will
- # generate a move from Stock for every procurement created in Output
- self.product_route = self.env['stock.location.route'].create({
- 'name': 'Stock -> output route',
- 'product_selectable': True,
- 'rule_ids': [(0, 0, {
- 'name': 'Stock -> output rule',
- 'action': 'pull',
- 'picking_type_id': self.ref('stock.picking_type_internal'),
- 'location_src_id': self.ref('stock.stock_location_stock'),
- 'location_id': self.ref('stock.stock_location_output'),
- 'invoice_state': '2binvoiced',
- 'operation_id': self.ref('l10n_br_fiscal.fo_venda'),
- 'operation_line_id': self.ref('l10n_br_fiscal.fo_venda_venda'),
- })],
- })
-
- # Set this route on `product.product_product_3`
- self.env.ref('product.product_product_3').write({
- 'route_ids': [(4, self.product_route.id)]})
-
- def test_procument_order(self):
- """Test Stock Rule create stock.move with Fiscal fields."""
-
- # Set this route on `product.product_product_3`
- self.env.ref('product.product_product_3').write({
- 'route_ids': [(4, self.product_route.id)]})
-
- # Create Delivery Order of 10 `product.product_product_3` from Output -> Customer
- product = self.env.ref('product.product_product_3')
- vals = {
- 'name': 'Delivery order for procurement',
- 'partner_id': self.ref('base.res_partner_2'),
- 'picking_type_id': self.ref('stock.picking_type_out'),
- 'location_id': self.ref('stock.stock_location_output'),
- 'location_dest_id': self.ref('stock.stock_location_customers'),
- 'move_lines': [(0, 0, {
- 'name': '/',
- 'product_id': product.id,
- 'product_uom': product.uom_id.id,
- 'product_uom_qty': 10.00,
- 'procure_method': 'make_to_order',
- })],
- }
- pick_output = self.env['stock.picking'].create(vals)
- pick_output.move_lines.onchange_product_id()
-
- # Confirm delivery order.
- pick_output.action_confirm()
-
- # I run the scheduler.
- # Note: If purchase if already installed, the method _run_buy
- # will be called due to the purchase demo data. As we update the
- # stock module to run this test, the method won't be an attribute
- # of stock.procurement at this moment. For that reason we mute the
- # logger when running the scheduler.
- with mute_logger('odoo.addons.stock.models.procurement'):
- self.env['procurement.group'].run_scheduler()
-
- # Check that a picking was created from stock to output.
- moves = self.env['stock.move'].search([
- ('product_id', '=', self.ref('product.product_product_3')),
- ('location_id', '=', self.ref('stock.stock_location_stock')),
- ('location_dest_id', '=', self.ref('stock.stock_location_output')),
- ('move_dest_ids', 'in', [pick_output.move_lines[0].id])
- ])
- self.assertEqual(
- len(moves.ids), 1,
- "It should have created a picking from Stock to Output with the"
- " original picking as destination")
-
- # Check if the fields included in l10n_br_stock_account was copied to move
- for move in moves:
- self.assertEqual(
- move.invoice_state, '2binvoiced',
- "The stock.move created has not invoice_state field 2binvoiced")
- self.assertEqual(
- move.operation_id.name, 'Venda',
- "The stock.move created has not operation_id field Venda")
- self.assertEqual(
- move.operation_line_id.name, 'Venda',
- "The stock.move created has not operation_line_id field Venda")
diff --git a/l10n_br_stock_account/views/stock_view.xml b/l10n_br_stock_account/views/stock_view.xml
deleted file mode 100644
index b9ff0eef292a..000000000000
--- a/l10n_br_stock_account/views/stock_view.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- l10n_br_stock_account.stock.location.path.form
-
- stock.location.path
-
- 32
-
-
-
-
-
-
-
-
-
- l10n_br_stock_account.procurement.rule.inherit.form
-
- procurement.rule
-
-
-
-
-
-
-
-
-
From 4fc76d8138d927c49d6c9fb5450ad8b20f31c1c3 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 11:41:42 -0300
Subject: [PATCH 049/612] [MOV] l10n_br_account_banking_payment_cnab ->
l10n_br_account_payment_cobranca
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_cobranca/README.rst | 73 +++
l10n_br_account_payment_cobranca/__init__.py | 25 +
.../__init__.py.orig | 30 +
.../__openerp__.py | 66 ++
.../__openerp__.py.orig | 69 +++
.../constantes.py | 418 +++++++++++++
.../data/l10n_br_payment_export_type.xml | 44 ++
.../demo/l10n_br_payment_mode.xml | 63 ++
.../febraban/__init__.py | 22 +
.../febraban/cnab.py | 51 ++
.../febraban/cnab_240/__init__.py | 20 +
.../febraban/cnab_240/bancos/__init__.py | 22 +
.../febraban/cnab_240/bancos/bb.py | 60 ++
.../febraban/cnab_240/bancos/bradesco.py | 84 +++
.../febraban/cnab_240/bancos/bradesco.py.orig | 71 +++
.../febraban/cnab_240/bancos/cef.py | 108 ++++
.../febraban/cnab_240/bancos/itau.py | 83 +++
.../febraban/cnab_240/bancos/santander.py | 59 ++
.../febraban/cnab_240/cnab_240.py | 570 +++++++++++++++++
.../febraban/cnab_240/cnab_240.py.orig | 566 +++++++++++++++++
.../febraban/cnab_400/__init__.py | 19 +
.../febraban/cnab_400/bancos/__init__.py | 20 +
.../febraban/cnab_400/bancos/bradesco.py | 113 ++++
.../febraban/cnab_400/cnab_400.py | 375 ++++++++++++
.../febraban/pag_for/__init__.py | 24 +
.../febraban/pag_for/bancos/__init__.py | 22 +
.../febraban/pag_for/bancos/bradesco.py | 75 +++
.../febraban/pag_for/pag_for500.py | 575 ++++++++++++++++++
.../models/__init__.py | 13 +
.../models/account_move_line.py | 49 ++
.../models/bank_payment_line.py | 108 ++++
.../models/l10n_br_cnab.py | 304 +++++++++
.../l10n_br_cnab_file_sufix_sequence.py | 34 ++
.../models/l10n_br_cnab_sequence.py | 40 ++
.../models/payment_line.py | 82 +++
.../models/payment_mode.py | 77 +++
.../models/payment_order.py | 75 +++
.../models/res_partner.py | 32 +
.../models/res_partner_bank.py | 37 ++
.../security/cnab_cobranca_security.xml | 11 +
.../security/ir.model.access.csv | 6 +
.../tests/test_remessa.REM | 6 +
.../views/account_move_line.xml | 19 +
.../views/bank_payment_line.xml | 31 +
.../views/l10n_br_cnab_retorno_view.xml | 173 ++++++
.../views/l10n_br_cnab_sequence.xml | 49 ++
.../views/l10n_br_cobranca_cnab.xml | 56 ++
.../views/l10n_br_cobranca_cnab_lines.xml | 123 ++++
.../views/l10n_br_payment_cnab.xml | 32 +
.../views/payment_line.xml | 25 +
.../views/payment_mode.xml | 32 +
.../views/payment_order.xml | 31 +
.../views/res_partner_bank.xml | 34 ++
.../wizard/__init__.py | 25 +
.../wizard/l10n_bank_payment_cnab_export.py | 105 ++++
.../wizard/payment_order_create.py | 139 +++++
56 files changed, 5475 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/README.rst
create mode 100644 l10n_br_account_payment_cobranca/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/__init__.py.orig
create mode 100644 l10n_br_account_payment_cobranca/__openerp__.py
create mode 100644 l10n_br_account_payment_cobranca/__openerp__.py.orig
create mode 100644 l10n_br_account_payment_cobranca/constantes.py
create mode 100644 l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
create mode 100644 l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
create mode 100644 l10n_br_account_payment_cobranca/febraban/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
create mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
create mode 100644 l10n_br_account_payment_cobranca/models/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/models/account_move_line.py
create mode 100644 l10n_br_account_payment_cobranca/models/bank_payment_line.py
create mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
create mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
create mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
create mode 100644 l10n_br_account_payment_cobranca/models/payment_line.py
create mode 100644 l10n_br_account_payment_cobranca/models/payment_mode.py
create mode 100644 l10n_br_account_payment_cobranca/models/payment_order.py
create mode 100644 l10n_br_account_payment_cobranca/models/res_partner.py
create mode 100644 l10n_br_account_payment_cobranca/models/res_partner_bank.py
create mode 100644 l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
create mode 100644 l10n_br_account_payment_cobranca/security/ir.model.access.csv
create mode 100644 l10n_br_account_payment_cobranca/tests/test_remessa.REM
create mode 100644 l10n_br_account_payment_cobranca/views/account_move_line.xml
create mode 100644 l10n_br_account_payment_cobranca/views/bank_payment_line.xml
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
create mode 100644 l10n_br_account_payment_cobranca/views/payment_line.xml
create mode 100644 l10n_br_account_payment_cobranca/views/payment_mode.xml
create mode 100644 l10n_br_account_payment_cobranca/views/payment_order.xml
create mode 100644 l10n_br_account_payment_cobranca/views/res_partner_bank.xml
create mode 100644 l10n_br_account_payment_cobranca/wizard/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
create mode 100644 l10n_br_account_payment_cobranca/wizard/payment_order_create.py
diff --git a/l10n_br_account_payment_cobranca/README.rst b/l10n_br_account_payment_cobranca/README.rst
new file mode 100644
index 000000000000..30ecee924f4a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/README.rst
@@ -0,0 +1,73 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+ :alt: License: AGPL-3
+
+
+Account Banking Brazillian - Payments Export Infrastructure
+=============================================================
+
+This module provide an infrastructure to export payment and debit orders in
+Febraban layout.
+
+Installation
+============
+
+This module depends on :
+* account_banking_payment_export
+* account_direct_debit
+
+This modules is part of the odoo-brazil/odoo-brazil-banking suite.
+
+Configuration
+=============
+
+ + In a multicompany environment, make sure the sequences payment line and payment order are with the company set to the one you'll use to export the payments and charges.
+ If they are not set like this, you'll not be able to add payment lines with regular users.
+
+Usage
+=====
+
+This module provides a menu to configure payment order types : Accounting > Configuration > Miscellaneous > Payment Export Types
+
+For further information, please visit:
+
+ * https://www.odoo.com/forum/help-1
+
+Known issues / Roadmap
+======================
+
+ * no known issues
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues `_. In case of trouble, please
+check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
+`here `_.
+
+
+Credits
+=======
+
+Contributors
+------------
+
+* Luis Felipe Mileo
+* Fernando Marcato Rodrigues
+* Daniel Sadamo
+
+
+Maintainer
+----------
+
+.. image:: https://brasil.odoo.com/logo.png
+ :alt: Odoo Brazil
+ :target: http://brazil.odoo.com
+
+This module is maintained by the Odoo Brazil.
+
+the Odoo Brazil Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
+
+To contribute to this module, please visit http://brazil.odoo.com
diff --git a/l10n_br_account_payment_cobranca/__init__.py b/l10n_br_account_payment_cobranca/__init__.py
new file mode 100644
index 000000000000..0e0916aec7f9
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/__init__.py
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import wizard
+from . import models
diff --git a/l10n_br_account_payment_cobranca/__init__.py.orig b/l10n_br_account_payment_cobranca/__init__.py.orig
new file mode 100644
index 000000000000..2ed5d635172a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/__init__.py.orig
@@ -0,0 +1,30 @@
+# -*- encoding: utf-8 -*-
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import wizard
+from . import model
+<<<<<<< HEAD
+
+=======
+import constantes
+>>>>>>> [WIP] Criação dos campos faltantes
diff --git a/l10n_br_account_payment_cobranca/__openerp__.py b/l10n_br_account_payment_cobranca/__openerp__.py
new file mode 100644
index 000000000000..96c1c722a242
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/__openerp__.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+{
+ 'name': 'Account Payment CNAB',
+ 'version': '8.0.1.0.0',
+ 'category': 'Banking addons',
+ 'license': 'AGPL-3',
+ 'author': 'KMEE, Odoo Community Association (OCA)',
+ 'website': 'http://www.kmee.com.br',
+ 'external_dependencies': {
+ 'python': ['cnab240',
+ 'pyboleto'],
+ },
+ 'depends': [
+ 'l10n_br_account_payment_boleto',
+ 'l10n_br_account_payment_mode',
+ 'l10n_br_account_product',
+ ],
+ 'data': [
+ 'security/cnab_cobranca_security.xml',
+ 'views/l10n_br_payment_cnab.xml',
+ 'views/payment_order.xml',
+ 'views/l10n_br_cnab_sequence.xml',
+ 'views/l10n_br_cobranca_cnab.xml',
+ 'views/l10n_br_cobranca_cnab_lines.xml',
+ 'views/account_move_line.xml',
+ 'views/res_partner_bank.xml',
+ 'views/l10n_br_cnab_retorno_view.xml',
+ 'views/payment_mode.xml',
+ 'views/payment_line.xml',
+ 'views/bank_payment_line.xml',
+ 'data/l10n_br_payment_export_type.xml',
+ # 'data/l10n_br_payment_mode.xml',
+ 'security/ir.model.access.csv',
+ ],
+ 'demo': [
+ # 'demo/l10n_br_payment_mode.xml',
+ ],
+ 'test': [
+ # 'tests/invoice_create.yml'
+ ],
+ "installable": True,
+ "auto_install": False,
+}
diff --git a/l10n_br_account_payment_cobranca/__openerp__.py.orig b/l10n_br_account_payment_cobranca/__openerp__.py.orig
new file mode 100644
index 000000000000..8c289f80394c
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/__openerp__.py.orig
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+{
+ 'name': 'Account Payment CNAB',
+ 'version': '8.0.1.0.0',
+ 'category': 'Banking addons',
+ 'license': 'AGPL-3',
+ 'author': 'KMEE, Odoo Community Association (OCA)',
+ 'website': 'http://www.kmee.com.br',
+ 'external_dependencies': {
+ 'python': ['cnab240',
+ 'pyboleto'],
+ },
+ 'depends': [
+ 'l10n_br_account_payment_boleto',
+ 'l10n_br_account_payment_mode',
+ 'l10n_br_account_product',
+ ],
+ 'data': [
+ 'security/cnab_cobranca_security.xml',
+ 'view/l10n_br_payment_cnab.xml',
+ 'view/payment_order.xml',
+ 'view/l10n_br_cnab_sequence.xml',
+ 'view/l10n_br_cobranca_cnab.xml',
+ 'view/l10n_br_cobranca_cnab_lines.xml',
+ 'view/account_move_line.xml',
+ 'view/res_partner_bank.xml',
+ 'view/l10n_br_cnab_retorno_view.xml',
+ 'view/payment_mode.xml',
+ 'view/payment_line.xml',
+ 'view/bank_payment_line.xml',
+ 'data/l10n_br_payment_export_type.xml',
+<<<<<<< HEAD
+ 'data/l10n_br_payment_mode.xml',
+=======
+ 'security/ir.model.access.csv',
+>>>>>>> [ADD] Regras de segurança para novos modelos
+ ],
+ 'demo': [
+ # 'demo/l10n_br_payment_mode.xml',
+ ],
+ 'test': [
+ 'tests/invoice_create.yml'
+ ],
+ "installable": True,
+ "auto_install": False,
+}
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
new file mode 100644
index 000000000000..393ed6701f8d
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -0,0 +1,418 @@
+# -*- coding: utf-8 -*-
+
+COBRANCA = '01'
+BOLETO_PAGAMENTO_ELETRONICO = '03'
+CONCILIACAO_BANCARIA = '04'
+DEBITOS = '05'
+CUSTODIA_CHEQUES = '06'
+GESTAO_CAIXA = '07'
+CONSULTA_INFORMACAO_MARGEM = '08'
+AVERBACAO_CONSIGNACAO_RETENCAO = '09'
+PAGAMENTO_DIVIDENDOS = '10'
+MANUTENCAO_CONSIGNACAO = '11'
+CONSIGNACAO_PARCELAS = '12'
+GLOSA_CONSIGNACAO = '13'
+CONSULTA_TRIBUTOS_PAGAR = '14'
+PAGAMENTO_FORNECEDOR = '20'
+PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS = '22'
+INTEROPERABILIDADE_CONTAS = '23'
+COMPROR = '25'
+COMPROR_ROTATIVO = '26'
+ALEGACAO_PAGADOR = '29'
+PAGAMENTO_SALARIOS = '30'
+PAGAMENTO_HONORARIOS = '32'
+PAGAMENTO_BOLSA_AUXILIO = '33'
+PAGAMENTO_PREBENDA = '34'
+VENDOR = '40'
+VENDOR_TERMO = '41'
+PAGAMENTO_SINISTROS_SEGURADOS = '50'
+PAGAMENTO_DESPESAS_VIAJANTE = '60'
+PAGAMENTO_AUTORIZADO = '70'
+PAGAMENTO_CREDENCIADOS = '75'
+PAGAMENTO_REMUNERACAO = '77'
+PAGAMENTO_REPRESENTANTES = '80'
+PAGAMENTO_BENEFICIOS = '90'
+PAGAMENTOS_DIVERSOS = '98'
+
+TIPO_SERVICO = [
+ (COBRANCA, COBRANCA + u' - Cobrança'),
+ (BOLETO_PAGAMENTO_ELETRONICO, BOLETO_PAGAMENTO_ELETRONICO +
+ u' - Boleto de Pagamento Eletrônico'),
+ (CONCILIACAO_BANCARIA, CONCILIACAO_BANCARIA + u' - Conciliação Bancária'),
+ (DEBITOS, DEBITOS + u' - Débitos'),
+ (CUSTODIA_CHEQUES, CUSTODIA_CHEQUES + u' - Custódia de Cheques'),
+ (GESTAO_CAIXA, GESTAO_CAIXA + u' - Gestão de Caixa'),
+ (CONSULTA_INFORMACAO_MARGEM, CONSULTA_INFORMACAO_MARGEM +
+ u' - Consulta/Informação Margem'),
+ (AVERBACAO_CONSIGNACAO_RETENCAO, AVERBACAO_CONSIGNACAO_RETENCAO +
+ u' - Averbação da Consignação/Retenção'),
+ (PAGAMENTO_DIVIDENDOS, PAGAMENTO_DIVIDENDOS + u' - Pagamento Dividendos'),
+ (MANUTENCAO_CONSIGNACAO, MANUTENCAO_CONSIGNACAO +
+ u' - Manutenção da Consignação'),
+ (CONSIGNACAO_PARCELAS, CONSIGNACAO_PARCELAS +
+ u' - Consignação de Parcelas'),
+ (GLOSA_CONSIGNACAO, GLOSA_CONSIGNACAO +
+ u' - Glosa da Consignação (INSS)'),
+ (CONSULTA_TRIBUTOS_PAGAR, CONSULTA_TRIBUTOS_PAGAR +
+ u' - Consulta de Tributos a pagar'),
+ (PAGAMENTO_FORNECEDOR, PAGAMENTO_FORNECEDOR +
+ u' - Pagamento Fornecedor'),
+ (PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS, PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS +
+ u' - Pagamento de Contas, Tributos e Impostos'),
+ (INTEROPERABILIDADE_CONTAS, INTEROPERABILIDADE_CONTAS +
+ u' - Interoperabilidade entre Contas de Instituições de Pagamentos'),
+ (COMPROR, COMPROR + u' - Compror'),
+ (COMPROR_ROTATIVO, COMPROR_ROTATIVO + u' - Compror Rotativo'),
+ (ALEGACAO_PAGADOR, ALEGACAO_PAGADOR + u' - Alegação do Pagador'),
+ (PAGAMENTO_SALARIOS, PAGAMENTO_SALARIOS + u' - Pagamento Salários'),
+ (PAGAMENTO_HONORARIOS, PAGAMENTO_HONORARIOS +
+ u' - Pagamento de honorários'),
+ (PAGAMENTO_BOLSA_AUXILIO, PAGAMENTO_BOLSA_AUXILIO +
+ u' - Pagamento de bolsa auxílio'),
+ (PAGAMENTO_PREBENDA, PAGAMENTO_PREBENDA +
+ u' - Pagamento de prebenda (remuneração a padres e sacerdotes)'),
+ (VENDOR, VENDOR + u' - Vendor'),
+ (VENDOR_TERMO, VENDOR_TERMO + u' - Vendor a Termo'),
+ (PAGAMENTO_SINISTROS_SEGURADOS, PAGAMENTO_SINISTROS_SEGURADOS +
+ u' - Pagamento Sinistros Segurados'),
+ (PAGAMENTO_DESPESAS_VIAJANTE, PAGAMENTO_DESPESAS_VIAJANTE +
+ u' - Pagamento Despesas Viajante em Trânsito'),
+ (PAGAMENTO_AUTORIZADO, PAGAMENTO_AUTORIZADO + u' - Pagamento Autorizado'),
+ (PAGAMENTO_CREDENCIADOS, PAGAMENTO_CREDENCIADOS +
+ u' - Pagamento Credenciados'),
+ (PAGAMENTO_REMUNERACAO, PAGAMENTO_REMUNERACAO +
+ u' - Pagamento de Remuneração'),
+ (PAGAMENTO_REPRESENTANTES, PAGAMENTO_REPRESENTANTES +
+ u' - Pagamento Representantes / Vendedores Autorizados'),
+ (PAGAMENTO_BENEFICIOS, PAGAMENTO_BENEFICIOS + u' - Pagamento Benefícios'),
+ (PAGAMENTOS_DIVERSOS, PAGAMENTOS_DIVERSOS + u' - Pagamentos Diversos'),
+]
+
+CREDITO_CONTA_CORRENTE_SALARIO = (
+ '01', u'01 - Crédito em Conta Corrente/Salário')
+CHEQUE_PAGAMENTO_ADMINISTRATIVO = (
+ '02', u'02 - Cheque Pagamento / Administrativo')
+DOC_TED = ('03', u'03 - DOC/TED (1) (2)')
+CARTAO_SALARIO = (
+ '04', u'04 - Cartão Salário (somente para Tipo de Serviço = \'30\')')
+CREDITO_CONTA_POUPANCA = ('05', u'05 - Crédito em Conta Poupança')
+OP_A_DISPOSICAO = ('10', u'10 - OP à Disposição')
+PAGAMENTO_CONTAS_TRIBUTOS_CODIGO_BARRAS = (
+ '11', u'11 - Pagamento de Contas e Tributos com Código de Barras')
+TRIBUTO_DARF_NORMAL = ('16', u'16 - Tributo - DARF Normal')
+TRIBUTO_GPS = ('17', u'17 - Tributo - GPS (Guia da Previdência Social)')
+TRIBUTO_DARF_SIMPLES = ('18', u'18 - Tributo - DARF Simples')
+TRIBUTO_IPTU_PREFEITURAS = ('19', u'19 - Tributo - IPTU – Prefeituras')
+PAGAMENTO_AUTENTICACAO = ('20', u'20 - Pagamento com Autenticação')
+TRIBUTO_DARJ = ('21', u'21 - Tributo – DARJ')
+TRIBUTO_GARE_SP_ICMS = ('22', u'22 - Tributo - GARE-SP ICMS')
+TRIBUTO_GARE_SP_DR = ('23', u'23 - Tributo - GARE-SP DR')
+TRIBUTO_GARE_SP_ITCMD = ('24', u'24 - Tributo - GARE-SP ITCMD')
+TRIBUTO_IPVA = ('25', u'25 - Tributo - IPVA')
+TRIBUTO_LICENCIAMENTO = ('26', u'26 - Tributo - Licenciamento')
+TRIBUTO_DPVAT = ('27', u'27 - Tributo – DPVAT')
+LIQUIDACAO_TITULOS_PROPRIO_BANCO = (
+ '30', u'30 - Liquidação de Títulos do Próprio Banco')
+PAGAMENTO_TITULOS_OUTROS_BANCOS = (
+ '31', u'31 - Pagamento de Títulos de Outros Bancos')
+EXTRATO_CONTA_CORRENTE = ('40', u'40 - Extrato de Conta Corrente')
+TED_OUTRA_TITULARIDADE = ('41', u'41 - TED – Outra Titularidade (1)')
+TED_MESMA_TITULARIDADE = ('43', u'43 - TED – Mesma Titularidade (1)')
+TED_TRANSFERENCIA_CONTA_INVESTIMENTO = (
+ '44', u'44 - TED para Transferência de Conta Investimento')
+DEBITO_CONTA_CORRENTE = ('50', u'50 - Débito em Conta Corrente')
+EXTRATO_GESTAO_CAIXA = ('70', u'70 - Extrato para Gestão de Caixa')
+DEPOSITO_JUDICIAL_CONTA_CORRENTE = (
+ '71', u'71 - Depósito Judicial em Conta Corrente')
+DEPOSITO_JUDICIAL_POUPANCA = ('72', u'72 - Depósito Judicial em Poupança')
+EXTRATO_CONTA_INVESTIMENTO = ('73', u'73 - Extrato de Conta Investimento')
+
+FORMA_LANCAMENTO = [
+ CREDITO_CONTA_CORRENTE_SALARIO,
+ CHEQUE_PAGAMENTO_ADMINISTRATIVO,
+ DOC_TED,
+ CARTAO_SALARIO,
+ CREDITO_CONTA_POUPANCA,
+ OP_A_DISPOSICAO,
+ PAGAMENTO_CONTAS_TRIBUTOS_CODIGO_BARRAS,
+ TRIBUTO_DARF_NORMAL,
+ TRIBUTO_GPS,
+ TRIBUTO_DARF_SIMPLES,
+ TRIBUTO_IPTU_PREFEITURAS,
+ PAGAMENTO_AUTENTICACAO,
+ TRIBUTO_DARJ,
+ TRIBUTO_GARE_SP_ICMS,
+ TRIBUTO_GARE_SP_DR,
+ TRIBUTO_GARE_SP_ITCMD,
+ TRIBUTO_IPVA,
+ TRIBUTO_LICENCIAMENTO,
+ TRIBUTO_DPVAT,
+ LIQUIDACAO_TITULOS_PROPRIO_BANCO,
+ PAGAMENTO_TITULOS_OUTROS_BANCOS,
+ EXTRATO_CONTA_CORRENTE,
+ TED_OUTRA_TITULARIDADE,
+ TED_MESMA_TITULARIDADE,
+ TED_TRANSFERENCIA_CONTA_INVESTIMENTO,
+ DEBITO_CONTA_CORRENTE,
+ EXTRATO_GESTAO_CAIXA,
+ DEPOSITO_JUDICIAL_CONTA_CORRENTE,
+ DEPOSITO_JUDICIAL_POUPANCA,
+ EXTRATO_CONTA_INVESTIMENTO,
+]
+
+CREDITO_EM_CONTA = ('01', u'01 - Crédito em Conta')
+PAGAMENTO_ALUGUEL = ('02', u'02 - Pagamento de Aluguel/Condomínio')
+PAGAMENTO_DUPLICATA_TITULOS = ('03', u'03 - Pagamento de Duplicata/Títulos')
+PAGAMENTO_DIVIDENDOS_C = ('04', u'04 - Pagamento de Dividendos')
+PAGAMENTO_MENSALIDADE_ESCOLAR = (
+ '05', u'05 - Pagamento de Mensalidade Escolar')
+PAGAMENTO_SALARIOS_C = ('06', u'06 - Pagamento de Salários')
+PAGAMENTO_FORNECEDORES = ('07', u'07 - Pagamento a Fornecedores')
+OPERACOES_CAMBIOS_FUNDOS_BOLSA = (
+ '08', u'08 - Operações de Câmbios/Fundos/Bolsa de Valores')
+REPASSE_ARRECADACAO = (
+ '09', u'09 - Repasse de Arrecadação/Pagamento de Tributos')
+TRANSFERECIA_INTERNACIONAL_EM_REAL = (
+ '10', u'10 - Transferência Internacional em Real')
+DOC_POUPANCA = ('11', u'11 - DOC para Poupança')
+DOC_DEPOSITO_JUDICIAL = ('12', u'12 - DOC para Depósito Judicial')
+OUTROS = ('13', u'13 - Outros')
+PAGAMENTO_BOLSA_AUXILIO_C = ('16', u'16 - Pagamento de bolsa auxílio')
+REMUNERACAO_COOPERADO = ('17', u'17 - Remuneração à cooperado')
+PAGAMENTO_HONORARIOS_C = ('18', u'18 - Pagamento de honorários')
+PAGAMENTO_PREBENDA_C = (
+ '19', u'19 - Pagamento de prebenda (Remuneração a padres e sacerdotes)')
+
+COMPLEMENTO_TIPO_SERVICO = [
+ CREDITO_EM_CONTA,
+ PAGAMENTO_ALUGUEL,
+ PAGAMENTO_DUPLICATA_TITULOS,
+ PAGAMENTO_DIVIDENDOS_C,
+ PAGAMENTO_MENSALIDADE_ESCOLAR,
+ PAGAMENTO_SALARIOS_C,
+ PAGAMENTO_FORNECEDORES,
+ OPERACOES_CAMBIOS_FUNDOS_BOLSA,
+ REPASSE_ARRECADACAO,
+ TRANSFERECIA_INTERNACIONAL_EM_REAL,
+ DOC_POUPANCA,
+ DOC_DEPOSITO_JUDICIAL,
+ OUTROS,
+ PAGAMENTO_BOLSA_AUXILIO_C,
+ REMUNERACAO_COOPERADO,
+ PAGAMENTO_HONORARIOS_C,
+ PAGAMENTO_PREBENDA_C,
+]
+
+# Codigo adotado pelo Banco Central para identificar a
+# finalidade da TED. Utitilizar os
+# códigos de finalidade cliente, disponíveis no site do Banco Central do Brasil
+# (www.bcb.gov.br), Sistema de Pagamentos Brasileiro,
+# Transferência de Arquivos,
+# Dicionários de Domínios para o SPB.
+CODIGO_FINALIDADE_TED = [
+ (' ', u'Padrão')
+]
+
+NAO_EMITE_AVISO = ('0', u'0 - Não Emite Aviso')
+EMITE_AVISO_REMETENTE = ('2', u'2 - Emite Aviso Somente para o Remetente')
+EMITE_AVISO_FAVORECIDO = ('5', u'5 - Emite Aviso Somente para o Favorecido')
+EMITE_AVISO_REMETENTE_FAVORECIDO = \
+ ('6', u'6 - Emite Aviso para o Remetente e Favorecido')
+EMITE_AVISO_FAVORECIDO_2_VIAS_REMETENTE = \
+ ('7', u'7 - Emite Aviso para o Favorecido e 2 Vias para o Remetente')
+
+AVISO_FAVORECIDO = [
+ NAO_EMITE_AVISO,
+ EMITE_AVISO_REMETENTE,
+ EMITE_AVISO_FAVORECIDO,
+ EMITE_AVISO_REMETENTE_FAVORECIDO,
+ EMITE_AVISO_FAVORECIDO_2_VIAS_REMETENTE,
+]
+
+INDICATIVO_FORMA_PAGAMENTO = [
+ ('01', u'01 - Débito em Conta Corrente'),
+ ('02', u'02 - Débito Empréstimo/Financiamento'),
+ ('03', u'03 - Débito Cartão de Crédito'),
+]
+
+TIPO_MOVIMENTO = [
+ ('0', u'0 - Indica INCLUSÃO'),
+ ('1', u'1 - Indica CONSULTA'),
+ ('2', u'2 - Indica SUSPENSÃO'),
+ ('3', u'3 - Indica ESTORNO (somente para retorno)'),
+ ('4', u'4 - Indica REATIVAÇÃO'),
+ ('5', u'5 - Indica ALTERAÇÃO'),
+ ('7', u'7 - Indica LIQUIDAÇAO'),
+ ('9', u'9 - Indica EXCLUSÃO'),
+]
+
+CODIGO_INSTRUCAO_MOVIMENTO = [
+ ('0', u'00 - Inclusão de Registro Detalhe Liberado'),
+ ('9', u'09 - Inclusão do Registro Detalhe Bloqueado'),
+ ('10', u'10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)'),
+ ('11', u'11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)'),
+ ('17', u'17 - Alteração do Valor do Título'),
+ ('19', u'19 - Alteração da Data de Pagamento'),
+ ('23', u'23 - Pagamento Direto ao Fornecedor - Baixar'),
+ ('25', u'25 - Manutenção em Carteira - Não Pagar'),
+ ('27', u'27 - Retirada de Carteira - Não Pagar'),
+ ('33', u'33 - Estorno por Devolução da Câmara Centralizadora '
+ u'(somente para Tipo de Movimento = \'3\')'),
+ ('40', u'40 - Alegação do Pagador'),
+ ('99', u'99 - Exclusão do Registro Detalhe Incluído Anteriormente'),
+]
+
+CODIGO_OCORRENCIAS = [
+ ('00', u'00 - Crédito ou Débito Efetivado'),
+ ('01', u'01 - Insuficiência de Fundos - Débito Não Efetuado'),
+ ('02', u'02 - Crédito ou Débito Cancelado pelo Pagador/Credor'),
+ ('03', u'03 - Débito Autorizado pela Agência - Efetuado'),
+ ('AA', u'AA - Controle Inválido'),
+ ('AB', u'AB - Tipo de Operação Inválido'),
+ ('AC', u'AC - Tipo de Serviço Inválido'),
+ ('AD', u'AD - Forma de Lançamento Inválida'),
+ ('AE', u'AE - Tipo/Número de Inscrição Inválido'),
+ ('AF', u'AF - Código de Convênio Inválido'),
+ ('AG', u'AG - Agência/Conta Corrente/DV Inválido'),
+ ('AH', u'AH - Nº Seqüencial do Registro no Lote Inválido'),
+ ('AI', u'AI - Código de Segmento de Detalhe Inválido'),
+ ('AJ', u'AJ - Tipo de Movimento Inválido'),
+ ('AK', u'AK - Código da Câmara de Compensação do Banco'
+ u' Favorecido/Depositário Inválido'),
+ ('AL', u'AL - Código do Banco Favorecido, Instituição de Pagamento'
+ u' ou Depositário Inválido'),
+ ('AM', u'AM - Agência Mantenedora da Conta Corrente do'
+ u' Favorecido Inválida'),
+ ('AN', u'AN - Conta Corrente/DV/Conta de Pagamento do'
+ u' Favorecido Inválido'),
+ ('AO', u'AO - Nome do Favorecido Não Informado'),
+ ('AP', u'AP - Data Lançamento Inválido'),
+ ('AQ', u'AQ - Tipo/Quantidade da Moeda Inválido'),
+ ('AR', u'AR - Valor do Lançamento Inválido'),
+ ('AS', u'AS - Aviso ao Favorecido - Identificação Inválida'),
+ ('AT', u'AT - Tipo/Número de Inscrição do Favorecido Inválido'),
+ ('AU', u'AU - Logradouro do Favorecido Não Informado'),
+ ('AV', u'AV - Nº do Local do Favorecido Não Informado'),
+ ('AW', u'AW - Cidade do Favorecido Não Informada'),
+ ('AX', u'AX - CEP/Complemento do Favorecido Inválido'),
+ ('AY', u'AY - Sigla do Estado do Favorecido Inválida'),
+ ('AZ', u'AZ - Código/Nome do Banco Depositário Inválido'),
+ ('BA', u'BA - Código/Nome da Agência Depositária Não Informado'),
+ ('BB', u'BB - Seu Número Inválido'),
+ ('BC', u'BC - Nosso Número Inválido'),
+ ('BD', u'BD - Inclusão Efetuada com Sucesso'),
+ ('BE', u'BE - Alteração Efetuada com Sucesso'),
+ ('BF', u'BF - Exclusão Efetuada com Sucesso'),
+ ('BG', u'BG - Agência/Conta Impedida Legalmente'),
+ ('BH', u'BH - Empresa não pagou salário'),
+ ('BI', u'BI - Falecimento do mutuário'),
+ ('BJ', u'BJ - Empresa não enviou remessa do mutuário'),
+ ('BK', u'BK - Empresa não enviou remessa no vencimento'),
+ ('BL', u'BL - Valor da parcela inválida'),
+ ('BM', u'BM - Identificação do contrato inválida'),
+ ('BN', u'BN - Operação de Consignação Incluída com Sucesso'),
+ ('BO', u'BO - Operação de Consignação Alterada com Sucesso'),
+ ('BP', u'BP - Operação de Consignação Excluída com Sucesso'),
+ ('BQ', u'BQ - Operação de Consignação Liquidada com Sucesso'),
+ ('BR', u'BR - Reativação Efetuada com Sucesso'),
+ ('BS', u'BS - Suspensão Efetuada com Sucesso'),
+ ('CA', u'CA - Código de Barras - Código do Banco Inválido'),
+ ('CB', u'CB - Código de Barras - Código da Moeda Inválido'),
+ ('CC', u'CC - Código de Barras - Dígito Verificador Geral Inválido'),
+ ('CD', u'CD - Código de Barras - Valor do Título Inválido'),
+ ('CE', u'CE - Código de Barras - Campo Livre Inválido'),
+ ('CF', u'CF - Valor do Documento Inválido'),
+ ('CG', u'CG - Valor do Abatimento Inválido'),
+ ('CH', u'CH - Valor do Desconto Inválido'),
+ ('CI', u'CI - Valor de Mora Inválido'),
+ ('CJ', u'CJ - Valor da Multa Inválido'),
+ ('CK', u'CK - Valor do IR Inválido'),
+ ('CL', u'CL - Valor do ISS Inválido'),
+ ('CM', u'CM - Valor do IOF Inválido'),
+ ('CN', u'CN - Valor de Outras Deduções Inválido'),
+ ('CO', u'CO - Valor de Outros Acréscimos Inválido'),
+ ('CP', u'CP - Valor do INSS Inválido'),
+ ('HA', u'HA - Lote Não Aceito'),
+ ('HB', u'HB - Inscrição da Empresa Inválida para o Contrato'),
+ ('HC', u'HC - Convênio com a Empresa Inexistente/Inválido'
+ u' para o Contrato'),
+ ('HD', u'HD - Agência/Conta Corrente da Empresa Inexistente/Inválido'
+ u' para o Contrato'),
+ ('HE', u'HE - Tipo de Serviço Inválido para o Contrato'),
+ ('HF', u'HF - Conta Corrente da Empresa com Saldo Insuficiente'),
+ ('HG', u'HG - Lote de Serviço Fora de Seqüência'),
+ ('HH', u'HH - Lote de Serviço Inválido'),
+ ('HI', u'HI - Arquivo não aceito'),
+ ('HJ', u'HJ - Tipo de Registro Inválido'),
+ ('HK', u'HK - Código Remessa / Retorno Inválido'),
+ ('HL', u'HL - Versão de layout inválida'),
+ ('HM', u'HM - Mutuário não identificado'),
+ ('HN', u'HN - Tipo do beneficio não permite empréstimo'),
+ ('HO', u'HO - Beneficio cessado/suspenso'),
+ ('HP', u'HP - Beneficio possui representante legal'),
+ ('HQ', u'HQ - Beneficio é do tipo PA (Pensão alimentícia)'),
+ ('HR', u'HR - Quantidade de contratos permitida excedida'),
+ ('HS', u'HS - Beneficio não pertence ao Banco informado'),
+ ('HT', u'HT - Início do desconto informado já ultrapassado'),
+ ('HU', u'HU - Número da parcela inválida'),
+ ('HV', u'HV - Quantidade de parcela inválida'),
+ ('HW', u'HW - Margem consignável excedida para o mutuário dentro'
+ u' do prazo do contrato'),
+ ('HX', u'HX - Empréstimo já cadastrado'),
+ ('HY', u'HY - Empréstimo inexistente'),
+ ('HZ', u'HZ - Empréstimo já encerrado'),
+ ('H1', u'H1 - Arquivo sem trailer'),
+ ('H2', u'H2 - Mutuário sem crédito na competência'),
+ ('H3', u'H3 - Não descontado – outros motivos'),
+ ('H4', u'H4 - Retorno de Crédito não pago'),
+ ('H5', u'H5 - Cancelamento de empréstimo retroativo'),
+ ('H6', u'H6 - Outros Motivos de Glosa'),
+ ('H7', u'H7 - Margem consignável excedida para o mutuário acima'
+ u' do prazo do contrato'),
+ ('H8', u'H8 - Mutuário desligado do empregador'),
+ ('H9', u'H9 - Mutuário afastado por licença'),
+ ('IA', u'IA - Primeiro nome do mutuário diferente do primeiro nome'
+ u' do movimento do censo ou diferente da base de Titular'
+ u' do Benefício'),
+ ('IB', u'IB - Benefício suspenso/cessado pela APS ou Sisobi'),
+ ('IC', u'IC - Benefício suspenso por dependência de cálculo'),
+ ('ID', u'ID - Benefício suspenso/cessado pela inspetoria/auditoria'),
+ ('IE', u'IE - Benefício bloqueado para empréstimo pelo beneficiário'),
+ ('IF', u'IF - Benefício bloqueado para empréstimo por TBM'),
+ ('IG', u'IG - Benefício está em fase de concessão de PA ou desdobramento'),
+ ('IH', u'IH - Benefício cessado por óbito'),
+ ('II', u'II - Benefício cessado por fraude'),
+ ('IJ', u'IJ - Benefício cessado por concessão de outro benefício'),
+ ('IK', u'IK - Benefício cessado: estatutário transferido'
+ u' para órgão de origem'),
+ ('IL', u'IL - Empréstimo suspenso pela APS'),
+ ('IM', u'IM - Empréstimo cancelado pelo banco'),
+ ('IN', u'IN - Crédito transformado em PAB'),
+ ('IO', u'IO - Término da consignação foi alterado'),
+ ('IP', u'IP - Fim do empréstimo ocorreu durante período'
+ u' de suspensão ou concessão'),
+ ('IQ', u'IQ - Empréstimo suspenso pelo banco'),
+ ('IR', u'IR - Não averbação de contrato – quantidade de'
+ u' parcelas/competências informadas ultrapassou a data limite'
+ u' da extinção de cota do dependente titular de benefícios'),
+ ('TA', u'TA - Lote Não Aceito - Totais do Lote com Diferença'),
+ ('YA', u'YA - Título Não Encontrado'),
+ ('YB', u'YB - Identificador Registro Opcional Inválido'),
+ ('YC', u'YC - Código Padrão Inválido'),
+ ('YD', u'YD - Código de Ocorrência Inválido'),
+ ('YE', u'YE - Complemento de Ocorrência Inválido'),
+ ('YF', u'YF - Alegação já Informada'),
+ ('ZA', u'ZA - Agência / Conta do Favorecido Substituída'),
+ ('ZB', u'ZB - Divergência entre o primeiro e último nome do beneficiário'
+ u' versus primeiro e último nome na Receita Federal'),
+ ('ZC', u'ZC - Confirmação de Antecipação de Valor'),
+ ('ZD', u'ZD - Antecipação parcial de valor'),
+ ('ZE', u'ZE - Título bloqueado na base'),
+ ('ZF', u'ZF - Sistema em contingência'
+ u' – título valor maior que referência'),
+ ('ZG', u'ZG - Sistema em contingência – título vencido'),
+ ('ZH', u'ZH - Sistema em contingência – título indexado'),
+ ('ZI', u'ZI - Beneficiário divergente'),
+ ('ZJ', u'ZJ - Limite de pagamentos parciais excedido'),
+ ('ZK', u'ZK - Boleto já liquidado'),
+]
diff --git a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
new file mode 100644
index 000000000000..fe787b74e9db
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+ 240
+ Cnab240
+ True
+ payment
+
+
+
+
+
+
+
+ 400
+ Cnab400
+ True
+
+
+
+
+
+
+
+ 500
+ Cnab500
+ True
+ payment
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
new file mode 100644
index 000000000000..c826dfe962e7
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+ Cobrança Bradesco240
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o vencimento
+ 3
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+ Cobrança Itau240
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o vencimento
+ 6
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+ Cobrança Cef240
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o vencimento
+ 11
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/febraban/__init__.py b/l10n_br_account_payment_cobranca/febraban/__init__.py
new file mode 100644
index 000000000000..0104e2520683
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/__init__.py
@@ -0,0 +1,22 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
new file mode 100644
index 000000000000..2a384e4a877b
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -0,0 +1,51 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+# TODO: implement abc factory?
+
+from __future__ import division, print_function, unicode_literals
+
+
+class Cnab(object):
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def get_cnab(bank, cnab_type='240'):
+ if cnab_type == '240':
+ from .cnab_240.cnab_240 import Cnab240
+ return Cnab240.get_bank(bank)
+ elif cnab_type == '400':
+ from .cnab_400.cnab_400 import Cnab400
+ return Cnab400.get_bank(bank)
+ elif cnab_type == '500':
+ from .pag_for.pag_for500 import PagFor500
+ return PagFor500.get_bank(bank)
+ else:
+ return False
+
+ def remessa(self, order):
+ return False
+
+ def retorno(self, cnab_file):
+ return object
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
new file mode 100644
index 000000000000..9a4bbb7d6759
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
@@ -0,0 +1,20 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
new file mode 100644
index 000000000000..0104e2520683
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
@@ -0,0 +1,22 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
new file mode 100644
index 000000000000..5580359114f5
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
@@ -0,0 +1,60 @@
+# coding: utf-8
+
+from __future__ import division, print_function, unicode_literals
+
+import re
+import string
+
+from ..cnab_240 import Cnab240
+
+
+class BB240(Cnab240):
+
+ def __init__(self):
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import bancodobrasil
+ self.bank = bancodobrasil
+
+ def _prepare_header(self):
+ """
+ Preparar header do arquivo.
+ Adicionar informações no header do arquivo do Banco do Brasil
+ """
+ vals = super(BB240, self)._prepare_header()
+ # vals['servico_servico'] = 1
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+ Preparar o evento (segmentoA e segmentoB) apartir da payment.line
+ :param line - payment.line
+ :return: dict - Informações
+ """
+ vals = super(BB240, self)._prepare_cobranca(line)
+ # vals['prazo_baixa'] = unicode(str(
+ # vals['prazo_baixa']), "utf-8")
+ # vals['desconto1_percentual'] = Decimal('0.00')
+ # vals['valor_iof'] = Decimal('0.00')
+ # # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
+ # vals['identificacao_titulo_banco'] = int(
+ # vals['identificacao_titulo_banco'])
+ # vals['cedente_conta_dv'] = unicode(str(
+ # vals['cedente_conta_dv']), "utf-8")
+ # vals['cedente_agencia_dv'] = unicode(str(
+ # vals['cedente_agencia_dv']), "utf-8")
+ # vals['cedente_dv_ag_cc'] = unicode(str(
+ # vals['cedente_dv_ag_cc']), "utf-8")
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
+ # CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
+
+ def str_to_unicode(inp_str):
+ inp_str = unicode(inp_str, "utf-8")
+ return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
new file mode 100644
index 000000000000..3dea8ad58bc8
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
@@ -0,0 +1,84 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+import re
+import string
+from decimal import Decimal
+
+from ..cnab_240 import Cnab240
+
+
+class Bradesco240(Cnab240):
+
+ def __init__(self):
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import bradesco
+ self.bank = bradesco
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+
+ vals = super(Bradesco240, self)._prepare_header()
+ vals['servico_servico'] = 1
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Bradesco240, self)._prepare_cobranca(line)
+ vals['prazo_baixa'] = unicode(str(
+ vals['prazo_baixa']), "utf-8")
+ vals['desconto1_percentual'] = Decimal('0.00')
+ vals['valor_iof'] = Decimal('0.00')
+ # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
+ vals['identificacao_titulo_banco'] = int(
+ vals['identificacao_titulo_banco'])
+ vals['cedente_conta_dv'] = unicode(str(
+ vals['cedente_conta_dv']), "utf-8")
+ vals['cedente_agencia_dv'] = unicode(str(
+ vals['cedente_agencia_dv']), "utf-8")
+ vals['cedente_dv_ag_cc'] = unicode(str(
+ vals['cedente_dv_ag_cc']), "utf-8")
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
+ # CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
+
+
+def str_to_unicode(inp_str):
+ inp_str = unicode(inp_str, "utf-8")
+ return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
new file mode 100644
index 000000000000..95d4537a20cb
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
@@ -0,0 +1,71 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+from ..cnab_240 import Cnab240
+import re
+import string
+from decimal import Decimal
+
+
+class Bradesco240(Cnab240):
+<<<<<<< HEAD
+=======
+
+>>>>>>> [FIX] pep8 and merge clear
+ def __init__(self):
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import bradesco
+ self.bank = bradesco
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+ vals = super(Bradesco240, self)._prepare_header()
+ return vals
+
+ def _prepare_segmento(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Bradesco240, self)._prepare_segmento(line)
+ vals['prazo_baixa'] = unicode(str(
+ vals['prazo_baixa']), "utf-8")
+ vals['desconto1_percentual'] = Decimal('0.00')
+ vals['valor_iof'] = Decimal('0.00')
+ vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
+ # CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
new file mode 100644
index 000000000000..14193fe38ebc
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
@@ -0,0 +1,108 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import re
+import string
+from decimal import Decimal
+
+from ..cnab_240 import Cnab240
+
+
+class Cef240(Cnab240):
+
+ def __init__(self):
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import cef
+ self.bank = cef
+
+ def _prepare_header(self):
+ """
+
+ :return:
+ """
+ vals = super(Cef240, self)._prepare_header()
+ vals['cedente_dv_ag_cc'] = unicode(str(
+ vals['cedente_dv_ag_cc']), "utf-8")
+ vals['cedente_agencia_dv'] = unicode(str(
+ vals['cedente_agencia_dv']), "utf-8")
+ # TODO: adicionar campo para preencher o codigo do cedente no
+ # cadastro da conta bancária
+ vals['cedente_codigo_codCedente'] = 6088
+ vals['nome_do_banco'] = u'CAIXA ECONOMICA FEDERAL'
+ # Não pode pegar comentário da payment_line.
+ vals['reservado_cedente_campo23'] = u'REMESSA TESTE'
+ # reservado_banco_campo22 não é required. Código atualizado na
+ # biblioteca cnab240
+ vals['data_credito_hd_lote'] = 15052015
+
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Cef240, self)._prepare_cobranca(line)
+
+ carteira, nosso_numero, digito = self.nosso_numero(
+ line.move_line_id.transaction_ref)
+
+ vals['cedente_dv_ag_cc'] = unicode(str(
+ vals['cedente_dv_ag_cc']), "utf-8")
+ # Informar o Número do Documento - Seu Número (mesmo das posições
+ # 63-73 do Segmento P)
+ vals['identificacao_titulo'] = unicode(str(
+ vals['numero_documento']), "utf-8")
+ # TODO: campo 27.3P CEF. Código do juros de mora
+ vals['juros_cod_mora'] = 3
+ vals['carteira_numero'] = int(carteira)
+ vals['nosso_numero'] = int(nosso_numero)
+ vals['nosso_numero_dv'] = int(digito)
+ vals['prazo_baixa'] = unicode(str(
+ vals['prazo_baixa']), "utf-8")
+
+ # Precisam estar preenchidos
+ # Header lote
+ # vals['servico_operacao'] = u'R'
+ # vals['servico_servico'] = 1
+ vals['cedente_conta_dv'] = unicode(str(
+ vals['cedente_conta_dv']), "utf-8")
+ vals['cedente_codigo_codCedente'] = 6088
+ vals['data_credito_hd_lote'] = 15052015
+
+ vals['desconto1_cod'] = 3
+ vals['desconto1_data'] = 0
+ vals['desconto1_percentual'] = Decimal('0.00')
+ vals['valor_iof'] = Decimal('0.00')
+
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
+ # CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = 14
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
new file mode 100644
index 000000000000..84c570692f7f
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
@@ -0,0 +1,83 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import re
+import string
+
+from ..cnab_240 import Cnab240
+
+
+class Itau240(Cnab240):
+ """
+
+ """
+
+ def __init__(self):
+ """
+
+ :return:
+ """
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import itau
+ self.bank = itau
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+ vals = super(Itau240, self)._prepare_header()
+ vals['cedente_dv_ag_cc'] = int(
+ vals['cedente_dv_ag_cc'])
+ vals['cedente_agencia_dv'] = int(
+ vals['cedente_agencia_dv']),
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Itau240, self)._prepare_cobranca(line)
+
+ carteira, nosso_numero, digito = self.nosso_numero(
+ line.move_line_id.transaction_ref)
+
+ vals['cedente_dv_ag_cc'] = int(
+ vals['cedente_dv_ag_cc'])
+ vals['carteira_numero'] = int(carteira)
+ vals['nosso_numero'] = int(nosso_numero)
+ vals['nosso_numero_dv'] = int(digito)
+
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
+ # CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
new file mode 100644
index 000000000000..cd8a3a541986
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
@@ -0,0 +1,59 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Gustavo Lepri
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from ..cnab_240 import Cnab240
+
+
+class Santander240(Cnab240):
+ """
+
+ """
+
+ def __init__(self):
+ """
+
+ :return:
+ """
+ super(Cnab240, self).__init__()
+ from cnab240.bancos import santander
+ self.bank = santander
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+ vals = super(Santander240, self)._prepare_header()
+ del vals['arquivo_hora_de_geracao']
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Santander240, self)._prepare_cobranca(line)
+ return vals
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
new file mode 100644
index 000000000000..e9e91468814e
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -0,0 +1,570 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from __future__ import division, print_function, unicode_literals
+
+import datetime
+import logging
+import re
+import string
+import time
+import unicodedata
+from decimal import Decimal
+
+from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
+
+from ..cnab import Cnab
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.tipos import Arquivo, Lote
+except ImportError as err:
+ _logger.debug = err
+
+
+class Cnab240(Cnab):
+ """
+ CNAB240
+ """
+
+ def __init__(self):
+ super(Cnab, self).__init__()
+
+ @staticmethod
+ def get_bank(bank):
+ '''
+ Função chamada na criação do CNAB que dado o código do banco,
+ instancia o objeto do banco e retorna o obj ao CNAB que sera criado.
+ :param bank: str - Código do banco
+ :return:
+ '''
+ if bank == '341':
+ from .bancos.itau import Itau240
+ return Itau240
+ elif bank == '237':
+ from .bancos.bradesco import Bradesco240
+ return Bradesco240
+ elif bank == '104':
+ from .bancos.cef import Cef240
+ return Cef240
+ elif bank == '033':
+ from .bancos.santander import Santander240
+ return Santander240
+ elif bank == '001':
+ from .bancos.bb import BB240
+ return BB240
+ else:
+ return Cnab240
+
+ def get_inscricao_tipo(self, partner_id):
+ # TODO: Implementar codigo para PIS/PASEP
+ if partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_header(self):
+ """
+ Preparar o header do arquivo do CNAB
+ :return: dict - Header do arquivo
+ """
+ header_arquivo = {
+ # CONTROLE
+ # 01.0
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.0 # Sequencia para o Arquivo
+ 'controle_lote': 1,
+ # 03.0 0- Header do Arquivo
+ 'controle_registro': 0,
+ # 04.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+
+ # EMPRESA
+ # 05.0 - 1 - CPF / 2 - CNPJ
+ 'cedente_inscricao_tipo':
+ self.get_inscricao_tipo(self.order.company_id.partner_id),
+ # 06.0
+ 'cedente_inscricao_numero':
+ int(punctuation_rm(self.order.company_id.cnpj_cpf)),
+ # 07.0
+ 'cedente_convenio': '0001222130126',
+ # 08.0
+ 'cedente_agencia':
+ int(self.order.mode.bank_id.bra_number),
+ # 09.0
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ # 10.0
+ 'cedente_conta':
+ int(punctuation_rm(self.order.mode.bank_id.acc_number)),
+ # 11.0
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ # 12.0
+ 'cedente_agencia_conta_dv':
+ self.order.mode.bank_id.acc_number_dig[1]
+ if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ # 13.0
+ 'cedente_nome':
+ self.order.mode.bank_id.partner_id.legal_name[:30]
+ if self.order.mode.bank_id.partner_id.legal_name
+ else self.order.mode.bank_id.partner_id.name[:30],
+ # 14.0
+ 'nome_banco': self.order.mode.bank_id.bank_name,
+ # 15.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+
+ # ARQUIVO
+ # 16.0 Código Remessa = 1 / Retorno = 2
+ 'arquivo_codigo': '1',
+ # 17.0
+ 'arquivo_data_de_geracao': self.data_hoje(),
+ # 18.0
+ 'arquivo_hora_de_geracao': self.hora_agora(),
+ # 19.0 TODO: Número sequencial de arquivo
+ 'arquivo_sequencia': int(self.get_file_numeration()),
+ # 20.0
+ 'arquivo_layout': 103,
+ # 21.0
+ 'arquivo_densidade': 0,
+ # 22.0
+ 'reservado_banco': '',
+ # 23.0
+ 'reservado_empresa': 'EMPRESA 100',
+ # 24.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+ }
+
+ return header_arquivo
+
+ def _prepare_header_lote(self):
+ """
+ Preparar o header de LOTE para arquivo do CNAB
+ :return: dict - Header do arquivo
+ """
+ empresa = self.order.mode.bank_id.partner_id
+
+ header_arquivo_lote = {
+
+ # CONTROLE
+ # 01.1
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.1 Sequencia para o Arquivo
+ 'controle_lote': 1,
+ # 03.1 0- Header do Arquivo
+ 'controle_registro': 1,
+
+ # SERVICO
+ # 04.1 # Header do lote sempre 'C'
+ 'servico_operacao': 'C',
+ # 05.1
+ 'servico_servico': self.order.tipo_servico,
+ # 06.1
+ 'servico_forma_lancamento': 1,
+ # 07.1
+ 'servico_layout': 20,
+ # 08.1
+ # CNAB - Uso Exclusivo da FEBRABAN/CNAB
+
+ # EMPRESA CEDENTE
+ # 09.1
+ 'empresa_inscricao_tipo': 2,
+ # self.get_inscricao_tipo(self.order.company_id.partner_id),
+ # 10.1
+ 'empresa_inscricao_numero': punctuation_rm(empresa.cnpj_cpf),
+ # 11.1
+ 'cedente_convenio': self.order.codigo_convenio,
+ # 12.1
+ 'cedente_agencia':
+ int(self.order.mode.bank_id.bra_number),
+ # 13.1
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ # 14.1
+ 'cedente_conta':
+ int(punctuation_rm(self.order.mode.bank_id.acc_number)),
+ # 15.1
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ # 16.1
+ 'cedente_agencia_conta_dv':
+ self.order.mode.bank_id.acc_number_dig[1]
+ if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ # 17.1
+ 'cedente_nome':
+ self.order.mode.bank_id.partner_id.legal_name[:30]
+ if self.order.mode.bank_id.partner_id.legal_name
+ else self.order.mode.bank_id.partner_id.name[:30],
+ # 18.1
+ 'mensagem1': '',
+
+ # ENDERECO
+ # 19.1
+ 'empresa_logradouro': empresa.street,
+ # 20.1
+ 'empresa_endereco_numero': empresa.number,
+ # 21.1
+ 'empresa_endereco_complemento': empresa.street2,
+ # 22.1
+ 'empresa_endereco_cidade': empresa.l10n_br_city_id.name,
+ # 23.1
+ 'empresa_endereco_cep': self.get_cep('prefixo', empresa.zip),
+ # 24.1
+ 'empresa_endereco_cep_complemento':
+ self.get_cep('sufixo', empresa.zip),
+ # 25.1
+ 'empresa_endereco_estado': empresa.state_id.code,
+
+ # 26.1
+ 'indicativo_forma_pagamento': '',
+ # 27.1
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+ # 28.1
+ 'ocorrencias': '',
+ }
+ return header_arquivo_lote
+
+ def get_file_numeration(self):
+ # Função para retornar a numeração sequencial do arquivo
+ return 1
+
+ def _prepare_cobranca(self, line):
+ """
+ :param line:
+ :return:
+ """
+ # prefixo, sufixo = self.cep(line.partner_id.zip)
+
+ aceite = u'N'
+ if not self.order.mode.boleto_aceite == 'S':
+ aceite = u'A'
+
+ # Código agencia do cedente
+ # cedente_agencia = cedente_agencia
+
+ # Dígito verificador da agência do cedente
+ # cedente_agencia_conta_dv = cedente_agencia_dv
+
+ # Código da conta corrente do cedente
+ # cedente_conta = cedente_conta
+
+ # Dígito verificador da conta corrente do cedente
+ # cedente_conta_dv = cedente_conta_dv
+
+ # Dígito verificador de agencia e conta
+ # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
+
+ return {
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'identificacao_titulo': u'0000000', # TODO
+ 'identificacao_titulo_banco': u'0000000', # TODO
+ 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
+ 'numero_documento': line.name,
+ 'vencimento_titulo': self.format_date(
+ line.ml_maturity_date),
+ 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+ # TODO: fépefwfwe
+ # TODO: Código adotado para identificar o título de cobrança.
+ # 8 é Nota de cŕedito comercial
+ 'especie_titulo': int(self.order.mode.boleto_especie),
+ 'aceite_titulo': aceite,
+ 'data_emissao_titulo': self.format_date(
+ line.ml_date_created),
+ # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
+ # CEF/FEBRABAN e Itaú não tem.
+ 'juros_mora_data': self.format_date(
+ line.ml_maturity_date),
+ 'juros_mora_taxa_dia': Decimal('0.00'),
+ 'valor_abatimento': Decimal('0.00'),
+ 'sacado_inscricao_tipo': int(
+ self.get_inscricao_tipo(line.partner_id)),
+ 'sacado_inscricao_numero': int(
+ self.rmchar(line.partner_id.cnpj_cpf)),
+ 'sacado_nome': line.partner_id.legal_name,
+ 'sacado_endereco': (
+ line.partner_id.street + ' ' + line.partner_id.number),
+ 'sacado_bairro': line.partner_id.district,
+ 'sacado_cep': self.get_cep('prefixo', line.partner_id.zip),
+ 'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
+ 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
+ 'sacado_uf': line.partner_id.state_id.code,
+ 'codigo_protesto': int(self.order.mode.boleto_protesto),
+ 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
+ 'codigo_baixa': 2,
+ 'prazo_baixa': 0, # De 5 a 120 dias.
+ 'controlecob_data_gravacao': self.data_hoje(),
+ 'cobranca_carteira': int(self.order.mode.boleto_carteira),
+ }
+
+ def _prepare_pagamento(self, line):
+ """
+ Prepara um dict para preencher os valores do segmento A e B apartir de
+ uma linha da payment.order e insere informações que irão compor o
+ header do lote
+ :param line: payment.line - linha que sera base para evento
+ :return: dict - Dict contendo todas informações dos segmentos
+ """
+ vals = {
+
+ # SEGMENTO A
+ # CONTROLE
+ # 01.3A
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.3A
+ 'controle_lote': 1,
+ # 03.3A - 3-Registros Iniciais do Lote
+ 'controle_registro': 3,
+
+ # SERVICO
+ # 04.3A - Nº Seqüencial do Registro - Inicia em 1 em cada novo lote
+ # TODO: Contador para o sequencial do lote
+ 'servico_numero_registro': 1,
+ # 05.3A
+ # Segmento Código de Segmento do Reg.Detalhe
+ # 06.3A
+ 'servico_tipo_movimento': self.order.tipo_movimento,
+ # 07.3A
+ 'servico_codigo_movimento': self.order.codigo_instrucao_movimento,
+
+ # FAVORECIDO
+ # 08.3A - 018-TED 700-DOC
+ 'favorecido_camara': 0,
+ # 09.3A
+ 'favorecido_banco': int(line.bank_id.bank_bic),
+ # 10.3A
+ 'favorecido_agencia': int(line.bank_id.bra_number),
+ # 11.3A
+ 'favorecido_agencia_dv': line.bank_id.bra_number_dig,
+ # 12.3A
+ 'favorecido_conta': punctuation_rm(line.bank_id.acc_number),
+ # 13.3A
+ 'favorecido_conta_dv': line.bank_id.acc_number_dig[0]
+ if line.bank_id.acc_number_dig else '',
+ # 14.3A
+ 'favorecido_dv': line.bank_id.acc_number_dig[1]
+ if len(line.bank_id.bra_number_dig or '') > 1 else '',
+ # 15.3A
+ 'favorecido_nome': line.partner_id.name,
+
+ # CREDITO
+ # 16.3A -
+ 'credito_seu_numero': line.name,
+ # 17.3A
+ 'credito_data_pagamento': self.format_date(line.date),
+ # 18.3A
+ 'credito_moeda_tipo': line.currency.name,
+ # 19.3A
+ 'credito_moeda_quantidade': Decimal('0.00000'),
+ # 20.3A
+ 'credito_valor_pagamento':
+ Decimal(str(line.amount_currency)).quantize(Decimal('1.00')),
+ # 21.3A
+ # 'credito_nosLoteso_numero': '',
+ # 22.3A
+ # 'credito_data_real': '',
+ # 23.3A
+ # 'credito_valor_real': '',
+
+ # INFORMAÇÔES
+ # 24.3A
+ # 'outras_informacoes': '',
+ # 25.3A
+ # 'codigo_finalidade_doc': line.codigo_finalidade_doc,
+ # 26.3A
+ 'codigo_finalidade_ted': line.codigo_finalidade_ted or '',
+ # 27.3A
+ 'codigo_finalidade_complementar':
+ line.codigo_finalidade_complementar or '',
+ # 28.3A
+ # CNAB - Uso Exclusivo FEBRABAN/CNAB
+ # 29.3A
+ # 'aviso_ao_favorecido': line.aviso_ao_favorecido,
+ 'aviso_ao_favorecido': 0,
+ # 'ocorrencias': '',
+
+ # SEGMENTO B
+ # Preenchido no segmento A
+ # 01.3B
+ # 02.3B
+ # 03.3B
+
+ # 04.3B
+ # 05.3B
+ # 06.3B
+
+ # DADOS COMPLEMENTARES - FAVORECIDOS
+ # 07.3B
+ 'favorecido_tipo_inscricao':
+ self.get_inscricao_tipo(line.partner_id),
+ # 08.3B
+ 'favorecido_num_inscricao':
+ int(punctuation_rm(line.partner_id.cnpj_cpf)),
+ # 09.3B
+ 'favorecido_endereco_rua': line.partner_id.street or '',
+ # 10.3B
+ 'favorecido_endereco_num': int(line.partner_id.number) or 0,
+ # 11.3B
+ 'favorecido_endereco_complemento': line.partner_id.street2 or '',
+ # 12.3B
+ 'favorecido_endereco_bairro': line.partner_id.district or '',
+ # 13.3B
+ 'favorecido_endereco_cidade':
+ line.partner_id.l10n_br_city_id.name or '',
+ # 14.3B
+ # 'favorecido_cep': int(line.partner_id.zip[:5]) or 0,
+ 'favorecido_cep': self.get_cep('prefixo', line.partner_id.zip),
+ # 15.3B
+ 'favorecido_cep_complemento':
+ self.get_cep('sufixo', line.partner_id.zip),
+ # 16.3B
+ 'favorecido_estado': line.partner_id.state_id.code or '',
+
+ # DADOS COMPLEMENTARES - PAGAMENTO
+ # 17.3B
+ 'pagamento_vencimento': 0,
+ # 18.3B
+ 'pagamento_valor_documento': Decimal('0.00'),
+ # 19.3B
+ 'pagamento_abatimento': Decimal('0.00'),
+ # 20.3B
+ 'pagamento_desconto': Decimal('0.00'),
+ # 21.3B
+ 'pagamento_mora': Decimal('0.00'),
+ # 22.3B
+ 'pagamento_multa': Decimal('0.00'),
+ # 23.3B
+ # TODO: Verificar se este campo é retornado no retorno
+ # 'cod_documento_favorecido': '',
+ # 24.3B - Informado No SegmentoA
+ # 'aviso_ao_favorecido': '0',
+ # 25.3B
+ # 'codigo_ug_centralizadora': '0',
+ # 26.3B
+ # 'codigo_ispb': '0',
+ }
+ return vals
+
+ def _adicionar_evento(self, line):
+ """
+ Adicionar o evento no arquivo de acordo com seu tipo
+ """
+ # if self.order.payment_order_type == 'payment':
+ # incluir = self.arquivo.incluir_debito_pagamento
+ # prepare = self._prepare_pagamento
+ # else:
+ # incluir = self.arquivo.incluir_cobranca
+ # prepare = self._prepare_cobranca
+ pass
+
+ def remessa(self, order):
+ """
+ Cria a remessa de eventos que sera anexada ao arquivo
+ :param order: payment.order
+ :return: Arquivo Cnab pronto para download
+ """
+ # cobrancasimples_valor_titulos = 0
+
+ self.order = order
+
+ # Preparar Header do Arquivo
+ self.arquivo = Arquivo(self.bank, **self._prepare_header())
+
+ if order.payment_order_type == 'payment':
+ incluir = self.arquivo.incluir_debito_pagamento
+ prepare = self._prepare_pagamento
+
+ header = self.bank.registros.HeaderLotePagamento(
+ **self._prepare_header_lote())
+
+ trailer = self.bank.registros.TrailerLotePagamento()
+ trailer.somatoria_valores = Decimal('0.00')
+ trailer.somatoria_quantidade_moedas = Decimal('0.00000')
+
+ lote_pagamento = Lote(self.bank, header, trailer)
+ self.arquivo.adicionar_lote(lote_pagamento)
+
+ else:
+ incluir = self.arquivo.incluir_cobranca
+ prepare = self._prepare_cobranca
+
+ for line in order.bank_line_ids:
+ # para cada linha da payment order adicoinar como um novo evento
+ # self._adicionar_evento(line)
+ # try:
+ incluir(tipo_lote=30, **prepare(line))
+ # except:
+ # from openerp import exceptions
+ # raise exceptions.ValidationError("Erro")
+ # self.arquivo.lotes[0].header.servico_servico = 30
+ # TODO: tratar soma de tipos de cobranca
+ # cobrancasimples_valor_titulos += line.amount_currency
+ # self.arquivo.lotes[0].trailer.cobrancasimples_valor_titulos = \
+ # Decimal(cobrancasimples_valor_titulos).quantize(
+ # Decimal('1.00'))
+
+ remessa = unicode(self.arquivo)
+ return unicodedata.normalize('NFKD', remessa).encode('ascii', 'ignore')
+
+ def get_cep(self, tipo, value):
+ '''
+ :param tipo:
+ :param value:
+ :return:
+ '''
+ if not value:
+ if tipo == 'prefixo':
+ return 0
+ else:
+ return ''
+ value = punctuation_rm(value)
+ sufixo = value[-3:]
+ prefixo = value[:5]
+ if tipo == 'sufixo':
+ return sufixo
+ else:
+ return prefixo
+
+ def format_date(self, srt_date):
+ if not srt_date:
+ return 0
+ return int(datetime.datetime.strptime(
+ srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
+
+ def data_hoje(self):
+ return (int(time.strftime("%d%m%Y")))
+
+ def hora_agora(self):
+ return (int(time.strftime("%H%M%S")))
+
+ def rmchar(self, format):
+ return re.sub('[%s]' % re.escape(string.punctuation), '',
+ format or '')
+
+ def nosso_numero(self, format):
+ """
+ Hook para ser sobrescrito e adicionar informação
+ :param format:
+ :return:
+ """
+ pass
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
new file mode 100644
index 000000000000..1fabc0a2c0b9
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
@@ -0,0 +1,566 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from __future__ import division, print_function, unicode_literals
+
+import datetime
+import logging
+import re
+import string
+import time
+import unicodedata
+from decimal import Decimal
+
+from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
+
+from ..cnab import Cnab
+
+_logger = logging.getLogger(__name__)
+try:
+<<<<<<< HEAD
+ from cnab240.tipos import Arquivo
+ from cnab240.errors import (Cnab240Error)
+=======
+ from cnab240.tipos import Arquivo, Lote
+>>>>>>> fixup! [FIX] Flake8
+except ImportError as err:
+ _logger.debug = err
+
+
+class Cnab240(Cnab):
+ """
+ CNAB240
+ """
+
+ def __init__(self):
+ super(Cnab, self).__init__()
+
+ @staticmethod
+ def get_bank(bank):
+ '''
+ Função chamada na criação do CNAB que dado o código do banco,
+ instancia o objeto do banco e retorna o obj ao CNAB que sera criado.
+ :param bank: str - Código do banco
+ :return:
+ '''
+ if bank == '341':
+ from .bancos.itau import Itau240
+ return Itau240
+ elif bank == '237':
+ from .bancos.bradesco import Bradesco240
+ return Bradesco240
+ elif bank == '104':
+ from .bancos.cef import Cef240
+ return Cef240
+ elif bank == '033':
+ from .bancos.santander import Santander240
+ return Santander240
+ elif bank == '001':
+ from .bancos.bb import BB240
+ return BB240
+ else:
+ return Cnab240
+
+ def inscricao_tipo(self, partner_id):
+ # TODO: Implementar codigo para PIS/PASEP
+ if partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_header(self):
+ """
+ Preparar o header do arquivo do CNAB
+ :return: dict - Header do arquivo
+ """
+ header_arquivo = {
+ # CONTROLE
+ # 01.0
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.0 # Sequencia para o Arquivo
+ 'controle_lote': 1,
+ # 03.0 0- Header do Arquivo
+ 'controle_registro': 0,
+ # 04.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+
+ # EMPRESA
+ # 05.0 - 1 - CPF / 2 - CNPJ
+ 'cedente_inscricao_tipo':
+ self.get_inscricao_tipo(self.order.company_id.partner_id),
+ # 06.0
+ 'cedente_inscricao_numero':
+ int(punctuation_rm(self.order.company_id.cnpj_cpf)),
+ # 07.0
+ 'cedente_convenio': '0001222130126',
+ # 08.0
+ 'cedente_agencia':
+ int(self.order.mode.bank_id.bra_number),
+ # 09.0
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ # 10.0
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ # 11.0
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ # 12.0
+ 'cedente_agencia_conta_dv':
+ self.order.mode.bank_id.acc_number_dig[1]
+ if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ # 13.0
+ 'cedente_nome':
+ self.order.mode.bank_id.partner_id.legal_name[:30],
+ # 14.0
+ 'nome_banco': self.order.mode.bank_id.bank_name,
+ # 15.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+
+ # ARQUIVO
+ # 16.0 Código Remessa = 1 / Retorno = 2
+ 'arquivo_codigo': '1',
+ # 17.0
+ 'arquivo_data_de_geracao': self.data_hoje(),
+ # 18.0
+ 'arquivo_hora_de_geracao': self.hora_agora(),
+ # 19.0 TODO: Número sequencial de arquivo
+ 'arquivo_sequencia': int(self.get_file_numeration()),
+ # 20.0
+ 'arquivo_layout': 103,
+ # 21.0
+ 'arquivo_densidade': 0,
+ # 22.0
+ 'reservado_banco': '',
+ # 23.0
+ 'reservado_empresa': 'EMPRESA 100',
+ # 24.0
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+ }
+
+ return header_arquivo
+
+ def _prepare_header_lote(self):
+ """
+ Preparar o header de LOTE para arquivo do CNAB
+ :return: dict - Header do arquivo
+ """
+ empresa = self.order.mode.bank_id.partner_id
+
+ header_arquivo_lote = {
+
+ # CONTROLE
+ # 01.1
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.1 Sequencia para o Arquivo
+ 'controle_lote': 1,
+ # 03.1 0- Header do Arquivo
+ 'controle_registro': 1,
+
+ # SERVICO
+ # 04.1 # Header do lote sempre 'C'
+ 'servico_operacao': 'C',
+ # 05.1
+ 'servico_servico': self.order.tipo_servico,
+ # 06.1
+ 'servico_forma_lancamento': 1,
+ # 07.1
+ 'servico_layout': 20,
+ # 08.1
+ # CNAB - Uso Exclusivo da FEBRABAN/CNAB
+
+ # EMPRESA CEDENTE
+ # 09.1
+ 'empresa_inscricao_tipo': 2,
+ # self.get_inscricao_tipo(self.order.company_id.partner_id),
+ # 10.1
+ 'empresa_inscricao_numero': punctuation_rm(empresa.cnpj_cpf),
+ # 11.1
+ 'cedente_convenio': self.order.codigo_convenio,
+ # 12.1
+ 'cedente_agencia':
+ int(self.order.mode.bank_id.bra_number),
+ # 13.1
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ # 14.1
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ # 15.1
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ # 16.1
+ 'cedente_agencia_conta_dv':
+ self.order.mode.bank_id.acc_number_dig[1]
+ if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ # 17.1
+ 'cedente_nome':
+ self.order.mode.bank_id.partner_id.legal_name[:30],
+ # 18.1
+ 'mensagem1': '',
+
+ # ENDERECO
+ # 19.1
+ 'empresa_logradouro': empresa.street,
+ # 20.1
+ 'empresa_endereco_numero': empresa.number,
+ # 21.1
+ 'empresa_endereco_complemento': empresa.street2,
+ # 22.1
+ 'empresa_endereco_cidade': empresa.l10n_br_city_id.name,
+ # 23.1
+ 'empresa_endereco_cep': self.get_cep('prefixo', empresa.zip),
+ # 24.1
+ 'empresa_endereco_cep_complemento':
+ self.get_cep('sufixo', empresa.zip),
+ # 25.1
+ 'empresa_endereco_estado': empresa.state_id.code,
+
+ # 26.1
+ 'indicativo_forma_pagamento': '',
+ # 27.1
+ # CNAB - Uso Exclusivo FEBRABAN / CNAB
+ # 28.1
+ 'ocorrencias': '',
+ }
+ return header_arquivo_lote
+
+ def get_file_numeration(self):
+ # Função para retornar a numeração sequencial do arquivo
+ return 1
+
+ def sacado_inscricao_tipo(self, partner_id):
+ # TODO: Implementar codigo para PIS/PASEP
+ if partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_cobranca(self, line):
+ """
+ :param line:
+ :return:
+ """
+ # prefixo, sulfixo = self.cep(line.partner_id.zip)
+
+ aceite = u'N'
+ if not self.order.mode.boleto_aceite == 'S':
+ aceite = u'A'
+
+ # Código agencia do cedente
+ # cedente_agencia = cedente_agencia
+
+ # Dígito verificador da agência do cedente
+ # cedente_agencia_conta_dv = cedente_agencia_dv
+
+ # Código da conta corrente do cedente
+ # cedente_conta = cedente_conta
+
+ # Dígito verificador da conta corrente do cedente
+ # cedente_conta_dv = cedente_conta_dv
+
+ # Dígito verificador de agencia e conta
+ # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
+
+ return {
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'identificacao_titulo': u'0000000', # TODO
+ 'identificacao_titulo_banco': u'0000000', # TODO
+ 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
+ 'numero_documento': line.name,
+ 'vencimento_titulo': self.format_date(
+ line.ml_maturity_date),
+ 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+ # TODO: fépefwfwe
+ # TODO: Código adotado para identificar o título de cobrança.
+ # 8 é Nota de cŕedito comercial
+ 'especie_titulo': int(self.order.mode.boleto_especie),
+ 'aceite_titulo': aceite,
+ 'data_emissao_titulo': self.format_date(
+ line.ml_date_created),
+ # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
+ # CEF/FEBRABAN e Itaú não tem.
+ 'juros_mora_data': self.format_date(
+ line.ml_maturity_date),
+ 'juros_mora_taxa_dia': Decimal('0.00'),
+ 'valor_abatimento': Decimal('0.00'),
+ 'sacado_inscricao_tipo': int(
+ self.sacado_inscricao_tipo(line.partner_id)),
+ 'sacado_inscricao_numero': int(
+ self.rmchar(line.partner_id.cnpj_cpf)),
+ 'sacado_nome': line.partner_id.legal_name,
+ 'sacado_endereco': (
+ line.partner_id.street + ' ' + line.partner_id.number),
+ 'sacado_bairro': line.partner_id.district,
+ 'sacado_cep': int(prefixo),
+ 'sacado_cep_sufixo': int(sulfixo),
+ 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
+ 'sacado_uf': line.partner_id.state_id.code,
+ 'codigo_protesto': int(self.order.mode.boleto_protesto),
+ 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
+ 'codigo_baixa': 2,
+ 'prazo_baixa': 0, # De 5 a 120 dias.
+ 'controlecob_data_gravacao': self.data_hoje(),
+ 'cobranca_carteira': int(self.order.mode.boleto_carteira),
+ }
+
+ def _prepare_pagamento(self, line):
+ """
+ Prepara um dict para preencher os valores do segmento A e B apartir de
+ uma linha da payment.order e insere informações que irão compor o
+ header do lote
+ :param line: payment.line - linha que sera base para evento
+ :return: dict - Dict contendo todas informações dos segmentos
+ """
+ vals = {
+
+ # SEGMENTO A
+ # CONTROLE
+ # 01.3A
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ # 02.3A
+ 'controle_lote': 1,
+ # 03.3A - 3-Registros Iniciais do Lote
+ 'controle_registro': 3,
+
+ # SERVICO
+ # 04.3A - Nº Seqüencial do Registro - Inicia em 1 em cada novo lote
+ # TODO: Contador para o sequencial do lote
+ 'servico_numero_registro': 1,
+ # 05.3A
+ # Segmento Código de Segmento do Reg.Detalhe
+ # 06.3A
+ 'servico_tipo_movimento': self.order.tipo_movimento,
+ # 07.3A
+ 'servico_codigo_movimento': self.order.codigo_instrucao_movimento,
+
+ # FAVORECIDO
+ # 08.3A - 018-TED 700-DOC
+ 'favorecido_camara': 0,
+ # 09.3A
+ 'favorecido_banco': int(line.bank_id.bank_bic),
+ # 10.3A
+ 'favorecido_agencia': int(line.bank_id.bra_number),
+ # 11.3A
+ 'favorecido_agencia_dv': line.bank_id.bra_number_dig,
+ # 12.3A
+ 'favorecido_conta': punctuation_rm(line.bank_id.acc_number),
+ # 13.3A
+ 'favorecido_conta_dv': line.bank_id.acc_number_dig[0]
+ if line.bank_id.acc_number_dig else '',
+ # 14.3A
+ 'favorecido_dv': line.bank_id.acc_number_dig[1]
+ if len(line.bank_id.bra_number_dig or '') > 1 else '',
+ # 15.3A
+ 'favorecido_nome': line.partner_id.name,
+
+ # CREDITO
+ # 16.3A -
+ 'credito_seu_numero': line.name,
+ # 17.3A
+ 'credito_data_pagamento': self.format_date(line.date),
+ # 18.3A
+ 'credito_moeda_tipo': line.currency.name,
+ # 19.3A
+ 'credito_moeda_quantidade': Decimal('0.00000'),
+ # 20.3A
+ 'credito_valor_pagamento':
+ Decimal(str(line.amount_currency)).quantize(Decimal('1.00')),
+ # 21.3A
+ # 'credito_nosLoteso_numero': '',
+ # 22.3A
+ # 'credito_data_real': '',
+ # 23.3A
+ # 'credito_valor_real': '',
+
+ # INFORMAÇÔES
+ # 24.3A
+ # 'outras_informacoes': '',
+ # 25.3A
+ # 'codigo_finalidade_doc': line.codigo_finalidade_doc,
+ # 26.3A
+ 'codigo_finalidade_ted': line.codigo_finalidade_ted or '',
+ # 27.3A
+ 'codigo_finalidade_complementar':
+ line.codigo_finalidade_complementar or '',
+ # 28.3A
+ # CNAB - Uso Exclusivo FEBRABAN/CNAB
+ # 29.3A
+ # 'aviso_ao_favorecido': line.aviso_ao_favorecido,
+ 'aviso_ao_favorecido': 0,
+ # 'ocorrencias': '',
+
+ # SEGMENTO B
+ # Preenchido no segmento A
+ # 01.3B
+ # 02.3B
+ # 03.3B
+
+ # 04.3B
+ # 05.3B
+ # 06.3B
+
+ # DADOS COMPLEMENTARES - FAVORECIDOS
+ # 07.3B
+ 'favorecido_tipo_inscricao':
+ self.get_inscricao_tipo(line.partner_id),
+ # 08.3B
+ 'favorecido_num_inscricao':
+ int(punctuation_rm(line.partner_id.cnpj_cpf)),
+ # 09.3B
+ 'favorecido_endereco_rua': line.partner_id.street or '',
+ # 10.3B
+ 'favorecido_endereco_num': int(line.partner_id.number) or 0,
+ # 11.3B
+ 'favorecido_endereco_complemento': line.partner_id.street2 or '',
+ # 12.3B
+ 'favorecido_endereco_bairro': line.partner_id.district or '',
+ # 13.3B
+ 'favorecido_endereco_cidade':
+ line.partner_id.l10n_br_city_id.name or '',
+ # 14.3B
+ # 'favorecido_cep': int(line.partner_id.zip[:5]) or 0,
+ 'favorecido_cep': self.get_cep('prefixo', line.partner_id.zip),
+ # 15.3B
+ 'favorecido_cep_complemento':
+ self.get_cep('sufixo', line.partner_id.zip),
+ # 16.3B
+ 'favorecido_estado': line.partner_id.state_id.code or '',
+
+ # DADOS COMPLEMENTARES - PAGAMENTO
+ # 17.3B
+ 'pagamento_vencimento': 0,
+ # 18.3B
+ 'pagamento_valor_documento': Decimal('0.00'),
+ # 19.3B
+ 'pagamento_abatimento': Decimal('0.00'),
+ # 20.3B
+ 'pagamento_desconto': Decimal('0.00'),
+ # 21.3B
+ 'pagamento_mora': Decimal('0.00'),
+ # 22.3B
+ 'pagamento_multa': Decimal('0.00'),
+ # 23.3B
+ # TODO: Verificar se este campo é retornado no retorno
+ # 'cod_documento_favorecido': '',
+ # 24.3B - Informado No SegmentoA
+ # 'aviso_ao_favorecido': '0',
+ # 25.3B
+ # 'codigo_ug_centralizadora': '0',
+ # 26.3B
+ # 'codigo_ispb': '0',
+ }
+ return vals
+
+ def _adicionar_evento(self, line):
+ """
+ Adicionar o evento no arquivo de acordo com seu tipo
+ """
+ # if self.order.payment_order_type == 'payment':
+ # incluir = self.arquivo.incluir_debito_pagamento
+ # prepare = self._prepare_pagamento
+ # else:
+ # incluir = self.arquivo.incluir_cobranca
+ # prepare = self._prepare_cobranca
+ pass
+
+ def remessa(self, order):
+ """
+ Cria a remessa de eventos que sera anexada ao arquivo
+ :param order: payment.order
+ :return: Arquivo Cnab pronto para download
+ """
+ # cobrancasimples_valor_titulos = 0
+
+ self.order = order
+
+ # Preparar Header do Arquivo
+ self.arquivo = Arquivo(self.bank, **self._prepare_header())
+
+ if order.payment_order_type == 'payment':
+ incluir = self.arquivo.incluir_debito_pagamento
+ prepare = self._prepare_pagamento
+ else:
+ incluir = self.arquivo.incluir_cobranca
+ prepare = self._prepare_cobranca
+
+ for line in order.bank_line_ids:
+ # para cada linha da payment order adicoinar como um novo evento
+ # self._adicionar_evento(line)
+ # try:
+ incluir(**prepare(line))
+ # except:
+ # from openerp import exceptions
+ # raise exceptions.ValidationError("Erro")
+ self.arquivo.lotes[0].header.servico_servico = 1
+ # TODO: tratar soma de tipos de cobranca
+ # cobrancasimples_valor_titulos += line.amount_currency
+ # self.arquivo.lotes[0].trailer.cobrancasimples_valor_titulos = \
+ # Decimal(cobrancasimples_valor_titulos).quantize(
+ # Decimal('1.00'))
+
+ remessa = unicode(self.arquivo)
+ return unicodedata.normalize(
+ 'NFKD', remessa).encode('ascii', 'ignore')
+
+ def get_cep(self, tipo, value):
+ '''
+ :param tipo:
+ :param value:
+ :return:
+ '''
+ if not value:
+ if tipo == 'prefixo':
+ return 0
+ else:
+ return ''
+ value = punctuation_rm(value)
+ sulfixo = format[-3:]
+ prefixo = format[:5]
+ if tipo == 'sulfixo':
+ return sulfixo
+ else:
+ return prefixo
+
+ def format_date(self, srt_date):
+ if not srt_date:
+ return 0
+ return int(datetime.datetime.strptime(
+ srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
+
+ def data_hoje(self):
+ return (int(time.strftime("%d%m%Y")))
+
+ def hora_agora(self):
+ return (int(time.strftime("%H%M%S")))
+
+ def rmchar(self, format):
+ return re.sub('[%s]' % re.escape(string.punctuation), '',
+ format or '')
+
+ def nosso_numero(self, format):
+ """
+ Hook para ser sobrescrito e adicionar informação
+ :param format:
+ :return:
+ """
+ pass
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
new file mode 100644
index 000000000000..a0d383002be9
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
@@ -0,0 +1,19 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Ainda não implementado!
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
new file mode 100644
index 000000000000..cce59cd38e38
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
@@ -0,0 +1,20 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Fernando Marcato Rodrigues
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
new file mode 100644
index 000000000000..fa3cf04e70dc
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
@@ -0,0 +1,113 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+import re
+import string
+from decimal import Decimal
+
+from ..cnab_400 import Cnab400
+
+
+class Bradesco400(Cnab400):
+
+ def __init__(self):
+ super(Cnab400, self).__init__()
+ from cnab240.bancos import bradesco_cobranca_400
+ self.bank = bradesco_cobranca_400
+ self.controle_linha = 2
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+
+ vals = super(Bradesco400, self)._prepare_header()
+ vals['servico_servico'] = 1
+ return vals
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(Bradesco400, self)._prepare_cobranca(line)
+ vals['prazo_baixa'] = unicode(str(
+ vals['prazo_baixa']), "utf-8")
+ vals['desconto1_percentual'] = Decimal('0.00')
+ vals['valor_iof'] = Decimal('0.00')
+ # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
+ vals['identificacao_titulo_banco'] = int(
+ vals['identificacao_titulo_banco'])
+ vals['cedente_conta_dv'] = unicode(str(
+ vals['cedente_conta_dv']), "utf-8")
+ vals['cedente_agencia_dv'] = unicode(str(
+ vals['cedente_agencia_dv']), "utf-8")
+ vals['cedente_dv_ag_cc'] = unicode(str(
+ vals['cedente_dv_ag_cc']), "utf-8")
+
+ vals['sacado_cc_dv'] = u'0'
+ vals['identificacao_empresa_beneficiaria_banco'] = \
+ self.retorna_id_empr_benef()
+ vals['digito_conferencia_numero_bancario'] = u'0'
+ vals['condicao_emissao_papeleta'] = 1
+
+ vals['indicador_rateio_credito'] = u""
+ self.controle_linha += 1
+
+ return vals
+
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
+
+ def retorna_id_empr_benef(self):
+ dig_cart = 3
+ dig_ag = 5
+ dig_conta = 7
+
+ carteira = self.adiciona_digitos(
+ self.order.mode.boleto_carteira, dig_cart)
+ agencia = self.adiciona_digitos(
+ self.order.mode.bank_id.bra_number, dig_ag)
+ conta = self.adiciona_digitos(
+ self.order.mode.bank_id.acc_number, dig_conta)
+
+ ident = u'0' + (carteira) + (agencia) + (conta) + \
+ (self.order.mode.bank_id.acc_number_dig)
+ return ident
+
+ def adiciona_digitos(self, campo, num_digitos):
+ chars_faltantes = num_digitos - len(campo)
+ return (u'0' * chars_faltantes) + campo
+
+
+def str_to_unicode(inp_str):
+ inp_str = unicode(inp_str, "utf-8")
+ return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
new file mode 100644
index 000000000000..cb1e3d8f3629
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -0,0 +1,375 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Fernando Marcato Rodrigues
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import datetime
+import logging
+import re
+import string
+import time
+import unicodedata
+from decimal import Decimal
+
+from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
+
+from ..cnab import Cnab
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.tipos import ArquivoCobranca400
+except ImportError as err:
+ _logger.debug = (err)
+
+IDENTIFICACAO_DA_OCORRENCIA = [
+ ('01', u'Remessa'),
+ ('02', u'Pedido de baixa'),
+ ('03', u'Pedido de Protesto Falimentar'),
+ ('04', u'Concessão de abatimento'),
+ ('05', u'Cancelamento de abatimento concedido'),
+ ('06', u'Alteração de vencimento'),
+ ('07', u'Alteração do controle do participante'),
+ ('08', u'Alteração de seu número'),
+ ('09', u'Pedido de protesto'),
+ ('18', u'Sustar protesto e baixar Título'),
+ ('19', u'Sustar protesto e manter em carteira'),
+ ('22', u'Transferência Cessão crédito ID. Prod.10'),
+ ('23', u'Transferência entre Carteiras'),
+ ('24', u'Dev. Transferência entre Carteiras'),
+ ('31', u'Alteração de outros dados'),
+ ('45', u'Pedido de Negativação (NOVO)'),
+ ('46', u'Excluir Negativação com baixa (NOVO)'),
+ ('47', u'Excluir negativação e manter pendente (NOVO)'),
+ ('68', u'Acerto nos dados do rateio de Crédito'),
+ ('69', u'Cancelamento do rateio de crédito'),
+]
+
+ESPECIE_DE_TITULO = [
+ ('01', u'Duplicata'),
+ ('02', u'Nota Promissória'),
+ ('03', u'Nota de Seguro'),
+ ('04', u'Cobrança Seriada'),
+ ('05', u'Recibo'),
+ ('10', u'Letras de Câmbio'),
+ ('11', u'Nota de Débito'),
+ ('12', u'Duplicata de Serv'),
+ ('30', u'Boleto de Proposta'),
+ ('99', u'Outros'),
+]
+
+# Essas instruções deverão ser enviadas no Arquivo-Remessa, quando da
+# entrada, desde que código de ocorrência na posição 109 a 110 do registro
+# de transação, seja “01”, para as instruções de protesto/negativação, o
+# CNPJ / CPF e o endereço do Pagador deverão ser informados corretamente
+LISTA_PRIMEIRA_INSTRUCAO = [
+ ('05', u'Protesto Falimentar'),
+ ('06', u'Protestar'),
+ ('07', u'Negativar'),
+ ('18', u'Decurso de prazo'),
+
+ ('08', u'Não cobrar juros de mora'),
+ ('09', u'Não receber após o vencimento'),
+ ('10', u'Multas de 10% após o 4o dia do Vencimento'),
+ ('11', u'Não receber após o 8o dia do vencimento.'),
+ ('12', u'Cobrar encargos após o 5o dia do vencimento'),
+ ('13', u'Cobrar encargos após o 10o dia do vencimento'),
+ ('14', u'Cobrar encargos após o 15o dia do vencimento'),
+ ('15', u'Conceder desconto mesmo se pago após o vencimento'),
+]
+
+
+class Cnab400(Cnab):
+
+ def __init__(self):
+ super(Cnab, self).__init__()
+
+ @staticmethod
+ def get_bank(bank):
+ if bank == '237':
+ from .bancos.bradesco import Bradesco400
+ return Bradesco400
+ else:
+ return Cnab400
+
+ @property
+ def inscricao_tipo(self):
+ # TODO: Implementar codigo para PIS/PASEP
+ if self.order.company_id.partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_header(self):
+ """
+
+ :param:
+ :return:
+ """
+ return {
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'arquivo_data_de_geracao': self.data_hoje(),
+ 'arquivo_hora_de_geracao': self.hora_agora(),
+ # TODO: Número sequencial de arquivo
+ 'arquivo_sequencia': int(self.get_file_numeration()),
+ 'cedente_inscricao_tipo': self.inscricao_tipo,
+ 'cedente_inscricao_numero': int(punctuation_rm(
+ self.order.company_id.cnpj_cpf)),
+ 'cedente_agencia': int(
+ self.order.mode.bank_id.bra_number),
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_conta_dv': (self.order.mode.bank_id.acc_number_dig),
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'cedente_nome': self.order.company_id.legal_name,
+ 'arquivo_codigo': 1, # Remessa/Retorno
+ 'servico_operacao': u'R',
+ 'nome_banco': unicode(self.order.mode.bank_id.bank_name),
+ 'codigo_empresa': int(self.order.mode.boleto_convenio),
+ }
+
+ def get_file_numeration(self):
+ numero = self.order.get_next_number()
+ if not numero:
+ numero = 1
+ return numero
+
+ def format_date(self, srt_date):
+ return int(datetime.datetime.strptime(
+ srt_date, '%Y-%m-%d').strftime('%d%m%y'))
+
+ def nosso_numero(self, format):
+ pass
+
+ def cep(self, format):
+ sulfixo = format[-3:]
+ prefixo = format[:5]
+ return prefixo, sulfixo
+
+ def sacado_inscricao_tipo(self, partner_id):
+ # TODO: Implementar codigo para PIS/PASEP
+ if partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def rmchar(self, format):
+ return re.sub('[%s]' % re.escape(string.punctuation), '',
+ format or '')
+
+ def codificar(self, texto):
+ return texto.encode('utf-8')
+
+ def _prepare_cobranca(self, line):
+ """
+ :param line:
+ :return:
+ """
+ prefixo, sulfixo = self.cep(line.partner_id.zip)
+
+ aceite = u'N'
+ if not self.order.mode.boleto_aceite == 'S':
+ aceite = u'A'
+
+ codigo_protesto = 0
+ dias_protestar = 0
+ if self.order.mode.boleto_protesto == '3' \
+ or self.order.mode.boleto_protesto == '0':
+ codigo_protesto = 0
+ dias_protestar = 0
+ elif self.order.mode.boleto_protesto == '1' \
+ or self.order.mode.boleto_protesto == '2':
+ codigo_protesto = 6
+ if (int(self.order.mode.boleto_protesto_prazo)) < 5:
+ dias_protestar = 5
+ else:
+ dias_protestar = int(self.order.mode.boleto_protesto_prazo)
+
+ sacado_endereco = self.retorna_endereco(line.partner_id.id)
+
+ # Código agencia do cedente
+ # cedente_agencia = cedente_agencia
+
+ # Dígito verificador da agência do cedente
+ # cedente_agencia_conta_dv = cedente_agencia_dv
+
+ # Código da conta corrente do cedente
+ # cedente_conta = cedente_conta
+
+ # Dígito verificador da conta corrente do cedente
+ # cedente_conta_dv = cedente_conta_dv
+
+ # Dígito verificador de agencia e conta
+ # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
+
+ return {
+
+ 'percentual_multa': Decimal('0.00'),
+ 'valor_desconto': Decimal('0.00'),
+ 'valor_abatimento_concedido_cancelado': Decimal('0.00'),
+ 'primeira_instrucao': codigo_protesto,
+ 'segunda_instrucao': dias_protestar,
+ 'sacado_cep': int(prefixo),
+ 'sacado_cep_sufixo': int(sulfixo),
+ 'sacador_avalista': self.order.mode.comunicacao_2,
+ # 'sacador_avalista': u'Protestar após 5 dias',
+ 'num_seq_registro': self.controle_linha,
+
+ 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
+ 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'identificacao_titulo': u'0000000', # TODO
+ 'identificacao_titulo_banco': u'0000000', # TODO
+ 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
+
+ 'vencimento_titulo': self.format_date(
+ line.ml_maturity_date),
+ 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+ # TODO: Código adotado para identificar o título de cobrança.
+ # 8 é Nota de cŕedito comercial
+ 'especie_titulo': int(self.order.mode.boleto_especie),
+ 'aceite_titulo': aceite,
+ 'data_emissao_titulo': self.format_date(
+ line.ml_date_created),
+ # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
+ # CEF/FEBRABAN e Itaú não tem.
+ 'juros_mora_data': self.format_date(
+ line.ml_maturity_date),
+
+ # 'juros_mora_taxa_dia': Decimal('0.20'),
+ 'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
+ line.amount_currency, line.percent_interest),
+
+ 'valor_abatimento': Decimal('0.00'),
+ 'sacado_inscricao_tipo': int(
+ self.sacado_inscricao_tipo(line.partner_id)),
+ 'sacado_inscricao_numero': int(
+ self.rmchar(line.partner_id.cnpj_cpf)),
+ 'sacado_nome': line.partner_id.legal_name,
+
+ # 'sacado_endereco': (
+ # line.partner_id.street +
+ # ' ' + str(line.partner_id.number)
+ # ),
+
+ 'sacado_endereco': sacado_endereco,
+
+ 'sacado_bairro': line.partner_id.district,
+ 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
+ 'sacado_uf': line.partner_id.state_id.code,
+ 'codigo_baixa': 2,
+ 'prazo_baixa': 0, # De 5 a 120 dias.
+ 'controlecob_data_gravacao': self.data_hoje(),
+ 'cobranca_carteira': int(self.order.mode.boleto_carteira),
+
+ 'primeira_mensagem': u'',
+ # Trazer da nova tela do payment_mode
+ 'identificacao_ocorrencia': 1,
+
+ # numero fatura esta copiando para communication
+ 'numero_documento': self.adiciona_digitos_num_doc(
+ line.communication),
+ # 'numero_documento': str(line.move_line_id.invoice.number),
+
+ }
+
+ def remessa(self, order):
+ """
+
+ :param order:
+ :return:
+ """
+ self.order = order
+ self.arquivo = ArquivoCobranca400(self.bank, **self._prepare_header())
+ for line in order.line_ids:
+ self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
+ self.arquivo.trailer.num_seq_registro = self.controle_linha
+
+ remessa = unicode(self.arquivo)
+ return unicodedata.normalize(
+ 'NFKD', remessa).encode('ascii', 'ignore')
+
+ def data_hoje(self):
+ return (int(time.strftime("%d%m%y")))
+
+ def hora_agora(self):
+ return (int(time.strftime("%H%M%S")))
+
+ def calcula_valor_juros_dia(self, total_titulo, percent_juros):
+ valor_juros = 0
+ valor_juros = (total_titulo * (percent_juros / 100))
+ return (Decimal(valor_juros).quantize(Decimal('1.00')))
+
+ def adiciona_digitos_num_doc(self, campo):
+ num_digitos = 10
+ campo = str(campo)
+ chars_faltantes = num_digitos - len(campo)
+ return (u' ' * chars_faltantes) + campo
+
+ # @api.multi
+ def retorna_endereco(self, id_parceiro):
+ # self.ensure_one()
+ # workaround to get env
+ res_partner_model = self.order.env['res.partner']
+ res_partner_end_cobranca = res_partner_model.search(
+ [('parent_id', '=', id_parceiro), ('type', '=', 'cnab_cobranca')],
+ limit=1)
+ if res_partner_end_cobranca:
+ str_endereco = self.monta_endereco(res_partner_end_cobranca)
+ else:
+ res_partner_end_cobranca = res_partner_model.search(
+ [('id', '=', id_parceiro)]
+ )
+ str_endereco = self.monta_endereco(res_partner_end_cobranca)
+ # Essa abordagem substitui caracteres especiais por '?'
+ # str_endereco = /
+ # unicode(str_endereco.encode("ascii", errors="replace"))
+
+ # Substitui sinal de grau por espaço
+ str_endereco = str_endereco.replace(u"\xb0", u" ")
+
+ return str_endereco
+
+ def monta_endereco(self, partner_item):
+
+ street = self.check_address_item_filled(partner_item.street)
+ number = self.check_address_item_filled(partner_item.number)
+ complemento = self.check_address_item_filled(partner_item.street2)
+ distrito = self.check_address_item_filled(partner_item.district)
+
+ str_endereco = (
+ street +
+ ' ' +
+ number +
+ ' ' +
+ complemento +
+ ' ' +
+ distrito
+ # + ' ' +
+ # partner_item.l10n_br_city_id.name +
+ # ' ' + partner_item.state_id.name
+ )
+ return str_endereco
+
+ def check_address_item_filled(self, item):
+ if not item:
+ return ('')
+ else:
+ return item
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py b/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
new file mode 100644
index 000000000000..dec8c03dbfde
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
@@ -0,0 +1,24 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import pag_for500
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
new file mode 100644
index 000000000000..0104e2520683
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
@@ -0,0 +1,22 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
new file mode 100644
index 000000000000..1edd242559c2
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
@@ -0,0 +1,75 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+import re
+import string
+
+from ..pag_for500 import PagFor500
+
+
+class BradescoPagFor(PagFor500):
+
+ def __init__(self):
+ super(PagFor500, self).__init__()
+ from cnab240.bancos import bradescoPagFor
+ self.bank = bradescoPagFor
+ self.controle_linha = 2
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+ vals = super(BradescoPagFor, self)._prepare_header()
+ vals['codigo_comunicacao'] = int(self.order.mode.boleto_convenio)
+ return vals
+
+ def _prepare_cobranca(self, line, vals):
+ """
+
+ :param line:
+ :return:
+ """
+ vals = super(BradescoPagFor, self)._prepare_cobranca(line, vals)
+
+ # TODO campo para informar a data do pagamento.
+ vals['data_para_efetivacao_pag'] = self.muda_campos_data(
+ vals['vencimento_titulo'])
+ self.controle_linha += 1
+
+ return vals
+
+ # Override cnab_240.nosso_numero. Diferentes números de dígitos
+ # entre CEF e Itau
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
+
+ def muda_campos_data(self, campo):
+ campo = str(campo)
+ campo = campo[-4:] + campo[2:4] + campo[:2]
+ return int(campo)
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
new file mode 100644
index 000000000000..36668325fbb4
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -0,0 +1,575 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import datetime
+import logging
+import re
+import string
+import time
+import unicodedata
+from decimal import Decimal
+
+from openerp import _
+from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
+from openerp.exceptions import Warning as UserError
+
+from ..cnab import Cnab
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.tipos import Arquivo
+except ImportError as err:
+ _logger.debug = (err)
+try:
+ from pyboleto.data import BoletoData
+except ImportError as err:
+ _logger.debug = (err)
+
+TIPO_CONTA_FORNECEDOR = [
+ ('1', u'Conta corrente'),
+ ('2', u'Conta Poupança'),
+]
+
+TIPO_DOCUMENTO = [
+ ('01', u'Nota Fiscal/Fatura'),
+ ('02', u'Fatura'),
+ ('03', u'Nota Fiscal'),
+ ('01', u'Duplicata'),
+ ('01', u'Outros'),
+]
+
+MODALIDADE = [
+ ('01', u'01 - Crédito em conta-corrente ou poupança Bradesco'),
+ ('02', u'02 - Cheque OP ( Ordem de Pagamento'),
+ ('03', u'03 - DOC COMPE'),
+ ('05', u'05 - Crédito em conta real time'),
+ ('08', u'08 - TED'),
+ ('30', u'30 - Rastreamento de Títulos'),
+ ('31', u'31 - Títulos de terceiros'),
+]
+
+TIPO_MOVIMENTO = [
+ ('0', u'Inclusão'),
+ ('5', u'Alteração'),
+ ('9', u'Exclusão'),
+]
+
+CODIGO_MOVIMENTO = [
+ ('00', u'Autoriza agendamento'),
+ ('25', u'Desautoriza Agendamento'),
+ ('50', u'Efetuar Alegçação'),
+]
+
+TIPO_DOC = [
+ ('C', u'Titularidade Diferente'),
+ ('D', u'Mesma Titularidade'),
+]
+
+FINALIDADE_DOC_TED = [
+ ('01', u'Crédito em Conta Corrente'),
+ ('02', u'Pagamento de Aluguel /Condomínios'),
+ ('03', u'Pagamento de Duplicatas/Títulos'),
+ ('04', u'Pagamento de Dividendos'),
+ ('05', u'Pagamento de Mensal. Escolares'),
+ ('06', u'Pagamento de Salário'),
+ ('07', u'Pagamento de Fornec/Honor.'),
+ ('08', u'Operações de Câmbio /Fundos /Bolsa de Valores'),
+ ('09', u'Repasse de Arrec./Pagto de Tributos'),
+ ('10', u'Transferência Internacional em Reais'),
+ ('11', u'DOC COMPE/TED para Poupança'),
+ ('12', u'DOC COMPE/TED para Depósito Judicial'),
+ ('13', u'Pensão Alimentícia'),
+ ('14', u'Restituição de Imposto de Renda'),
+ ('18', u'Operações Seguro Habit.', u'SFH'),
+ ('19', u'Operações do FDS', u'Caixa'),
+ ('20', u'Pagamento De Operação De Crédito'),
+ ('23', u'Taxa de Administração'),
+ ('27', u'Pagamento Acordo/Execução Judicial'),
+ ('28', u'Liquidação de Empréstimos Consignados'),
+ ('29', u'Pagamento de Bolsa Auxilio'),
+ ('30', u'Remuneração A Cooperado'),
+ ('31', u'Pagamento de Prebenda'),
+ ('33', u'Pagamento de Juros sobre Capital Próprio'),
+ ('34', u'Pagamento de Rendimentos ou Amortização s/ Cotas '
+ u'e/ou Debêntures'),
+ ('35', u'Taxa De Serviço'),
+ ('37', u'Pagamento de Juros e/ou Amortização de Títulos '
+ u'Depositados em Garantia.'),
+ ('38', u'Estorno Ou Restituição', u'Diversos'),
+ ('59', u'Restituição de Prêmios de Seguros'),
+ ('60', u'Pagamento de Indenização Sinistro Seguro'),
+ ('61', u'Pagamento de Premio de Co-Seguro'),
+ ('63', u'Pagamento de Indenização Sinistro Co-Seguro'),
+ ('64', u'Pagamento de Premio De Resseguro'),
+ ('65', u'Restituição de Premio De Resseguro'),
+ ('66', u'Pagamento de Indenização Sinistro Resseguro'),
+ ('67', u'Restituição Indenização Sinistro Resseguro'),
+ ('68', u'Pagamento de Despesas Com Sinistro'),
+ ('69', u'Pagamento de Inspeções/Vistorias Prévias'),
+ ('70', u'Pagamento de Resgate de Titulo de Capitalização'),
+ ('71', u'Pagamento de Sorteio de Titulo de Capitalização'),
+ ('72', u'Devolução Mensal de Titulo de Capitalização.'),
+ ('73', u'Restituição de Contribuição de Plano Previdenciário'),
+ ('74', u'Pagamento de Beneficio Previdenciário Pecúlio'),
+ ('75', u'Pagamento de Beneficio Previdenciário Pensão'),
+ ('76', u'Pagamento de Beneficio Previdenciário Aposentadoria'),
+ ('77', u'Pagamento de Resgate Previdenciário'),
+ ('78', u'Pagamento de Comissão de Corretagem'),
+ ('79', u'Pagamento de Transferências/Portabilidade de Reserva '
+ u'Seguro/Previdência'),
+ ('80', u'Pagamento de Impostos'),
+ ('81', u'Pagamento de Serviços Públicos'),
+ ('82', u'Pagamento de Honorários'),
+ ('83', u'Pagamento de Corretoras'),
+ ('84', u'Repasse de Valores BNDES'),
+ ('85', u'Liquidação de Compromissos com BNDES'),
+ ('86', u'Compra e Venda de Ações'),
+ ('87', u'Contratos Referenciados em Ações ou Índices de Ações'),
+ ('88', u'Operação De Cambio'),
+ ('89', u'Pagamento de Boleto Bancário em Cartório'),
+ ('90', u'Pagamento de Tarifas pela Prestação de Serviços de Arrecadação'
+ u' de Convênios'),
+ ('91', u'Operações no Mercado de Renda Fixa e Variável com Utilização '
+ u'de Intermediário'),
+ ('92', u'Operação de Câmbio Mercado Interbancário Instituições '
+ u'sem Reservas Bancárias'),
+ ('93', u'Pagamento de Operações com Identificação de Destinatário Final'),
+ ('94', u'Ordem Bancaria do Tesouro - OBT'),
+ ('99', u'Outros'),
+]
+
+
+class PagFor500(Cnab):
+ """
+
+ """
+
+ def __init__(self):
+ super(Cnab, self).__init__()
+
+ @staticmethod
+ def get_bank(bank):
+ if bank == '237':
+ from .bancos.bradesco import BradescoPagFor
+ return BradescoPagFor
+ else:
+ return PagFor500
+
+ @property
+ def inscricao_tipo(self):
+ # TODO: Implementar codigo para PIS/PASEP
+ if self.order.company_id.partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_header(self):
+ """
+
+ :param:
+ :return:
+ """
+ return {
+ 'arquivo_data_de_geracao': self.data_hoje_pag_for(),
+ 'arquivo_hora_de_geracao': self.hora_agora(),
+ # TODO: Número sequencial de arquivo
+ 'numero_remessa': int(self.get_file_numeration()),
+ 'cedente_inscricao_tipo': self.inscricao_tipo,
+ 'cnpj_cpf_base': int(punctuation_rm(
+ self.order.company_id.cnpj_cpf)[0:8]),
+ 'cnpj_cpf_filial': int(punctuation_rm(
+ self.order.company_id.cnpj_cpf)[9:12]),
+ 'sufixo_cnpj': int(punctuation_rm(
+ self.order.company_id.cnpj_cpf)[12:14]),
+ 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
+ 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_agencia_conta_dv':
+ self.order.mode.bank_id.bra_number_dig,
+ 'nome_empresa_pagadora': self.order.company_id.legal_name,
+ 'cedente_codigo_agencia_digito':
+ self.order.mode.bank_id.bra_number_dig,
+ 'arquivo_codigo': 1, # Remessa/Retorno
+ 'servico_operacao': u'R',
+ 'reservado_empresa': u'BRADESCO PAG FOR',
+ # Sequencial crescente e nunca pode ser repetido
+ 'numero_lista_debito': int(self.get_file_numeration()),
+ # TODO: Sequencial crescente de 1 a 1 no arquivo. O primeiro header
+ # será sempre 000001
+ 'sequencial': 1
+ }
+
+ def get_file_numeration(self):
+ numero = self.order.get_next_number()
+ if not numero:
+ numero = 1
+ return numero
+
+ def format_date(self, srt_date):
+ return int(datetime.datetime.strptime(
+ srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
+
+ def format_date_ano_mes_dia(self, srt_date):
+ return int(datetime.datetime.strptime(
+ srt_date, '%Y-%m-%d').strftime('%Y%m%d'))
+
+ def nosso_numero(self, format):
+ pass
+
+ def cep(self, format):
+ sulfixo = format[-3:]
+ prefixo = format[:5]
+ return prefixo, sulfixo
+
+ def sacado_inscricao_tipo(self, partner_id):
+ # TODO: Implementar codigo para PIS/PASEP
+ if partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def rmchar(self, format):
+ return re.sub('[%s]' % re.escape(string.punctuation), '', format or '')
+
+ def _prepare_cobranca(self, line, vals):
+ """
+
+ :param line:
+ :return:
+ """
+ segmento = {}
+
+ vals.update(segmento)
+
+ # TODO this zip code
+ prefixo, sulfixo = self.cep(line.partner_id.zip)
+
+ segmento = {
+ 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ # 'especie_titulo': 8,
+
+ 'tipo_inscricao': int(
+ self.sacado_inscricao_tipo(line.partner_id)),
+ 'cnpj_cpf_base_forn': int(
+ self.rmchar(line.partner_id.cnpj_cpf)[0:8]),
+ 'cnpj_cpf_filial_forn': int(
+ self.rmchar(line.partner_id.cnpj_cpf)[9:12]),
+ 'cnpj_cpf_forn_sufixo': int(
+ self.rmchar(line.partner_id.cnpj_cpf)[12:14]),
+ 'nome_forn': line.partner_id.legal_name,
+ 'endereco_forn': (
+ line.partner_id.street + ' ' + line.partner_id.number),
+ 'cep_forn': int(prefixo),
+ 'cep_complemento_forn': int(sulfixo),
+
+ # TODO quando banco é 237, deve-se extrair da linha
+ # digitável. Do contrário, zeros.
+ # 'nosso_numero': 11, # FIXME
+
+ # 'numero_documento': line.name,
+ # 'vencimento_titulo': self.format_date_ano_mes_dia(
+ # line.ml_maturity_date),
+
+ 'data_emissao_titulo': self.format_date_ano_mes_dia(
+ line.ml_date_created),
+
+ 'desconto1_data': 0,
+ 'fator_vencimento': 0, # FIXME
+
+ 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+
+ 'valor_pagto': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+
+ 'valor_desconto': Decimal('0.00'),
+
+ 'valor_acrescimo': Decimal('0.00'),
+
+ # FIXME
+ 'tipo_documento': 2, # NF, Fatura, Duplicata...
+ # NF_Fatura_01/Fatura_02/NF_03/Duplicata_04/Outros_05
+ 'numero_nf': int(line.ml_inv_ref.internal_number),
+
+ 'modalidade_pagamento': int(
+ line.order_id.mode.type_purchase_payment),
+
+ # Quando não informada o sistema assume a data constante do campo
+ # Vencimento
+ 'data_para_efetivacao_pag': 0,
+
+ 'tipo_movimento': 0,
+ # TODO Tipo de Movimento.
+ # 0 - Inclusão.
+ # 5 - Alteração.
+ # 9 - Exclusão.
+
+ 'codigo_movimento': 0, # Autoriza agendamento
+
+ # Quando não informado consulta em todos processamentos
+ # 'horario_consulta_saldo': u'5',
+
+ 'codigo_area_empresa': 0,
+
+ 'codigo_lancamento': 0, # FIXME
+
+ 'tipo_conta_fornecedor': 1, # FIXME
+
+ # O Primeiro registro de transação sempre será o registro
+ # “000002”, e assim sucessivamente.
+ 'sequencial': 3, # FIXME
+
+ # Trailer
+ 'totais_quantidade_registros': 0,
+ 'total_valor_arq': Decimal('0.00'),
+ # FIXME: lib nao reconhece campo
+ 'sequencial_trailer': int(self.get_file_numeration()),
+ 'sequencial_transacao': self.controle_linha,
+ 'codigo_protesto': int(self.order.mode.boleto_protesto),
+ 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
+ 'codigo_baixa': 2,
+ 'prazo_baixa': 0, # De 5 a 120 dias.
+ 'controlecob_data_gravacao': self.data_hoje(),
+
+ }
+ segmento.update(vals)
+ return segmento
+
+ def remessa(self, order):
+ """
+
+ :param order:
+ :return:
+ """
+
+ pag_valor_titulos = 0
+
+ self.order = order
+ self.arquivo = Arquivo(self.bank, **self._prepare_header())
+ cont_lote = 0
+
+ for line in order.line_ids:
+ self.arquivo.incluir_pagamento(**self.incluir_pagamento_for(line))
+ pag_valor_titulos += line.amount_currency
+ self.arquivo.trailer.total_valor_arq = Decimal(
+ pag_valor_titulos).quantize(Decimal('1.00'))
+ self.arquivo.trailer.sequencial_transacao = self.controle_linha
+
+ cont_lote += 1
+ remessa = unicode(self.arquivo)
+ return unicodedata.normalize(
+ 'NFKD', remessa).encode('ascii', 'ignore')
+
+ def data_hoje(self):
+ return (int(time.strftime("%d%m%Y")))
+
+ def data_hoje_pag_for(self):
+ return (int(time.strftime("%Y%m%d")))
+
+ def hora_agora(self):
+ return (int(time.strftime("%H%M%S")))
+
+ @staticmethod
+ def modulo11(num, base, r):
+ return BoletoData.modulo11(num, base=9, r=0)
+
+ def incluir_pagamento_for(self, line):
+ mode = line.order_id.mode.type_purchase_payment
+ if mode in ('01'):
+ return self.lancamento_credito_bradesco(line)
+ elif mode in ('02'):
+ raise UserError(_(u'Operação não suportada'))
+ elif mode in ('03'):
+ return self.lancamento_doc(line)
+ elif mode in ('05'):
+ raise UserError(_(u'Operação não suportada'))
+ elif mode in ('08'):
+ return self.lancamento_ted(line)
+ elif mode in ('30'):
+ raise UserError(_(u'Operação não suportada'))
+ elif mode in ('31'):
+ # titulos de terceiros
+ return self.lancamento_titulos_terceiros(line)
+ raise UserError(_(u'Operação não suportada'))
+
+ def lancamento_credito_bradesco(self, line):
+ # TODO:
+ # modalidade 01.
+
+ vals = {
+ 'especie_titulo': line.order_id.mode.type_purchase_payment,
+
+ 'codigo_banco_forn': 237,
+ 'codigo_agencia_forn': int(line.bank_id.bra_number),
+ 'digito_agencia_forn_transacao': line.bank_id.bra_number_dig,
+ 'conta_corrente_forn': int(line.bank_id.acc_number),
+ 'digito_conta_forn_transacao': line.bank_id.acc_number_dig,
+
+ 'numero_pagamento': self.adiciona_digitos_num_pag(
+ line.communication),
+
+ 'carteira': int(self.order.mode.boleto_carteira),
+
+ 'nosso_numero': 0,
+
+ 'vencimento_titulo': self.format_date_ano_mes_dia(
+ line.ml_maturity_date),
+
+ 'informacoes_complementares': u'',
+ }
+
+ return self._prepare_cobranca(line, vals)
+
+ def lancamento_ted(self, line):
+ # TODO:
+ # modalidade 08.
+
+ vals = {
+ 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ 'especie_titulo': line.order_id.mode.type_purchase_payment,
+
+
+ # TODO: código do banco. Para a Modalidade de Pagamento valor
+ # pode variar
+ 'codigo_banco_forn': int(line.bank_id.bank.bic),
+ 'codigo_agencia_forn': int(line.bank_id.bra_number),
+ 'digito_agencia_forn_transacao': line.bank_id.bra_number_dig,
+ 'conta_corrente_forn': int(line.bank_id.acc_number),
+ 'digito_conta_forn_transacao': line.bank_id.acc_number_dig,
+ # TODO Gerado pelo cliente pagador quando do agendamento de
+ # pagamento por parte desse, exceto para a modalidade 30 -
+ # Títulos em Cobrança Bradesco
+ # communication
+ 'numero_pagamento': self.adiciona_digitos_num_pag(
+ line.communication),
+
+ 'carteira': 0,
+
+ 'nosso_numero': 0,
+
+ 'vencimento_titulo': self.format_date_ano_mes_dia(
+ line.ml_maturity_date),
+
+ 'fator_vencimento': 0, # FIXME
+
+ # 'modalidade_pagamento': int(self.order.mode.boleto_especie),
+
+ 'tipo_movimento': 0,
+ # TODO Tipo de Movimento.
+ # 0 - Inclusão.
+ # 5 - Alteração.
+ # 9 - Exclusão. Wkf Odoo.
+ 'codigo_movimento': 0, # FIXME
+ # 'horario_consulta_saldo': u'5', # FIXME
+
+ # 'informacoes_complementares': self.montar_info_comple_ted(),
+ 'informacoes_complementares': u'',
+
+ 'codigo_lancamento': 0, # FIXME
+ 'tipo_conta_fornecedor': 1, # FIXME
+
+ }
+
+ return self._prepare_cobranca(line, vals)
+
+ def lancamento_doc(self):
+ # TODO:
+
+ vals = {}
+
+ return self._prepare_cobranca(vals)
+
+ def lancamento_titulos_terceiros(self, line):
+ # TODO:
+
+ res_cods_ag_cc = \
+ self.ler_linha_digitavel_codigos_ag_cc(line.linha_digitavel)
+
+ vals = {
+ 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ 'especie_titulo': line.order_id.mode.type_purchase_payment,
+
+ # extrair do código de barras
+ 'codigo_banco_forn': res_cods_ag_cc['codigo_banco_forn'],
+ 'codigo_agencia_forn': res_cods_ag_cc['codigo_agencia_forn'],
+ 'digito_agencia_forn_transacao': res_cods_ag_cc[
+ 'digito_agencia_forn_transacao'],
+ 'conta_corrente_forn': res_cods_ag_cc['conta_corrente_forn'],
+ 'digito_conta_forn_transacao': res_cods_ag_cc[
+ 'digito_conta_forn_transacao'],
+
+ 'carteira': res_cods_ag_cc['carteira']
+
+ }
+
+ return self._prepare_cobranca(vals)
+
+ def adiciona_digitos_num_pag(self, campo):
+ num_digitos = 16
+ campo = str(campo)
+ chars_faltantes = num_digitos - len(campo)
+ return (u' ' * chars_faltantes) + campo
+
+ def montar_info_comple_ted(self):
+ tipo_doc_compe = TIPO_DOC[0][0]
+ num_doc_ted = '000000'
+ # pagamento duplicatas. Ou será 01?
+ finalidade_doc_compe = FINALIDADE_DOC_TED[2][0]
+ tipo_conta_doc_ted = '01'
+ codigo_identif_transf = '0000000000000000000000000'
+ fim_do_campo = ' '
+ info_comple = tipo_doc_compe + num_doc_ted + finalidade_doc_compe + \
+ tipo_conta_doc_ted + codigo_identif_transf + fim_do_campo
+ return (info_comple.encode('utf-8'))
+
+ def ler_linha_digitavel_codigos_ag_cc(self, linha_digitavel):
+ codigo_banco_fornecedor = linha_digitavel[:3]
+ res = {}
+
+ # para banco = 237, bradesco
+ if (codigo_banco_fornecedor == '237'):
+ res = {
+ 'codigo_banco_forn': int(codigo_banco_fornecedor),
+ 'codigo_agencia_forn': int(linha_digitavel[4:8]),
+ # Calcular usando modulo 11 base 7
+ 'digito_agencia_forn_transacao': u'',
+ 'conta_corrente_forn': int(linha_digitavel[23:30]),
+ # Calcular usando modulo 11 base 7
+ 'digito_conta_forn_transacao': u'',
+
+ 'carteira': int(linha_digitavel[8:10]),
+
+ 'nosso_numero': int(linha_digitavel[11:21])
+ }
+ # para outros bancos
+ else:
+ res = {
+ 'codigo_banco_forn': int(codigo_banco_fornecedor),
+ 'codigo_agencia_forn': 0,
+ 'digito_agencia_forn_transacao': u'',
+ 'conta_corrente_forn': 0,
+ 'digito_conta_forn_transacao': u'',
+
+ 'carteira': 0,
+
+ 'nosso_numero': 0,
+ }
+ return res
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
new file mode 100644
index 000000000000..06bababd5de4
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+
+from . import account_move_line
+from . import payment_order
+from . import l10n_br_cnab_sequence
+from . import l10n_br_cnab_file_sufix_sequence
+from . import payment_mode
+from . import res_partner_bank
+from . import res_partner
+from .. import constantes
+from . import payment_line
+# from . import bank_payment_line
+from . import l10n_br_cnab
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
new file mode 100644
index 000000000000..de3b62a1abaf
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# #############################################################################
+#
+#
+# Copyright (C) 2012 KMEE (http://www.kmee.com.br)
+# @author Fernando Marcato Rodrigues
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+# ESTADOS_CNAB = [
+# ('draft', u'Inicial'),
+# ('added', u'Adicionada à ordem de pagamento'),
+# ('exported', u'Exportada'),
+# ('accepted', u'Aceita'),
+# ('not_accepted', u'Não aceita pelo banco'), # importar novamente
+# ]
+
+
+class AccounMoveLine(models.Model):
+ _inherit = "account.move.line"
+ #
+ # state_cnab = fields.Selection(
+ # ESTADOS_CNAB, u'Estados CNAB', default='draft')
+
+ is_cnab_rejected = fields.Boolean(
+ u'Pode ser exportada novamente', default=False,
+ help='Marque esse campo para indicar um título que pode ser '
+ 'exportado novamente pelo CNAB')
+ cnab_rejected_code = fields.Char(u'Rejeição')
+ # transaction_ref = fields.char('Transaction Ref.',
+ # select=True,
+ # store=True,
+ # related='name')
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
new file mode 100644
index 000000000000..f7c4560c4694
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, api
+from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \
+ AVISO_FAVORECIDO
+
+
+class BankPaymentLine(models.Model):
+ _inherit = 'bank.payment.line'
+
+ @api.model
+ def default_get(self, fields_list):
+ res = super(BankPaymentLine, self).default_get(fields_list)
+ mode = self.env['payment.order'].browse(
+ self.env.context.get('order_id')).mode
+ if mode.codigo_finalidade_doc:
+ res.update({
+ 'codigo_finalidade_doc': mode.codigo_finalidade_doc})
+ if mode.codigo_finalidade_ted:
+ res.update({
+ 'codigo_finalidade_ted': mode.codigo_finalidade_ted
+ })
+ if mode.codigo_finalidade_complementar:
+ res.update({
+ 'codigo_finalidade_complementar':
+ mode.codigo_finalidade_complementar
+ })
+ if mode.aviso_ao_favorecido:
+ res.update({
+ 'aviso_ao_favorecido': mode.aviso_ao_favorecido
+ })
+ return res
+
+ codigo_finalidade_doc = fields.Selection(
+ selection=COMPLEMENTO_TIPO_SERVICO,
+ string=u'Complemento do Tipo de Serviço',
+ help=u'Campo P005 do CNAB'
+ )
+ codigo_finalidade_ted = fields.Selection(
+ selection=CODIGO_FINALIDADE_TED,
+ string=u'Código Finalidade da TED',
+ help=u'Campo P011 do CNAB'
+ )
+ codigo_finalidade_complementar = fields.Char(
+ size=2,
+ string=u'Código de finalidade complementar',
+ help=u'Campo P013 do CNAB'
+ )
+ aviso_ao_favorecido = fields.Selection(
+ selection=AVISO_FAVORECIDO,
+ string=u'Aviso ao Favorecido',
+ help=u'Campo P006 do CNAB',
+ default='0',
+ )
+ abatimento = fields.Float(
+ digits=(13, 2),
+ string=u'Valor do Abatimento',
+ help=u'Campo G045 do CNAB',
+ default=0.00
+ )
+ desconto = fields.Float(
+ digits=(13, 2),
+ string=u'Valor do Desconto',
+ help=u'Campo G046 do CNAB',
+ default=0.00
+ )
+ mora = fields.Float(
+ digits=(13, 2),
+ string=u'Valor da Mora',
+ help=u'Campo G047 do CNAB',
+ default=0.00
+ )
+ multa = fields.Float(
+ digits=(13, 2),
+ string=u'Valor da Multa',
+ help=u'Campo G048 do CNAB',
+ default=0.00
+ )
+ evento_id = fields.One2many(
+ string="Eventos CNAB",
+ comodel_name="l10n.br.cnab.evento",
+ inverse_name="bank_payment_line_id",
+ readonly=True
+ )
+ codigo_finalidade_complementar = fields.Char(
+ size=2,
+ string=u'Código de finalidade complementar',
+ help=u'Campo P013 do CNAB',
+ )
+
+ @api.model
+ def same_fields_payment_line_and_bank_payment_line(self):
+ """
+ This list of fields is used both to compute the grouping
+ hashcode and to copy the values from payment line
+ to bank payment line
+ The fields must have the same name on the 2 objects
+ """
+ same_fields = super(
+ BankPaymentLine, self
+ ).same_fields_payment_line_and_bank_payment_line()
+
+ # TODO: Implementar campo brasileiros que permitem mesclar linhas
+
+ # same_fields = [
+ # 'currency', 'partner_id',
+ # 'bank_id', 'date', 'state']
+
+ return same_fields
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
new file mode 100644
index 000000000000..d16929d5399e
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -0,0 +1,304 @@
+# -*- coding: utf-8 -*-
+# Copyright 2017 KMEE - Luiz Felipe do Divino Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+import base64
+import codecs
+import logging
+from datetime import datetime
+from ..constantes import CODIGO_OCORRENCIAS
+
+from openerp import api, models, fields, exceptions
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.bancos import bancodobrasil
+ from cnab240.tipos import Arquivo
+except ImportError as err:
+ _logger.debug = (err)
+
+STATE = [
+ ('draft', 'Novo'),
+ ('done', 'Processado'),
+]
+
+TIPO_OPERACAO = {
+ 'C': u'Lançamento a Crédito',
+ 'D': u'Lançamento a Débito',
+ 'E': u'Extrato para Conciliação',
+ 'G': u'Extrato para Gestão de Caixa',
+ 'I': u'Informações de Títulos Capturados do Próprio Banco',
+ 'R': u'Arquivo Remessa',
+ 'T': u'Arquivo Retorno',
+}
+
+TIPO_SERVICO = {
+ '01': 'Cobrança',
+ '03': 'Boleto de Pagamento Eletrônico',
+ '04': 'Conciliação Bancária',
+ '05': 'Débitos',
+ '06': 'Custódia de Cheques',
+ '07': 'Gestão de Caixa',
+ '08': 'Consulta/Informação Margem',
+ '09': 'Averbação da Consignação/Retenção',
+ '10': 'Pagamento Dividendos',
+ '11': 'Manutenção da Consignação',
+ '12': 'Consignação de Parcelas',
+ '13': 'Glosa da Consignação (INSS)',
+ '14': 'Consulta de Tributos a pagar',
+ '20': 'Pagamento Fornecedor',
+ '22': 'Pagamento de Contas, Tributos e Impostos',
+ '23': 'Interoperabilidade entre Contas de Instituições de Pagamentos',
+ '25': 'Compror',
+ '26': 'Compror Rotativo',
+ '29': 'Alegação do Pagador',
+ '30': 'Pagamento Salários',
+ '32': 'Pagamento de honorários',
+ '33': 'Pagamento de bolsa auxílio',
+ '34': 'Pagamento de prebenda (remuneração a padres e sacerdotes)',
+ '40': 'Vendor',
+ '41': 'Vendor a Termo',
+ '50': 'Pagamento Sinistros Segurados',
+ '60': 'Pagamento Despesas Viajante em Trânsito',
+ '70': 'Pagamento Autorizado',
+ '75': 'Pagamento Credenciados',
+ '77': 'Pagamento de Remuneração',
+ '80': 'Pagamento Representantes / Vendedores Autorizados',
+ '90': 'Pagamento Benefícios',
+ '98': 'Pagamentos Diversos',
+}
+
+TIPO_INSCRICAO_EMPRESA = {
+ 0: 'Isento / Não informado',
+ 1: 'CPF',
+ 2: 'CGC / CNPJ',
+ 3: 'PIS / PASEP',
+ 9: 'Outros',
+}
+
+
+class L10nBrHrCnab(models.Model):
+ _name = "l10n.br.cnab"
+ _rec_name = "display_name"
+
+ @api.multi
+ def processar_arquivo_retorno(self):
+ arquivo_retono = base64.b64decode(self.arquivo_retorno)
+ f = open('/tmp/cnab_retorno.ret', 'wb')
+ f.write(arquivo_retono)
+ f.close()
+ arquivo_retono = codecs.open('/tmp/cnab_retorno.ret', encoding='ascii')
+ arquivo_parser = Arquivo(bancodobrasil, arquivo=arquivo_retono)
+ if not arquivo_parser.header.arquivo_codigo == u'2':
+ raise exceptions.Warning(
+ u"Este não é um arquivo de retorno!"
+ )
+ data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
+ self.data_arquivo = fields.Date.from_string(
+ data_arquivo[4:] + "-" + data_arquivo[2:4] + "-" +
+ data_arquivo[0:2]
+ )
+ self.bank_account_id = self.env['res.partner.bank'].search(
+ [('acc_number', '=', arquivo_parser.header.cedente_conta)]).id
+ self.num_lotes = arquivo_parser.trailer.totais_quantidade_lotes
+ self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
+ for lote in arquivo_parser.lotes:
+ account_bank_id_lote = self.env['res.partner.bank'].search(
+ [('acc_number', '=', lote.header.cedente_conta)]
+ ).id
+ vals = {
+ 'account_bank_id': account_bank_id_lote,
+ 'empresa_inscricao_numero':
+ str(lote.header.empresa_inscricao_numero),
+ 'empresa_inscricao_tipo':
+ TIPO_INSCRICAO_EMPRESA[lote.header.empresa_inscricao_tipo],
+ 'servico_operacao':
+ TIPO_OPERACAO[lote.header.servico_operacao],
+ 'tipo_servico': TIPO_SERVICO[str(lote.header.servico_servico)],
+ 'mensagem': lote.header.mensagem1,
+ 'qtd_registros': lote.trailer.quantidade_registros,
+ 'total_valores': float(lote.trailer.somatoria_valores),
+ 'cnab_id': self.id,
+ }
+ lote_id = self.env['l10n.br.cnab.lote'].create(vals)
+ for evento in lote.eventos:
+ data_evento = str(
+ evento.credito_data_real)
+ data_evento = fields.Date.from_string(
+ data_evento[4:] + "-" + data_evento[2:4] + "-" +
+ data_evento[0:2]
+ )
+ account_bank_id_lote = self.env['res.partner.bank'].search(
+ [
+ ('bra_number', '=', evento.favorecido_agencia),
+ ('bra_number_dig', '=', evento.favorecido_agencia_dv),
+ ('acc_number', '=', evento.favorecido_conta),
+ ('acc_number_dig', '=', evento.favorecido_conta_dv)
+ ])
+ account_bank_id_lote = account_bank_id_lote.ids[0] \
+ if account_bank_id_lote else False
+ favorecido_partner = self.env['res.partner.bank'].search(
+ [('owner_name', 'ilike', evento.favorecido_nome)]
+ )
+ favorecido_partner = favorecido_partner[0].partner_id.id \
+ if favorecido_partner else False
+ bank_payment_line_id = self.env['bank.payment.line'].search(
+ [
+ ('name', '=', evento.credito_seu_numero)
+ ]
+ )
+ ocorrencias_dic = dict(CODIGO_OCORRENCIAS)
+ ocorrencias = [
+ evento.ocorrencias[0:2],
+ evento.ocorrencias[2:4],
+ evento.ocorrencias[4:6],
+ evento.ocorrencias[6:8],
+ evento.ocorrencias[8:10]
+ ]
+ vals_evento = {
+ 'data_real_pagamento': data_evento,
+ 'segmento': evento.servico_segmento,
+ 'favorecido_nome': favorecido_partner,
+ 'favorecido_conta_bancaria': account_bank_id_lote,
+ 'nosso_numero': str(evento.credito_nosso_numero),
+ 'seu_numero': evento.credito_seu_numero,
+ 'tipo_moeda': evento.credito_moeda_tipo,
+ 'valor_pagamento': evento.credito_valor_pagamento,
+ 'ocorrencias': evento.ocorrencias,
+ 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
+ ocorrencias[0] else '',
+ 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
+ ocorrencias[1] else '',
+ 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
+ ocorrencias[2] else '',
+ 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
+ ocorrencias[3] else '',
+ 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
+ ocorrencias[4] else '',
+ 'lote_id': lote_id.id,
+ 'bank_payment_line_id': bank_payment_line_id.id,
+ }
+ self.env['l10n.br.cnab.evento'].create(vals_evento)
+ if evento.ocorrencias and bank_payment_line_id:
+ if '00' in ocorrencias:
+ bank_payment_line_id.write({'state2': 'paid'})
+ else:
+ bank_payment_line_id.write({'state2': 'exception'})
+
+ return self.write({'state': 'done'})
+
+ @api.multi
+ def _get_name(self, data):
+ cnab_ids = self.search([('data', '=', data)])
+ return data + " - " + (
+ str(len(cnab_ids) + 1) if cnab_ids else '1'
+ )
+
+ @api.model
+ def create(self, vals):
+ name = self._get_name(vals['data'])
+ vals.update({'name': name})
+ return super(L10nBrHrCnab, self).create(vals)
+
+ arquivo_retorno = fields.Binary(string='Arquivo Retorno')
+ data = fields.Date(
+ string="Data CNAB",
+ required=True,
+ default=datetime.now()
+ )
+ name = fields.Char(
+ string="Name",
+ )
+ lote_id = fields.One2many(
+ string="Lotes",
+ comodel_name="l10n.br.cnab.lote",
+ inverse_name="cnab_id"
+ )
+ state = fields.Selection(
+ string=u"Estágio",
+ selection=STATE,
+ default="draft",
+ )
+ data_arquivo = fields.Datetime(
+ string="Data Criação no Banco",
+ )
+ bank_account_id = fields.Many2one(
+ string="Conta cedente",
+ comodel_name="res.partner.bank",
+ )
+ num_lotes = fields.Integer(
+ string=u"Número de Lotes",
+ )
+ num_eventos = fields.Integer(
+ string=u"Número de Eventos",
+ )
+
+
+class L10nBrHrCnabLote(models.Model):
+ _name = "l10n.br.cnab.lote"
+
+ account_bank_id = fields.Many2one(
+ string=u"Conta Bancária",
+ comodel_name="res.partner.bank",
+ )
+ empresa_inscricao_numero = fields.Char(string=u"Número de Inscrição")
+ empresa_inscricao_tipo = fields.Char(string=u"Tipo de Inscrição")
+ servico_operacao = fields.Char(string=u"Tipo de Operação")
+ tipo_servico = fields.Char(strin=u"Tipo do Serviço")
+ mensagem = fields.Char(string="Mensagem")
+ qtd_registros = fields.Integer(string="Quantidade de Registros")
+ total_valores = fields.Float(string="Valor Total")
+ evento_id = fields.One2many(
+ string="Eventos",
+ comodel_name="l10n.br.cnab.evento",
+ inverse_name="lote_id",
+ )
+ cnab_id = fields.Many2one(
+ string="CNAB",
+ comodel_name="l10n.br.cnab"
+ )
+ state = fields.Selection(
+ string="State",
+ related="cnab_id.state",
+ selection=STATE,
+ default="draft",
+ )
+
+
+class L10nBrHrCnabEvento(models.Model):
+ _name = "l10n.br.cnab.evento"
+
+ data_real_pagamento = fields.Datetime(string="Data Real do Pagamento")
+ segmento = fields.Char(string="Segmento")
+ favorecido_nome = fields.Many2one(
+ string="Favorecido",
+ comodel_name="res.partner"
+ )
+ favorecido_conta_bancaria = fields.Many2one(
+ string=u"Conta Bancária",
+ comodel_name="res.partner.bank",
+ )
+ nosso_numero = fields.Char(string=u"Nosso Número")
+ seu_numero = fields.Char(string=u"Seu Número")
+ tipo_moeda = fields.Char(string=u"Tipo de Moeda")
+ valor_pagamento = fields.Float(string="Valor do Pagamento")
+ ocorrencias = fields.Char(string=u"Ocorrências")
+ str_motiv_a = fields.Char(u'Motivo da ocorrência 01')
+ str_motiv_b = fields.Char(u'Motivo de ocorrência 02')
+ str_motiv_c = fields.Char(u'Motivo de ocorrência 03')
+ str_motiv_d = fields.Char(u'Motivo de ocorrência 04')
+ str_motiv_e = fields.Char(u'Motivo de ocorrência 05')
+ bank_payment_line_id = fields.Many2one(
+ string="Bank Payment Line",
+ comodel_name="bank.payment.line",
+ )
+ lote_id = fields.Many2one(
+ string="Lote",
+ comodel_name="l10n.br.cnab.lote",
+ )
+ state = fields.Selection(
+ string="State",
+ related="lote_id.state",
+ selection=STATE,
+ default="draft",
+ )
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
new file mode 100644
index 000000000000..38d2593af2f0
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# #############################################################################
+#
+#
+# Copyright (C) 2012 KMEE (http://www.kmee.com.br)
+# @author Fernando Marcato Rodrigues
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+class L10nBrCnabFileSufixSequence(models.Model):
+ _name = 'l10n_br_cnab_file_sufix.sequence'
+
+ code = fields.Char(u'Código')
+ name = fields.Char(u'Nome')
+ internal_sequence_id = fields.Many2one(
+ 'ir.sequence', u'Sequência Interna')
+ parent_payment_mode_suf = fields.Many2one(
+ 'payment.mode', "Conta de exportação", select=True)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
new file mode 100644
index 000000000000..5742279de7c1
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# #############################################################################
+#
+#
+# Copyright (C) 2012 KMEE (http://www.kmee.com.br)
+# @author Fernando Marcato Rodrigues
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+class L10nBrCnabSequence(models.Model):
+ _name = 'l10n_br_cnab.sequence'
+
+ code = fields.Char(u'Código')
+ name = fields.Char(u'Nome')
+ internal_sequence_id = fields.Many2one(
+ 'ir.sequence', u'Sequência Interna')
+ parent_payment_mode = fields.Many2one(
+ 'payment.mode', "Conta de exportação", select=True)
+
+ # 'parent_id': fields.many2one('res.partner.category',
+ # 'Parent Category', select=True, ondelete='cascade')
+ # 400: um modo de cobrança = 1 conta bancária = 1 sequencia de arquivo
+ # 500: n modos de pagamento (ted, doc) = 1 conta bancária = 1 sequencia de
+ # arquivo
diff --git a/l10n_br_account_payment_cobranca/models/payment_line.py b/l10n_br_account_payment_cobranca/models/payment_line.py
new file mode 100644
index 000000000000..d9f78a242fc3
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/payment_line.py
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, api
+from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \
+ AVISO_FAVORECIDO
+
+
+class PaymentLine(models.Model):
+ _inherit = 'payment.line'
+
+ @api.model
+ def default_get(self, fields_list):
+ res = super(PaymentLine, self).default_get(fields_list)
+ mode = self.env['payment.order'].browse(
+ self.env.context.get('order_id')).mode
+ if mode.codigo_finalidade_doc:
+ res.update({
+ 'codigo_finalidade_doc': mode.codigo_finalidade_doc})
+ if mode.codigo_finalidade_ted:
+ res.update({
+ 'codigo_finalidade_ted': mode.codigo_finalidade_ted
+ })
+ if mode.codigo_finalidade_complementar:
+ res.update({
+ 'codigo_finalidade_complementar':
+ mode.codigo_finalidade_complementar
+ })
+ if mode.aviso_ao_favorecido:
+ res.update({
+ 'aviso_ao_favorecido': mode.aviso_ao_favorecido
+ })
+ return res
+
+ seu_numero = fields.Char(
+ string=u'Seu Número',
+ size=20,
+ help=u'Campo G064'
+ )
+ codigo_finalidade_doc = fields.Selection(
+ selection=COMPLEMENTO_TIPO_SERVICO,
+ string=u'Complemento do Tipo de Serviço',
+ help=u'Campo P005 do CNAB',
+ )
+ codigo_finalidade_ted = fields.Selection(
+ selection=CODIGO_FINALIDADE_TED,
+ string=u'Código Finalidade da TED',
+ help=u'Campo P011 do CNAB',
+ )
+ codigo_finalidade_complementar = fields.Char(
+ size=2,
+ string=u'Código de finalidade complementar',
+ help=u'Campo P013 do CNAB',
+ )
+ aviso_ao_favorecido = fields.Selection(
+ selection=AVISO_FAVORECIDO,
+ string=u'Aviso ao Favorecido',
+ help=u'Campo P006 do CNAB',
+ default='0',
+ )
+ abatimento = fields.Float(
+ digits=(13, 2),
+ string=u'Valor do Abatimento',
+ help=u'Campo G045 do CNAB',
+ default=0.00
+ )
+ desconto = fields.Float(
+ digits=(13, 2),
+ string=u'Valor do Desconto',
+ help=u'Campo G046 do CNAB',
+ default=0.00
+ )
+ mora = fields.Float(
+ digits=(13, 2),
+ string=u'Valor da Mora',
+ help=u'Campo G047 do CNAB',
+ default=0.00
+ )
+ multa = fields.Float(
+ digits=(13, 2),
+ string=u'Valor da Multa',
+ help=u'Campo G048 do CNAB',
+ default=0.00
+ )
diff --git a/l10n_br_account_payment_cobranca/models/payment_mode.py b/l10n_br_account_payment_cobranca/models/payment_mode.py
new file mode 100644
index 000000000000..18de555a5073
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/payment_mode.py
@@ -0,0 +1,77 @@
+# -*- coding: utf-8 -*-
+# #############################################################################
+#
+#
+# Copyright (C) 2012 KMEE (http://www.kmee.com.br)
+# @author Fernando Marcato Rodrigues
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+from openerp.addons import decimal_precision as dp
+from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
+ COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, AVISO_FAVORECIDO
+
+
+class PaymentMode(models.Model):
+ _inherit = "payment.mode"
+
+ condicao_emissao_papeleta = fields.Selection(
+ [('1', 'Banco emite e Processa'),
+ ('2', 'Cliente emite e banco processa'), ],
+ u'Condição Emissão de Papeleta', default='1')
+ cnab_percent_interest = fields.Float(string=u"Percentual de Juros",
+ digits=dp.get_precision('Account'))
+ comunicacao_2 = fields.Char("Comunicação para o sacador avalista")
+ tipo_servico = fields.Selection(
+ selection=TIPO_SERVICO,
+ string=u'Tipo de Serviço',
+ help=u'Campo G025 do CNAB'
+ )
+ forma_lancamento = fields.Selection(
+ selection=FORMA_LANCAMENTO,
+ string=u'Forma Lançamento',
+ help=u'Campo G029 do CNAB'
+ )
+ codigo_convenio = fields.Char(
+ size=20,
+ string=u'Código do Convênio no Banco',
+ help=u'Campo G007 do CNAB',
+ default=u'0001222130126',
+ )
+ codigo_finalidade_doc = fields.Selection(
+ selection=COMPLEMENTO_TIPO_SERVICO,
+ string=u'Complemento do Tipo de Serviço',
+ help=u'Campo P005 do CNAB'
+ )
+ codigo_finalidade_ted = fields.Selection(
+ selection=CODIGO_FINALIDADE_TED,
+ string=u'Código Finalidade da TED',
+ help=u'Campo P011 do CNAB'
+ )
+ codigo_finalidade_complementar = fields.Char(
+ size=2,
+ string=u'Código de finalidade complementar',
+ help=u'Campo P013 do CNAB',
+ )
+ aviso_ao_favorecido = fields.Selection(
+ selection=AVISO_FAVORECIDO,
+ string=u'Aviso ao Favorecido',
+ help=u'Campo P006 do CNAB',
+ default=0,
+ )
+ # A exportação CNAB não se encaixa somente nos parâmetros de
+ # débito e crédito.
diff --git a/l10n_br_account_payment_cobranca/models/payment_order.py b/l10n_br_account_payment_cobranca/models/payment_order.py
new file mode 100644
index 000000000000..6a191ea9253a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/payment_order.py
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# Copyright 2012 KMEE - Fernando Marcato Rodrigues
+# Copyright 2017 KMEE - Hendrix Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from __future__ import division, print_function, unicode_literals
+
+from openerp import models, fields
+
+from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
+ INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO, CODIGO_INSTRUCAO_MOVIMENTO
+
+
+class PaymentOrder(models.Model):
+ _inherit = b'payment.order'
+
+ file_number = fields.Integer(
+ string=u'Número sequencial do arquivo',
+ )
+
+ cnab_file = fields.Binary(
+ string='CNAB File',
+ readonly=True,
+ )
+
+ cnab_filename = fields.Char("CNAB Filename")
+
+ tipo_servico = fields.Selection(
+ selection=TIPO_SERVICO,
+ string=u'Tipo de Serviço',
+ help=u'Campo G025 do CNAB',
+ default='30',
+ )
+ forma_lancamento = fields.Selection(
+ selection=FORMA_LANCAMENTO,
+ string=u'Forma Lançamento',
+ help=u'Campo G029 do CNAB'
+ )
+ codigo_convenio = fields.Char(
+ size=20,
+ string=u'Código do Convênio no Banco',
+ help=u'Campo G007 do CNAB',
+ default=u'0001222130126',
+ )
+ indicativo_forma_pagamento = fields.Selection(
+ selection=INDICATIVO_FORMA_PAGAMENTO,
+ string=u'Indicativo de Forma de Pagamento',
+ help='Campo P014 do CNAB',
+ default='01'
+ )
+ tipo_movimento = fields.Selection(
+ selection=TIPO_MOVIMENTO,
+ string='Tipo de Movimento',
+ help='Campo G060 do CNAB',
+ default='0',
+ )
+ codigo_instrucao_movimento = fields.Selection(
+ selection=CODIGO_INSTRUCAO_MOVIMENTO,
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ default='0',
+ )
+
+ # @api.multi
+ # def set_to_draft(self, *args):
+ # super(PaymentOrder, self).set_to_draft(*args)
+ #
+ # for order in self:
+ # for line in order.line_ids:
+ # self.write_added_state_to_move_line(line.move_line_id)
+ # return True
+
+ # @api.multi
+ # def write_added_state_to_move_line(self, mov_line):
+ # mov_line.state_cnab = 'added'
diff --git a/l10n_br_account_payment_cobranca/models/res_partner.py b/l10n_br_account_payment_cobranca/models/res_partner.py
new file mode 100644
index 000000000000..0ea7a232acf5
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/res_partner.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# #############################################################################
+#
+#
+# Copyright (C) 2016 KMEE (http://www.kmee.com.br)
+# @author Fernando Marcato Rodrigues
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+class ResPartner(models.Model):
+
+ _inherit = 'res.partner'
+
+ type = fields.Selection(selection_add=[
+ ('cnab_cobranca', u'Cobrança CNAB'),
+ ])
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
new file mode 100644
index 000000000000..0892a46b5fc2
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# Copyright 2012 KMEE - Fernando Marcato Rodrigues
+# Copyright 2017 KMEE - Hendrix Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from openerp import models, fields
+
+
+class ResPartnerBank(models.Model):
+ """ Adiciona campos necessários para o cadastramentos de contas
+ bancárias no Brasil."""
+ _inherit = 'res.partner.bank'
+
+ codigo_da_empresa = fields.Integer(
+ u'Código da empresa',
+ size=20,
+ help=u"Será informado pelo banco depois do cadastro do beneficiário "
+ u"na agência"
+ )
+
+ tipo_de_conta = fields.Selection(
+ selection=[
+ ('01', u'Conta corrente individual'),
+ ('02', u'Conta poupança individual'),
+ ('03', u'Conta depósito judicial/Depósito em consignação '
+ u'individual'),
+ ('11', u'Conta corrente conjunta'),
+ ('12', u'Conta poupança conjunta'),
+ ('13', u'Conta depósito judicial/Depósito em consignação '
+ u'conjunta')],
+ string=u'Tipo de Conta',
+ default='01'
+ )
+
+ bra_number = fields.Char(
+ size=5,
+ )
diff --git a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
new file mode 100644
index 000000000000..42a6a0c47e7b
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ CNAB Cobranca
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/security/ir.model.access.csv b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
new file mode 100644
index 000000000000..8ed4b5e73dc6
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
@@ -0,0 +1,6 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,,1,0,0,0
+access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,,1,0
+access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,,1,0,0,0
+access_l10n_br_cnab_sequence,access_l10n_br_cnab_sequence,model_l10n_br_cnab_sequence,,1,0,0,0
+access_l10n_br_cnab_file_sufix_sequence,access_l10n_br_cnab_file_sufix_sequence,model_l10n_br_cnab_file_sufix_sequence,,1,0,0,0
diff --git a/l10n_br_account_payment_cobranca/tests/test_remessa.REM b/l10n_br_account_payment_cobranca/tests/test_remessa.REM
new file mode 100644
index 000000000000..6d4ba831f212
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/tests/test_remessa.REM
@@ -0,0 +1,6 @@
+23100000 281583054000129 01611000000000039500Sua Empresa BANCO BRADESCO S.A. 11303201712000000000108400000
+23100011R01 042 2081583054000129 01611000000000039500Sua Empresa 000001011303201700000000
+2310001300001P 01016110000000000395000000000000000000000030 0 001 0503201700000000010000000000 01A130320170050320170000000000000000000000000000000000000000000000000000000000000000000001 00020 000000000000
+2310001300002Q 012081493979000189Cliente 1 SP Rua Samuel Morse 135 Brooklin 04576060Sao Paulo SP0000000000000000 000
+23100015 00000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000
+23199999 000001000006000000
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
new file mode 100644
index 000000000000..a94442cfa048
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ cnab.account.move.line.form.inherit
+ account.move.line
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
new file mode 100644
index 000000000000..51bba2122811
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ bank.payment.line.form
+ bank.payment.line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
new file mode 100644
index 000000000000..3248e7b7554f
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+ cnab.retorno.tree
+ l10n.br.cnab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.lote.tree
+ l10n.br.cnab.lote
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.evento.tree
+ l10n.br.cnab.evento
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.retorno.evento.form.view
+ l10n.br.cnab.evento
+
+
+
+
+
+
+ cnab.retorno.lote.form.view
+ l10n.br.cnab.lote
+
+
+
+
+
+
+ cnab.retorno.form.view
+ l10n.br.cnab
+
+
+
+
+
+
+ CNAB Retorno
+ ir.actions.act_window
+ l10n.br.cnab
+ form
+ tree,form
+
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
new file mode 100644
index 000000000000..99ac15f8201a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+ l10n_br_cnab_sequence.form.view
+ l10n_br_cnab.sequence
+
+
+
+
+
+
+
+
+ l10n_br_cnab_sequence.tree.view
+ l10n_br_cnab.sequence
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
new file mode 100644
index 000000000000..981c64005747
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+ [('payment_order_type', '=', 'payment')]
+ {'search_payment_order_type': 'payment'}
+
+
+
+ Cobranca
+ payment.order
+ form
+ tree,form
+ {'search_payment_order_type': 'cobranca',
+ 'default_payment_order_type': 'cobranca'}
+
+ [('payment_order_type', '=', 'cobranca')]
+ Crie ordens de cobrança CNAB 240.
+
+
+
+
+
+ payment.order.form
+ payment.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [('payment_order_type', '=', payment_order_type)]
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
new file mode 100644
index 000000000000..c809942e9ef2
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
@@ -0,0 +1,123 @@
+
+
+
+
+
+ Linhas de Cobrança
+ payment.line
+ order_id
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Linhas de Cobrança Select
+ payment.line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Linhas de cobrança
+ payment.line
+ form
+ tree,form
+ {}
+
+
+ []
+
+ Lista das linhas cnab 400.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
new file mode 100644
index 000000000000..ae19e1e1a5e2
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ payment.cnab.form
+ payment.cnab
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_line.xml b/l10n_br_account_payment_cobranca/views/payment_line.xml
new file mode 100644
index 000000000000..c5dfbf9c91ca
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/payment_line.xml
@@ -0,0 +1,25 @@
+
+
+
+ payment.order.form
+
+ payment.order
+
+
+ {'order_id': active_id or False,
+ 'default_mode': mode}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
new file mode 100644
index 000000000000..abec16ccf310
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/payment_mode.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ cnab.payment.mode.l10n_br_payment.form.inherit
+ payment.mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_order.xml b/l10n_br_account_payment_cobranca/views/payment_order.xml
new file mode 100644
index 000000000000..d71dc0b19762
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/payment_order.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ payment.order.form.sequence
+ payment.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
new file mode 100644
index 000000000000..88e755102926
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ view_cnab_bank_acc_dig.partner.bank.form
+ res.partner.bank
+
+
+
+
+
+
+
+
+
+ {'required': True}
+
+
+
+ {'required': True}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_cobranca/wizard/__init__.py
new file mode 100644
index 000000000000..9f670fca1fa8
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/wizard/__init__.py
@@ -0,0 +1,25 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import payment_order_create
+from . import l10n_bank_payment_cnab_export
diff --git a/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py b/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
new file mode 100644
index 000000000000..b95104224e51
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
@@ -0,0 +1,105 @@
+# coding: utf-8
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import base64
+import time
+
+from openerp import models, api, workflow, fields, _
+from openerp.exceptions import Warning as UserError
+from ..febraban.cnab import Cnab
+
+import logging
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.errors import (Cnab240Error)
+except ImportError as err:
+ _logger.debug = err
+
+
+class L10nPaymentCnab(models.TransientModel):
+ _name = 'payment.cnab'
+ _description = 'Export payment order(s) in cnab layout'
+
+ name = fields.Char(string=u'Nome', size=255)
+
+ cnab_file = fields.Binary(string='CNAB File', readonly=True)
+
+ state = fields.Selection(
+ string='state',
+ selection=[('init', 'init'), ('done', 'done')],
+ default='init',
+ readonly=True
+ )
+
+ @api.multi
+ def export(self):
+ for order_id in self.env.context.get('active_ids', []):
+
+ order = self.env['payment.order'].browse(order_id)
+ if not order.line_ids:
+ raise UserError(
+ _('Error'),
+ _('Adicione pelo menos uma linha na ordem de pagamento.'))
+
+ # Criando instancia do CNAB a partir do código do banco
+ cnab = Cnab.get_cnab(
+ order.mode.bank_id.bank_bic, order.mode.type.code)()
+
+ # Criando remessa de eventos
+ try:
+ remessa = cnab.remessa(order)
+ except Cnab240Error as e:
+ from openerp import exceptions
+ raise exceptions.ValidationError(
+ "Campo preenchido incorretamente \n\n{0}".format(e))
+
+ if order.mode.type.code == '240':
+ self.name = 'CB%s%s.REM' % (
+ time.strftime('%d%m'), str(order.file_number))
+ # elif order.mode.type.code == '400':
+ # self.name = 'CB%s%s.REM' % (
+ # time.strftime('%d%m'), str(suf_arquivo))
+ elif order.mode.type.code == '500':
+ self.name = 'PG%s%s.REM' % (
+ time.strftime('%d%m'), str(order.file_number))
+ self.state = 'done'
+ self.cnab_file = base64.b64encode(remessa)
+ order.cnab_file = base64.b64encode(remessa)
+ order.cnab_filename = self.name
+
+ workflow.trg_validate(
+ self.env.uid, 'payment.order', order_id, 'done', self.env.cr)
+
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': self._name,
+ 'view_mode': 'form',
+ 'view_type': 'form',
+ 'res_id': self.id,
+ 'target': 'new',
+ }
+
+ @api.multi
+ def done(self):
+ return {'type': 'ir.actions.act_window_close'}
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
new file mode 100644
index 000000000000..6714b4965af9
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -0,0 +1,139 @@
+# -*- coding: utf-8 -*-
+# ###########################################################################
+#
+# Author: Luis Felipe Mileo
+# Fernando Marcato Rodrigues
+# Daniel Sadamo Hirayama
+# Copyright 2015 KMEE - www.kmee.com.br
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+from openerp import models, api
+
+
+class PaymentOrderCreate(models.TransientModel):
+ _inherit = 'payment.order.create'
+
+ @api.multi
+ def extend_payment_order_domain(self, payment_order, domain):
+ super(PaymentOrderCreate, self).extend_payment_order_domain(
+ payment_order, domain)
+
+ if payment_order.mode.type.code == '240':
+ if payment_order.mode.payment_order_type == 'cobranca':
+ domain += [
+ ('debit', '>', 0)
+ ]
+
+ # TODO: Refactor this
+ if ('invoice.payment_mode_id', '=', False) in domain:
+ domain.remove(('invoice.payment_mode_id', '=', False))
+ if ('date_maturity', '<=', self.duedate) in domain:
+ domain.remove(('date_maturity', '<=', self.duedate))
+ if ('date_maturity', '=', False) in domain:
+ domain.remove(('date_maturity', '=', False))
+ if ('date_maturity', '<=', self.duedate) in domain:
+ domain.remove(('date_maturity', '<=', self.duedate))
+
+ elif payment_order.mode.type.code == '400':
+ if payment_order.mode.payment_order_type == 'cobranca':
+ domain += [
+ ('debit', '>', 0),
+ ('account_id.type', '=', 'receivable'),
+ '&',
+ ('payment_mode_id', '=', payment_order.mode.id),
+ '&',
+ ('invoice.state', '=', 'open'),
+ ('invoice.fiscal_category_id.'
+ 'property_journal.revenue_expense', '=', True)
+ ]
+ # TODO: Refactory this
+ # TODO: domain do state da move_line.
+ # index = domain.index(('invoice.payment_mode_id', '=', False))
+ # del domain[index - 1]
+ # domain.removemove(('invoice.payment_mode_id', '=', False))
+ # index = domain.index(('date_maturity', '<=', self.duedate))
+ # del domain[index - 1]
+ # domain.remove(('date_maturity', '=', False))
+ # domain.remove(('date_maturity', '<=', self.duedate))
+
+ elif payment_order.mode.type.code == '500':
+ if payment_order.mode.payment_order_type == 'payment':
+ domain += [
+ '&', ('credit', '>', 0),
+ ('account_id.type', '=', 'payable')
+ ]
+ # index = domain.index(('invoice.payment_mode_id', '=', False))
+ # del domain[index - 1]
+ # domain.remove(('invoice.payment_mode_id', '=', False))
+ # index = domain.index(('date_maturity', '<=', self.duedate))
+ # del domain[index - 1]
+ # domain.remove(('date_maturity', '=', False))
+ # domain.remove(('date_maturity', '<=', self.duedate))
+
+ index = domain.index(('account_id.type', '=', 'receivable'))
+ del domain[index - 1]
+ domain.remove(('account_id.type', '=', 'receivable'))
+
+ return True
+
+ @api.multi
+ def _prepare_payment_line(self, payment, line):
+ res = super(PaymentOrderCreate, self)._prepare_payment_line(
+ payment, line)
+
+ # res['communication2'] = line.payment_mode_id.comunicacao_2
+ res['percent_interest'] = line.payment_mode_id.cnab_percent_interest
+
+ if payment.mode.type.code == '400':
+ # write bool to move_line to avoid it being added on cnab again
+ self.write_cnab_rejected_bool(line)
+
+ return res
+
+ @api.multi
+ def filter_lines(self, lines):
+ """ Filter move lines before proposing them for inclusion
+ in the payment order.
+
+ This implementation filters out move lines that are already
+ included in draft or open payment orders. This prevents the
+ user to include the same line in two different open payment
+ orders. When the payment order is sent, it is assumed that
+ the move will be reconciled soon (or immediately with
+ account_banking_payment_transfer), so it will not be
+ proposed anymore for payment.
+
+ See also https://github.com/OCA/bank-payment/issues/93.
+
+ :param lines: recordset of move lines
+ :returns: list of move line ids
+ """
+
+ self.ensure_one()
+ payment_lines = self.env['payment.line'].\
+ search([('order_id.state', 'in', ('draft', 'open', 'done')),
+ ('move_line_id', 'in', lines.ids)])
+ # Se foi exportada e o cnab_rejeitado dela for true, pode adicionar
+ # de novo
+ to_exclude = set([l.move_line_id.id for l in payment_lines
+ if not l.move_line_id.is_cnab_rejected])
+ return [l.id for l in lines if l.id not in to_exclude]
+
+ @api.multi
+ def write_cnab_rejected_bool(self, line):
+ line.write({'is_cnab_rejected': False})
From 51e0cc8f8537d9b9cfa25819e35a1bcbfb98ea87 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 11:52:21 -0300
Subject: [PATCH 050/612] [MOV] Arquivos l10n_br_account_payment_boleto ->
l10n_br_account_payment_cobranca
---
.../boleto/__init__.py | 23 ++
.../boleto/document.py | 317 ++++++++++++++++++
.../data/boleto_data.xml | 18 +
.../demo/payment_demo.xml | 163 +++++++++
.../models/account_invoice.py | 64 ++++
.../models/account_move_line.py | 53 ++-
.../models/payment_mode.py | 46 +++
.../models/res_company.py | 44 +++
.../reports/__init__.py | 23 ++
.../reports/report.py | 81 +++++
.../reports/report_print_button_view.xml | 13 +
.../views/account_move_line.xml | 14 +
.../views/payment_mode.xml | 12 +
.../views/res_company.xml | 23 ++
14 files changed, 893 insertions(+), 1 deletion(-)
create mode 100644 l10n_br_account_payment_cobranca/boleto/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/boleto/document.py
create mode 100644 l10n_br_account_payment_cobranca/data/boleto_data.xml
create mode 100644 l10n_br_account_payment_cobranca/demo/payment_demo.xml
create mode 100644 l10n_br_account_payment_cobranca/models/account_invoice.py
create mode 100644 l10n_br_account_payment_cobranca/models/res_company.py
create mode 100644 l10n_br_account_payment_cobranca/reports/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/reports/report.py
create mode 100644 l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
create mode 100644 l10n_br_account_payment_cobranca/views/res_company.xml
diff --git a/l10n_br_account_payment_cobranca/boleto/__init__.py b/l10n_br_account_payment_cobranca/boleto/__init__.py
new file mode 100644
index 000000000000..4696cdeed55d
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/boleto/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import document
diff --git a/l10n_br_account_payment_cobranca/boleto/document.py b/l10n_br_account_payment_cobranca/boleto/document.py
new file mode 100644
index 000000000000..90bfc82cd0a4
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/boleto/document.py
@@ -0,0 +1,317 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from datetime import datetime, date
+import logging
+
+_logger = logging.getLogger(__name__)
+
+try:
+ from pyboleto import bank
+except ImportError as err:
+ _logger.debug = err
+
+
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+BoletoException = bank.BoletoException
+
+
+class Boleto:
+ boleto = object
+ account_number = ''
+ account_digit = ''
+
+ branch_number = ''
+ branch_digit = ''
+
+ nosso_numero = ''
+
+ @staticmethod
+ def getBoleto(move_line, nosso_numero):
+ boleto_type = move_line.payment_mode_id.boleto_type
+ if boleto_type:
+ return dict_boleto[boleto_type][0](move_line, nosso_numero)
+ raise BoletoException(u'Configure o tipo de boleto no modo de '
+ u'pagamento')
+
+ @staticmethod
+ def getBoletoClass(move_line):
+ bank_code = move_line.payment_mode_id.bank_id.bank.bic
+ return bank.get_class_for_codigo(bank_code)
+
+ def __init__(self, move_line, nosso_numero):
+ self._cedente(move_line.company_id)
+ self._sacado(move_line.partner_id)
+ self._move_line(move_line)
+ self.nosso_numero = str(nosso_numero)
+
+ def getAccountNumber(self):
+ if self.account_digit:
+ return str(self.account_number + '-' +
+ self.account_digit).encode('utf-8')
+ return self.account_number.encode('utf-8')
+
+ def getBranchNumber(self):
+ if self.branch_digit:
+ return str(self.branch_number + '-' +
+ self.branch_digit).encode('utf-8')
+ return self.branch_number.encode('utf-8')
+
+ def _move_line(self, move_line):
+ self._payment_mode(move_line.payment_mode_id)
+ self.boleto.data_vencimento = datetime.date(datetime.strptime(
+ move_line.date_maturity, '%Y-%m-%d'))
+ self.boleto.data_documento = datetime.date(datetime.strptime(
+ move_line.invoice.date_invoice, '%Y-%m-%d'))
+ self.boleto.data_processamento = date.today()
+ self.boleto.valor = str("%.2f" % move_line.debit or move_line.credit)
+ self.boleto.valor_documento = str("%.2f" % move_line.debit or
+ move_line.credit)
+ self.boleto.especie = \
+ move_line.currency_id and move_line.currency_id.symbol or 'R$'
+ self.boleto.quantidade = '' # str("%.2f" % move_line.amount_currency)
+ self.boleto.numero_documento = move_line.name.encode('utf-8')
+
+ def _payment_mode(self, payment_mode_id):
+ """
+ :param payment_mode:
+ :return:
+ """
+ self.boleto.convenio = payment_mode_id.boleto_convenio
+ self.boleto.especie_documento = payment_mode_id.boleto_modalidade
+ self.boleto.aceite = payment_mode_id.boleto_aceite
+ self.boleto.carteira = str(payment_mode_id.boleto_carteira)
+
+ def _cedente(self, company):
+ """
+ :param company:
+ :return:
+ """
+ self.boleto.cedente = company.partner_id.legal_name.encode('utf-8')
+ self.boleto.cedente_documento = company.cnpj_cpf.encode('utf-8')
+ self.boleto.cedente_bairro = company.district
+ self.boleto.cedente_cep = company.zip
+ self.boleto.cedente_cidade = company.city
+ self.boleto.cedente_logradouro = company.street + ', ' + company.number
+ self.boleto.cedente_uf = company.state_id.code
+ self.boleto.agencia_cedente = self.getBranchNumber()
+ self.boleto.conta_cedente = self.getAccountNumber()
+
+ def _sacado(self, partner):
+ """
+
+ :param partner:
+ :return:
+ """
+ self.boleto.sacado_endereco = partner.street + ', ' + partner.number
+ self.boleto.sacado_cidade = partner.city
+ self.boleto.sacado_bairro = partner.district
+ self.boleto.sacado_uf = partner.state_id.code
+ self.boleto.sacado_cep = partner.zip
+ self.boleto.sacado_nome = partner.legal_name
+ self.boleto.sacado_documento = partner.cnpj_cpf
+
+ @classmethod
+ def get_pdfs(cls, boleto_list):
+ """
+
+ :param boletoList:
+ :return:
+ """
+ fbuffer = StringIO()
+
+ fbuffer.reset()
+ from pyboleto.pdf import BoletoPDF
+
+ boleto = BoletoPDF(fbuffer)
+ for i in range(len(boleto_list)):
+ boleto.drawBoleto(boleto_list[i])
+ boleto.nextPage()
+ boleto.save()
+ boleto_file = fbuffer.getvalue()
+
+ fbuffer.close()
+ return boleto_file
+
+
+class BoletoBB(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ # TODO: size o convenio and nosso numero, replace (7,2)
+ # Size of convenio 4, 6, 7 or 8
+ # Nosso Numero format. 1 or 2
+ # Used only for convenio=6
+ # 1: Nosso Numero with 5 positions
+ # 2: Nosso Numero with 17 positions
+ self.boleto = Boleto.getBoletoClass(move_line)(7, 2)
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoBarisul(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoBradesco(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ # bank specific
+ self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
+ self.branch_digit = move_line.payment_mode_id.bank_id.bra_number_dig
+ # end bank specific
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoCaixa(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ # bank specific
+ self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
+ # end bank specific
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoHsbc(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoItau157(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoItau(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoReal(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoSantander101(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.ios = '0'
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoStatander101201(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.ios = '0'
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+class BoletoCaixaSigcb(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ from pyboleto.bank.caixa_sigcb import BoletoCaixaSigcb
+ self.boleto = BoletoCaixaSigcb()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ # bank specific
+ self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
+ # end bank specific
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+class BoletoSicredi(Boleto):
+
+ def __init__(self, move_line, nosso_numero):
+ self.boleto = Boleto.getBoletoClass(move_line)()
+ self.account_number = move_line.payment_mode_id.bank_id.acc_number
+ self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ Boleto.__init__(self, move_line, nosso_numero)
+ self.boleto.nosso_numero = self.nosso_numero
+
+
+dict_boleto = {
+ '1': (BoletoBB, 'Banco do Brasil 18'),
+ '2': (BoletoBarisul, 'Barisul x'),
+ '3': (BoletoBradesco, 'Bradesco 06, 03'),
+ '4': (BoletoCaixa, 'Caixa Economica SR'),
+ '5': (BoletoHsbc, 'HSBC CNR CSB'),
+ '6': (BoletoItau157, 'Itau 157'),
+ '7': (BoletoItau, 'Itau 175, 174, 178, 104, 109'),
+ '8': (BoletoReal, 'Real 57'),
+ '9': (BoletoSantander101, 'Santander 102'),
+ '10': (BoletoStatander101201, 'Santander 101, 201'),
+ '11': (BoletoCaixaSigcb, 'Caixa Sigcb'),
+ '12': (BoletoSicredi, 'Sicredi'),
+}
+
+
+def getBoletoSelection():
+ list = []
+ for i in dict_boleto:
+ list.append((i, dict_boleto[i][1]))
+ return list
diff --git a/l10n_br_account_payment_cobranca/data/boleto_data.xml b/l10n_br_account_payment_cobranca/data/boleto_data.xml
new file mode 100644
index 000000000000..2dff8a649c45
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/data/boleto_data.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ Nosso número
+
+
+
+ Sequêncial Único da Fatura
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/demo/payment_demo.xml b/l10n_br_account_payment_cobranca/demo/payment_demo.xml
new file mode 100644
index 000000000000..0a0e31ed2376
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/demo/payment_demo.xml
@@ -0,0 +1,163 @@
+
+
+
+
+ Boleto sem registro Banco do Brasil
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 1
+ 27
+ 18
+ DM
+ 29
+
+
+
+
+ Boleto sem registro Bradesco
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 3
+ 06
+ 03
+ DM
+ 19
+
+
+
+
+ Boleto sem registro HSBC
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 5
+
+ CNR
+ PD
+
+
+
+
+
+ Boleto sem registro ITAU
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 7
+ 99999999
+ 109
+ DM
+
+
+
+
+
+
+ Boleto sem registro Santander
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 9
+
+ 102
+ DM
+
+
+
+
+
+ Boleto sem registro Caixa Economica SR
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 4
+
+ SR
+
+
+
+
+
+
+ Boleto sem registro Caixa Economica SR
+
+
+
+
+
+
+ 00
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ 11
+
+ SR
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
new file mode 100644
index 000000000000..91d28d71a070
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+# @author Danimar Ribeiro
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import logging
+
+from openerp import models, api
+
+_logger = logging.getLogger(__name__)
+
+
+class AccountInvoice(models.Model):
+ _inherit = 'account.invoice'
+
+ @api.multi
+ def action_move_create(self):
+ value = super(AccountInvoice, self).action_move_create()
+
+ for invoice in self:
+ sequence = self.env['ir.sequence'].next_by_id(
+ self.company_id.transaction_id_sequence.id)
+ invoice.transaction_id = sequence
+
+ return value
+
+ @api.multi
+ def finalize_invoice_move_lines(self, move_lines):
+ """ Propagate the transaction_id from the invoice to the move lines.
+
+ The transaction id is written on the move lines only if the account is
+ the same than the invoice's one.
+ """
+ move_lines = super(AccountInvoice, self).finalize_invoice_move_lines(
+ move_lines)
+ for invoice in self:
+ if invoice.transaction_id:
+ invoice_account_id = invoice.account_id.id
+ index = 1
+ for line in move_lines:
+ # line is a tuple (0, 0, {values})
+ if invoice_account_id == line[2]['account_id']:
+ line[2]['transaction_ref'] = u'{0}/{1:02d}'.format(
+ invoice.transaction_id, index)
+ index += 1
+ return move_lines
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index de3b62a1abaf..5e7da60972bb 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -20,8 +20,16 @@
#
##############################################################################
-from openerp import models, fields
+import logging
+from datetime import date
+
+from openerp import models, fields, api
+
+from ..boleto.document import Boleto
+from ..boleto.document import BoletoException
+
+_logger = logging.getLogger(__name__)
# ESTADOS_CNAB = [
# ('draft', u'Inicial'),
@@ -47,3 +55,46 @@ class AccounMoveLine(models.Model):
# select=True,
# store=True,
# related='name')
+ date_payment_created = fields.Date(
+ u'Data da criação do pagamento', readonly=True)
+ boleto_own_number = fields.Char(
+ u'Nosso Número', readonly=True)
+
+ @api.multi
+ def send_payment(self):
+ boleto_list = []
+
+ for move_line in self:
+ try:
+
+ if move_line.payment_mode_id.type_payment == '00':
+ number_type = move_line.company_id.own_number_type
+ if not move_line.boleto_own_number:
+ if number_type == '0':
+ nosso_numero = self.env['ir.sequence'].next_by_id(
+ move_line.company_id.own_number_sequence.id)
+ elif number_type == '1':
+ nosso_numero = \
+ move_line.transaction_ref.replace('/', '')
+ else:
+ nosso_numero = self.env['ir.sequence'].next_by_id(
+ move_line.payment_mode_id.
+ internal_sequence_id.id)
+ else:
+ nosso_numero = move_line.boleto_own_number
+
+ boleto = Boleto.getBoleto(move_line, nosso_numero)
+ if boleto:
+ move_line.date_payment_created = date.today()
+ move_line.transaction_ref = \
+ boleto.boleto.format_nosso_numero()
+ move_line.boleto_own_number = nosso_numero
+
+ boleto_list.append(boleto.boleto)
+ except BoletoException as be:
+ _logger.error(be.message or be.value, exc_info=True)
+ continue
+ except Exception as e:
+ _logger.error(e.message or e.value, exc_info=True)
+ continue
+ return boleto_list
diff --git a/l10n_br_account_payment_cobranca/models/payment_mode.py b/l10n_br_account_payment_cobranca/models/payment_mode.py
index 18de555a5073..6e729fa41f23 100644
--- a/l10n_br_account_payment_cobranca/models/payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/payment_mode.py
@@ -21,10 +21,15 @@
##############################################################################
from openerp import models, fields
+from openerp.exceptions import ValidationError
from openerp.addons import decimal_precision as dp
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, AVISO_FAVORECIDO
+from ..boleto.document import getBoletoSelection
+
+selection = getBoletoSelection()
+
class PaymentMode(models.Model):
_inherit = "payment.mode"
@@ -75,3 +80,44 @@ class PaymentMode(models.Model):
)
# A exportação CNAB não se encaixa somente nos parâmetros de
# débito e crédito.
+ boleto_carteira = fields.Char('Carteira', size=3)
+ boleto_modalidade = fields.Char('Modalidade', size=2)
+ boleto_convenio = fields.Char(u'Codigo convênio', size=10)
+ boleto_variacao = fields.Char(u'Variação', size=2)
+ boleto_cnab_code = fields.Char(u'Código Cnab', size=20)
+ boleto_aceite = fields.Selection(
+ [('S', 'Sim'), ('N', 'Não')], string='Aceite', default='N')
+ boleto_type = fields.Selection(
+ selection, string="Boleto")
+ boleto_especie = fields.Selection([
+ ('01', u'DUPLICATA MERCANTIL'),
+ ('02', u'NOTA PROMISSÓRIA'),
+ ('03', u'NOTA DE SEGURO'),
+ ('04', u'MENSALIDADE ESCOLAR'),
+ ('05', u'RECIBO'),
+ ('06', u'CONTRATO'),
+ ('07', u'COSSEGUROS'),
+ ('08', u'DUPLICATA DE SERVIÇO'),
+ ('09', u'LETRA DE CÂMBIO'),
+ ('13', u'NOTA DE DÉBITOS'),
+ ('15', u'DOCUMENTO DE DÍVIDA'),
+ ('16', u'ENCARGOS CONDOMINIAIS'),
+ ('17', u'CONTA DE PRESTAÇÃO DE SERVIÇOS'),
+ ('99', u'DIVERSOS'),
+ ], string=u'Espécie do Título', default='01')
+ boleto_protesto = fields.Selection([
+ ('0', u'Sem instrução'),
+ ('1', u'Protestar (Dias Corridos)'),
+ ('2', u'Protestar (Dias Úteis)'),
+ ('3', u'Não protestar'),
+ ('7', u'Negativar (Dias Corridos)'),
+ ('8', u'Não Negativar')
+ ], string=u'Códigos de Protesto', default='0')
+ boleto_protesto_prazo = fields.Char(u'Prazo protesto', size=2)
+
+ @api.constrains('boleto_type', 'boleto_carteira',
+ 'boleto_modalidade', 'boleto_convenio',
+ 'boleto_variacao', 'boleto_aceite')
+ def boleto_restriction(self):
+ if self.boleto_type == '6' and not self.boleto_carteira:
+ raise ValidationError(u'Carteira no banco Itaú é obrigatória')
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
new file mode 100644
index 000000000000..9d34486e2ca1
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, fields
+
+
+class ResCompany(models.Model):
+ _inherit = 'res.company'
+
+ own_number_type = fields.Selection(
+ selection=[
+ ('0', u'Sequêncial único por empresa'),
+ ('1', u'Numero sequêncial da Fatura'),
+ ('2', u'Sequêncial único por modo de pagamento'), ],
+ string=u'Tipo de nosso número',
+ default='2'
+ )
+
+ own_number_sequence = fields.Many2one(
+ comodel_name='ir.sequence',
+ string=u'Sequência do Nosso Número'
+ )
+
+ transaction_id_sequence = fields.Many2one('ir.sequence',
+ string=u'Sequência da fatura')
diff --git a/l10n_br_account_payment_cobranca/reports/__init__.py b/l10n_br_account_payment_cobranca/reports/__init__.py
new file mode 100644
index 000000000000..50bba6033514
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/reports/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import report
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
new file mode 100644
index 000000000000..49f6a2d09b96
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Account Payment Boleto module for Odoo
+# Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
+# @author Luis Felipe Miléo
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from __future__ import with_statement
+
+from openerp import pooler
+from openerp.osv import osv
+from openerp.report.interface import report_int
+from openerp.report.render import render
+
+from ..boleto.document import Boleto
+
+
+class ExternalPdf(render):
+
+ def __init__(self, pdf):
+ render.__init__(self)
+ self.pdf = pdf
+ self.output_type = 'pdf'
+
+ def _render(self):
+ return self.pdf
+
+
+class ReportCustom(report_int):
+ """
+ Custom report for return boletos
+ """
+
+ def create(self, cr, uid, ids, datas, context=False):
+ if not context:
+ context = {}
+ active_ids = context.get('active_ids')
+ active_model = context.get('active_model')
+ pool = pooler.get_pool(cr.dbname)
+ ids_move_lines = []
+
+ aml_obj = pool.get('account.move.line')
+
+ if active_model == 'account.invoice':
+ ai_obj = pool.get('account.invoice')
+ for account_invoice in ai_obj.browse(cr, uid, active_ids):
+ for move_line in account_invoice.move_line_receivable_id:
+ ids_move_lines.append(move_line.id)
+ elif active_model == 'account.move.line':
+ ids_move_lines = active_ids
+ else:
+ return False
+
+ boleto_list = aml_obj.send_payment(cr, uid, ids_move_lines)
+ if not boleto_list:
+ raise osv.except_osv(
+ 'Error !', ('Não é possível gerar os boletos\n'
+ 'Certifique-se que a fatura esteja confirmada e o '
+ 'forma de pagamento seja duplicatas'))
+ pdf_string = Boleto.get_pdfs(boleto_list)
+ self.obj = ExternalPdf(pdf_string)
+ self.obj.render()
+ return self.obj.pdf, 'pdf'
+
+
+ReportCustom('report.l10n_br_account_payment_boleto.report')
diff --git a/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml b/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
new file mode 100644
index 000000000000..9881bc43547c
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index a94442cfa048..7090b3d87a15 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -15,5 +15,19 @@
+
+
+ Payments
+ account.move.line
+ partner_id
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
index abec16ccf310..6aef2e43aa2d 100644
--- a/l10n_br_account_payment_cobranca/views/payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_mode.xml
@@ -25,6 +25,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
new file mode 100644
index 000000000000..f7c818daecc5
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ l10n_br_account_payment_boleto.res.company.form
+
+ res.company
+
+
+
+
+
+
+
+
+
+
+
+
+
From 9ce0dc6f5fa38cd257b87b2ea1c0618d9c803611 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 11:59:58 -0300
Subject: [PATCH 051/612] [REF] pep8
Signed-off-by: Luis Felipe Mileo
---
.../boleto/document.py | 2 +-
.../data/l10n_br_payment_export_type.xml | 5 +-
.../demo/l10n_br_payment_mode.xml | 30 ++-
.../demo/payment_demo.xml | 3 +-
.../febraban/cnab_240/cnab_240.py | 2 +-
.../febraban/cnab_400/cnab_400.py | 22 +--
.../febraban/pag_for/pag_for500.py | 7 +-
.../models/__init__.py | 12 +-
.../models/account_move_line.py | 4 +-
.../models/bank_payment_line.py | 2 +-
.../models/payment_mode.py | 2 +-
.../models/res_partner.py | 1 -
.../security/cnab_cobranca_security.xml | 3 +-
.../views/bank_payment_line.xml | 14 +-
.../views/l10n_br_cnab_retorno_view.xml | 177 +++++++++++-------
.../views/l10n_br_cobranca_cnab.xml | 47 +++--
.../views/l10n_br_cobranca_cnab_lines.xml | 123 ++++++------
.../views/l10n_br_payment_cnab.xml | 5 +-
.../views/payment_line.xml | 9 +-
.../views/payment_mode.xml | 9 +-
.../views/payment_order.xml | 6 +-
.../views/res_partner_bank.xml | 5 +-
.../wizard/payment_order_create.py | 2 +-
23 files changed, 296 insertions(+), 196 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/boleto/document.py b/l10n_br_account_payment_cobranca/boleto/document.py
index 90bfc82cd0a4..9ad1fa58d085 100644
--- a/l10n_br_account_payment_cobranca/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/boleto/document.py
@@ -30,7 +30,6 @@
except ImportError as err:
_logger.debug = err
-
try:
from cStringIO import StringIO
except ImportError:
@@ -284,6 +283,7 @@ def __init__(self, move_line, nosso_numero):
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
+
class BoletoSicredi(Boleto):
def __init__(self, move_line, nosso_numero):
diff --git a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
index fe787b74e9db..4cc23eb2328b 100644
--- a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
+++ b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
@@ -3,13 +3,14 @@
-
+
240
Cnab240
True
payment
-
+
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index c826dfe962e7..8fa8e05cd17b 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -6,13 +6,17 @@
Cobrança Bradesco240
-
+
-
+
00
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o
+ vencimento
+
3
06
03
@@ -25,13 +29,17 @@
Cobrança Itau240
-
+
-
+
00
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o
+ vencimento
+
6
06
03
@@ -44,13 +52,17 @@
Cobrança Cef240
-
+
-
+
00
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o
+ vencimento
+
11
06
03
diff --git a/l10n_br_account_payment_cobranca/demo/payment_demo.xml b/l10n_br_account_payment_cobranca/demo/payment_demo.xml
index 0a0e31ed2376..354c96ed1b81 100644
--- a/l10n_br_account_payment_cobranca/demo/payment_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/payment_demo.xml
@@ -86,7 +86,8 @@
99999999
109
DM
-
+
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index e9e91468814e..35e8e0add393 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -303,7 +303,7 @@ def _prepare_cobranca(self, line):
self.rmchar(line.partner_id.cnpj_cpf)),
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
- line.partner_id.street + ' ' + line.partner_id.number),
+ line.partner_id.street + ' ' + line.partner_id.number),
'sacado_bairro': line.partner_id.district,
'sacado_cep': self.get_cep('prefixo', line.partner_id.zip),
'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index cb1e3d8f3629..e9fbade762f6 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -355,17 +355,17 @@ def monta_endereco(self, partner_item):
distrito = self.check_address_item_filled(partner_item.district)
str_endereco = (
- street +
- ' ' +
- number +
- ' ' +
- complemento +
- ' ' +
- distrito
- # + ' ' +
- # partner_item.l10n_br_city_id.name +
- # ' ' + partner_item.state_id.name
- )
+ street +
+ ' ' +
+ number +
+ ' ' +
+ complemento +
+ ' ' +
+ distrito
+ # + ' ' +
+ # partner_item.l10n_br_city_id.name +
+ # ' ' + partner_item.state_id.name
+ )
return str_endereco
def check_address_item_filled(self, item):
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index 36668325fbb4..81e672603e3d 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -203,10 +203,10 @@ def _prepare_header(self):
'cedente_agencia': int(self.order.mode.bank_id.bra_number),
'cedente_conta': int(self.order.mode.bank_id.acc_number),
'cedente_agencia_conta_dv':
- self.order.mode.bank_id.bra_number_dig,
+ self.order.mode.bank_id.bra_number_dig,
'nome_empresa_pagadora': self.order.company_id.legal_name,
'cedente_codigo_agencia_digito':
- self.order.mode.bank_id.bra_number_dig,
+ self.order.mode.bank_id.bra_number_dig,
'arquivo_codigo': 1, # Remessa/Retorno
'servico_operacao': u'R',
'reservado_empresa': u'BRADESCO PAG FOR',
@@ -276,7 +276,7 @@ def _prepare_cobranca(self, line, vals):
self.rmchar(line.partner_id.cnpj_cpf)[12:14]),
'nome_forn': line.partner_id.legal_name,
'endereco_forn': (
- line.partner_id.street + ' ' + line.partner_id.number),
+ line.partner_id.street + ' ' + line.partner_id.number),
'cep_forn': int(prefixo),
'cep_complemento_forn': int(sulfixo),
@@ -446,7 +446,6 @@ def lancamento_ted(self, line):
'conta_complementar': int(self.order.mode.bank_id.acc_number),
'especie_titulo': line.order_id.mode.type_purchase_payment,
-
# TODO: código do banco. Para a Modalidade de Pagamento valor
# pode variar
'codigo_banco_forn': int(line.bank_id.bank.bic),
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index 06bababd5de4..42be772ce912 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
+from . import account_invoice
from . import account_move_line
-from . import payment_order
-from . import l10n_br_cnab_sequence
+# from . import bank_payment_line
+from . import l10n_br_cnab
from . import l10n_br_cnab_file_sufix_sequence
+from . import l10n_br_cnab_sequence
+from . import payment_line
from . import payment_mode
+from . import payment_order
+from . import res_company
from . import res_partner_bank
from . import res_partner
from .. import constantes
-from . import payment_line
-# from . import bank_payment_line
-from . import l10n_br_cnab
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 5e7da60972bb..5445300514a0 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -31,6 +31,7 @@
_logger = logging.getLogger(__name__)
+
# ESTADOS_CNAB = [
# ('draft', u'Inicial'),
# ('added', u'Adicionada à ordem de pagamento'),
@@ -79,7 +80,8 @@ def send_payment(self):
else:
nosso_numero = self.env['ir.sequence'].next_by_id(
move_line.payment_mode_id.
- internal_sequence_id.id)
+ internal_sequence_id.id
+ )
else:
nosso_numero = move_line.boleto_own_number
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index f7c4560c4694..a49923e289d2 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -105,4 +105,4 @@ def same_fields_payment_line_and_bank_payment_line(self):
# 'currency', 'partner_id',
# 'bank_id', 'date', 'state']
- return same_fields
\ No newline at end of file
+ return same_fields
diff --git a/l10n_br_account_payment_cobranca/models/payment_mode.py b/l10n_br_account_payment_cobranca/models/payment_mode.py
index 6e729fa41f23..9025a573832b 100644
--- a/l10n_br_account_payment_cobranca/models/payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/payment_mode.py
@@ -20,7 +20,7 @@
#
##############################################################################
-from openerp import models, fields
+from openerp import api, fields, models
from openerp.exceptions import ValidationError
from openerp.addons import decimal_precision as dp
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
diff --git a/l10n_br_account_payment_cobranca/models/res_partner.py b/l10n_br_account_payment_cobranca/models/res_partner.py
index 0ea7a232acf5..040dc54018ed 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner.py
@@ -24,7 +24,6 @@
class ResPartner(models.Model):
-
_inherit = 'res.partner'
type = fields.Selection(selection_add=[
diff --git a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
index 42a6a0c47e7b..dbcd059b99e2 100644
--- a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
+++ b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
@@ -4,7 +4,8 @@
CNAB Cobranca
-
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index 51bba2122811..2b920e198615 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -4,7 +4,8 @@
bank.payment.line.form
bank.payment.line
-
+
@@ -17,8 +18,10 @@
-
-
+
+
@@ -26,6 +29,9 @@
-
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 3248e7b7554f..d27d1b737741 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -2,20 +2,21 @@
-
+
cnab.retorno.tree
l10n.br.cnab
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -25,15 +26,16 @@
l10n.br.cnab.lote
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -43,19 +45,19 @@
l10n.br.cnab.evento
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -66,26 +68,41 @@
@@ -98,24 +115,36 @@
@@ -127,8 +156,12 @@
@@ -167,7 +210,9 @@
tree,form
-
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
index 981c64005747..8441c4ff19b0 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
@@ -3,9 +3,12 @@
-
- [('payment_order_type', '=', 'payment')]
- {'search_payment_order_type': 'payment'}
+
+ [('payment_order_type', '=', 'payment')]
+
+ {'search_payment_order_type': 'payment'}
+
@@ -14,18 +17,24 @@
form
tree,form
{'search_payment_order_type': 'cobranca',
- 'default_payment_order_type': 'cobranca'}
-
- [('payment_order_type', '=', 'cobranca')]
+ 'default_payment_order_type': 'cobranca'}
+
+
+ [('payment_order_type', '=', 'cobranca')]
+
Crie ordens de cobrança CNAB 240.
-
+
payment.order.form
payment.order
-
+
@@ -33,20 +42,22 @@
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
- [('payment_order_type', '=', payment_order_type)]
+ [('payment_order_type', '=',
+ payment_order_type)]
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
index c809942e9ef2..237f99e8a61a 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
@@ -35,42 +35,51 @@
-
Linhas de Cobrança Select
payment.line
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -87,36 +96,38 @@
Lista das linhas cnab 400.
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
index ae19e1e1a5e2..36c9e6556804 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
@@ -7,12 +7,13 @@
+
+
-
- cnab.retorno.lote.form.view
- l10n.br.cnab.lote
-
-
-
+
+ cnab.retorno.lote.form.view
+ l10n.br.cnab.lote
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.retorno.form.view
+ l10n.br.cnab
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
-
-
-
-
-
- cnab.retorno.form.view
- l10n.br.cnab
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
- CNAB Retorno
- ir.actions.act_window
- l10n.br.cnab
- form
- tree,form
-
+
+ CNAB Retorno
+ ir.actions.act_window
+ l10n.br.cnab
+ form
+ tree,form
+
-
+
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
index 99ac15f8201a..6f6785d0b38b 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
@@ -1,49 +1,46 @@
-
-
-
-
-
- l10n_br_cnab_sequence.form.view
- l10n_br_cnab.sequence
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- l10n_br_cnab_sequence.tree.view
- l10n_br_cnab.sequence
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ l10n_br_cnab_sequence.form.view
+ l10n_br_cnab.sequence
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ l10n_br_cnab_sequence.tree.view
+ l10n_br_cnab.sequence
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
index 8441c4ff19b0..89406e4e7059 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
@@ -1,67 +1,65 @@
-
-
+
-
-
- [('payment_order_type', '=', 'payment')]
-
- {'search_payment_order_type': 'payment'}
-
-
+
+
+ [('payment_order_type', '=', 'payment')]
+
+ {'search_payment_order_type': 'payment'}
+
+
-
- Cobranca
- payment.order
- form
- tree,form
- {'search_payment_order_type': 'cobranca',
- 'default_payment_order_type': 'cobranca'}
-
-
- [('payment_order_type', '=', 'cobranca')]
-
- Crie ordens de cobrança CNAB 240.
-
+
+ Cobranca
+ payment.order
+ form
+ tree,form
+ {'search_payment_order_type': 'cobranca',
+ 'default_payment_order_type': 'cobranca'}
+
+
+ [('payment_order_type', '=', 'cobranca')]
+
+ Crie ordens de cobrança CNAB 240.
+
-
+
-
- payment.order.form
- payment.order
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [('payment_order_type', '=',
- payment_order_type)]
-
-
-
-
-
+
+ payment.order.form
+ payment.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [('payment_order_type', '=',
+ payment_order_type)]
+
+
+
+
+
-
-
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
index 237f99e8a61a..51f4d7e3c5f2 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
@@ -1,134 +1,132 @@
-
-
-
-
- Linhas de Cobrança
- payment.line
- order_id
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Linhas de Cobrança Select
- payment.line
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Linhas de cobrança
- payment.line
- form
- tree,form
- {}
-
-
- []
-
- Lista das linhas cnab 400.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Linhas de Cobrança
+ payment.line
+ order_id
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Linhas de Cobrança Select
+ payment.line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Linhas de cobrança
+ payment.line
+ form
+ tree,form
+ {}
+
+
+ []
+
+ Lista das linhas cnab 400.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
index 36c9e6556804..cd27855b3290 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
@@ -1,33 +1,31 @@
-
-
-
- payment.cnab.form
- payment.cnab
-
-
-
-
-
-
-
-
-
-
+
+
+ payment.cnab.form
+ payment.cnab
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_line.xml b/l10n_br_account_payment_cobranca/views/payment_line.xml
index 8252439ff190..6042f414bb09 100644
--- a/l10n_br_account_payment_cobranca/views/payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_line.xml
@@ -1,4 +1,4 @@
-
+
payment.order.form
@@ -25,4 +25,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
index ebc32a9ffb22..7efc38c16179 100644
--- a/l10n_br_account_payment_cobranca/views/payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_mode.xml
@@ -1,47 +1,45 @@
-
-
-
- cnab.payment.mode.l10n_br_payment.form.inherit
-
- payment.mode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ cnab.payment.mode.l10n_br_payment.form.inherit
+
+ payment.mode
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_order.xml b/l10n_br_account_payment_cobranca/views/payment_order.xml
index 2c28039771ed..622f3940c3a4 100644
--- a/l10n_br_account_payment_cobranca/views/payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_order.xml
@@ -1,33 +1,30 @@
-
-
+
-
- payment.order.form.sequence
- payment.order
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ payment.order.form.sequence
+ payment.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
+
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index f7c818daecc5..a50fb27b1ada 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -1,23 +1,21 @@
-
-
-
- l10n_br_account_payment_boleto.res.company.form
-
- res.company
-
-
-
-
-
-
+ l10n_br_account_payment_boleto.res.company.form
+
+ res.company
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
index d2e265f6b501..a439f45f4255 100644
--- a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
+++ b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
@@ -1,35 +1,32 @@
-
-
+
+
+
+ view_cnab_bank_acc_dig.partner.bank.form
+ res.partner.bank
+
+
+
+
+
+
+
-
-
- view_cnab_bank_acc_dig.partner.bank.form
- res.partner.bank
-
-
-
-
-
-
-
+
+ {'required': True}
+
-
- {'required': True}
-
+
+ {'required': True}
+
-
- {'required': True}
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_cobranca/wizard/__init__.py
index 9f670fca1fa8..890698bdab07 100644
--- a/l10n_br_account_payment_cobranca/wizard/__init__.py
+++ b/l10n_br_account_payment_cobranca/wizard/__init__.py
@@ -1,25 +1,9 @@
-# coding: utf-8
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
+# © 2012 KMEE INFORMATICA LTDA
+# @author Luis Felipe Mileo
+# @author Daniel Sadamo
+# @author Fernando Marcato
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import payment_order_create
from . import l10n_bank_payment_cnab_export
diff --git a/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py b/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
index b95104224e51..336f1bcf8d13 100644
--- a/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
+++ b/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
@@ -1,31 +1,15 @@
-# coding: utf-8
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
+# © 2012 KMEE INFORMATICA LTDA
+# @author Luis Felipe Mileo
+# @author Daniel Sadamo
+# @author Fernando Marcato
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import base64
import time
-from openerp import models, api, workflow, fields, _
-from openerp.exceptions import Warning as UserError
+from odoo import models, api, workflow, fields, _
+from odoo.exceptions import Warning as UserError
from ..febraban.cnab import Cnab
import logging
@@ -70,7 +54,7 @@ def export(self):
try:
remessa = cnab.remessa(order)
except Cnab240Error as e:
- from openerp import exceptions
+ from odoo import exceptions
raise exceptions.ValidationError(
"Campo preenchido incorretamente \n\n{0}".format(e))
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 7d3cae995eac..729d0dc69b93 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -1,28 +1,12 @@
# -*- coding: utf-8 -*-
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-from openerp import models, api
+# © 2012 KMEE INFORMATICA LTDA
+# @author Luis Felipe Mileo
+# @author Daniel Sadamo
+# @author Fernando Marcato
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+
+from odoo import models, api
class PaymentOrderCreate(models.TransientModel):
From 0233f5c88b75d3011c47e6e52e7818b4a08bae8c Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 13:21:50 -0300
Subject: [PATCH 053/612] [REF] Migrando models renomeados
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_cobranca/models/payment_line.py | 2 +-
l10n_br_account_payment_cobranca/models/payment_mode.py | 2 +-
l10n_br_account_payment_cobranca/models/payment_order.py | 2 +-
l10n_br_account_payment_cobranca/views/payment_line.xml | 4 ++--
l10n_br_account_payment_cobranca/views/payment_mode.xml | 2 +-
l10n_br_account_payment_cobranca/views/payment_order.xml | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/payment_line.py b/l10n_br_account_payment_cobranca/models/payment_line.py
index 888fdff756b6..29e2de530c55 100644
--- a/l10n_br_account_payment_cobranca/models/payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/payment_line.py
@@ -9,7 +9,7 @@
class PaymentLine(models.Model):
- _inherit = 'payment.line'
+ _inherit = 'account.payment.line'
@api.model
def default_get(self, fields_list):
diff --git a/l10n_br_account_payment_cobranca/models/payment_mode.py b/l10n_br_account_payment_cobranca/models/payment_mode.py
index 65870599711b..b3bfc3caa1c4 100644
--- a/l10n_br_account_payment_cobranca/models/payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/payment_mode.py
@@ -15,7 +15,7 @@
class PaymentMode(models.Model):
- _inherit = "payment.mode"
+ _inherit = "account.payment.mode"
condicao_emissao_papeleta = fields.Selection(
[('1', 'Banco emite e Processa'),
diff --git a/l10n_br_account_payment_cobranca/models/payment_order.py b/l10n_br_account_payment_cobranca/models/payment_order.py
index 7756cb2fec28..6abf7e48cbde 100644
--- a/l10n_br_account_payment_cobranca/models/payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/payment_order.py
@@ -13,7 +13,7 @@
class PaymentOrder(models.Model):
- _inherit = b'payment.order'
+ _inherit = b'account.payment.order'
file_number = fields.Integer(
string=u'Número sequencial do arquivo',
diff --git a/l10n_br_account_payment_cobranca/views/payment_line.xml b/l10n_br_account_payment_cobranca/views/payment_line.xml
index 6042f414bb09..6fd4ae30d263 100644
--- a/l10n_br_account_payment_cobranca/views/payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_line.xml
@@ -1,10 +1,10 @@
- payment.order.form
+ account.payment.order.form
- payment.order
+ account.payment.order
{'order_id': active_id or False,
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
index 7efc38c16179..e7837351910e 100644
--- a/l10n_br_account_payment_cobranca/views/payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_mode.xml
@@ -4,7 +4,7 @@
model="ir.ui.view">
cnab.payment.mode.l10n_br_payment.form.inherit
- payment.mode
+ account.payment.mode
diff --git a/l10n_br_account_payment_cobranca/views/payment_order.xml b/l10n_br_account_payment_cobranca/views/payment_order.xml
index 622f3940c3a4..060f1565a5ec 100644
--- a/l10n_br_account_payment_cobranca/views/payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_order.xml
@@ -3,7 +3,7 @@
payment.order.form.sequence
- payment.order
+ account.payment.order
From be200cef4bf8706e1e980be5ad68fc5f97a05af2 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 29 May 2019 17:39:12 -0300
Subject: [PATCH 054/612] [FIX]l10n_br_account_payment_cobranca dependencies
---
l10n_br_account_payment_cobranca/__manifest__.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index cc7d28be4fb9..6acaceb20711 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -18,9 +18,8 @@
'pyboleto'],
},
'depends': [
- 'l10n_br_account_payment_boleto',
- 'l10n_br_account_payment_mode',
- 'l10n_br_account_product',
+ 'base_transaction_id',
+ 'l10n_br_account_payment_order',
],
'data': [
'security/cnab_cobranca_security.xml',
From 2a063896ca8834bef4815baa01522c6e7fe06b92 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 29 May 2019 17:40:33 -0300
Subject: [PATCH 055/612] [WIP][FIX]l10n_br_account_payment_cobranca views
---
.../__manifest__.py | 8 +++----
.../views/l10n_br_cobranca_cnab_lines.xml | 22 +++++++++++--------
.../views/payment_mode.xml | 2 +-
.../views/payment_order.xml | 2 +-
.../views/res_partner_bank.xml | 2 +-
.../wizard/__init__.py | 2 +-
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 6acaceb20711..bdaadf038821 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -26,15 +26,15 @@
'views/l10n_br_payment_cnab.xml',
'views/payment_order.xml',
'views/l10n_br_cnab_sequence.xml',
- 'views/l10n_br_cobranca_cnab.xml',
+ #'views/l10n_br_cobranca_cnab.xml',
'views/l10n_br_cobranca_cnab_lines.xml',
'views/account_move_line.xml',
'views/res_partner_bank.xml',
'views/l10n_br_cnab_retorno_view.xml',
'views/payment_mode.xml',
- 'views/payment_line.xml',
- 'views/bank_payment_line.xml',
- 'data/l10n_br_payment_export_type.xml',
+ # 'views/payment_line.xml',
+ # 'views/bank_payment_line.xml',
+ # 'data/l10n_br_payment_export_type.xml',
# 'data/l10n_br_payment_mode.xml',
'security/ir.model.access.csv',
],
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
index 51f4d7e3c5f2..897a20a361ec 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
@@ -3,7 +3,7 @@
Linhas de Cobrança
- payment.line
+ account.payment.line
order_id
tree
@@ -21,10 +21,10 @@
-
-
+
+
-
+
@@ -37,7 +37,7 @@
Linhas de Cobrança Select
- payment.line
+ account.payment.line
@@ -84,7 +84,7 @@
Linhas de cobrança
- payment.line
+ account.payment.line
form
tree,form
{}
@@ -95,9 +95,13 @@
Lista das linhas cnab 400.
-
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
index e7837351910e..28454d6991bb 100644
--- a/l10n_br_account_payment_cobranca/views/payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_mode.xml
@@ -6,7 +6,7 @@
account.payment.mode
+ ref="l10n_br_account_payment_order.view_payment_mode_form_inherit_l10n_br_payment"/>
diff --git a/l10n_br_account_payment_cobranca/views/payment_order.xml b/l10n_br_account_payment_cobranca/views/payment_order.xml
index 060f1565a5ec..3e17258cd7db 100644
--- a/l10n_br_account_payment_cobranca/views/payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/payment_order.xml
@@ -5,7 +5,7 @@
payment.order.form.sequence
account.payment.order
+ ref="account_payment_order.account_payment_order_form"/>
diff --git a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
index a439f45f4255..fdc34d85eced 100644
--- a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
+++ b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
@@ -21,7 +21,7 @@
{'required': True}
-
+
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_cobranca/wizard/__init__.py
index 890698bdab07..b99aec60880c 100644
--- a/l10n_br_account_payment_cobranca/wizard/__init__.py
+++ b/l10n_br_account_payment_cobranca/wizard/__init__.py
@@ -5,5 +5,5 @@
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from . import payment_order_create
+# from . import payment_order_create
from . import l10n_bank_payment_cnab_export
From 17a5aab1c2bb08c13b75ccdf735cef15c3d76536 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 20:04:23 -0300
Subject: [PATCH 056/612] [IMP] Sequencia do boleto
Signed-off-by: Luis Felipe Mileo
Signed-off-by: Luis Felipe Mileo
---
.../__manifest__.py | 9 +++--
.../constantes.py | 6 ++++
.../data/boleto_data.xml | 12 +++----
.../models/account_invoice.py | 35 +++++++++++++++----
.../models/res_company.py | 18 ++++++----
.../views/res_company.xml | 20 +++++------
6 files changed, 68 insertions(+), 32 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index bdaadf038821..2384efe30b35 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -22,7 +22,11 @@
'l10n_br_account_payment_order',
],
'data': [
+ # 'data/l10n_br_payment_export_type.xml',
+ 'data/boleto_data.xml',
+
'security/cnab_cobranca_security.xml',
+
'views/l10n_br_payment_cnab.xml',
'views/payment_order.xml',
'views/l10n_br_cnab_sequence.xml',
@@ -32,10 +36,9 @@
'views/res_partner_bank.xml',
'views/l10n_br_cnab_retorno_view.xml',
'views/payment_mode.xml',
+ 'views/res_company.xml',
# 'views/payment_line.xml',
- # 'views/bank_payment_line.xml',
- # 'data/l10n_br_payment_export_type.xml',
- # 'data/l10n_br_payment_mode.xml',
+ # 'views/bank_payment_line.xml',
'security/ir.model.access.csv',
],
'demo': [
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 469ed5c284a0..651ea7715f76 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -2,6 +2,12 @@
# © 2012 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+SEQUENCIAL_EMPRESA = '0'
+SEQUENCIAL_FATURA = '1'
+SEQUENCIAL_CARTEIRA = '2'
+
+
COBRANCA = '01'
BOLETO_PAGAMENTO_ELETRONICO = '03'
CONCILIACAO_BANCARIA = '04'
diff --git a/l10n_br_account_payment_cobranca/data/boleto_data.xml b/l10n_br_account_payment_cobranca/data/boleto_data.xml
index 0b9b1a93709a..bca3e6d31ebd 100644
--- a/l10n_br_account_payment_cobranca/data/boleto_data.xml
+++ b/l10n_br_account_payment_cobranca/data/boleto_data.xml
@@ -3,16 +3,14 @@
Nosso número
-
-
-
- Sequêncial Único da Fatura
-
+ nosso.numero
+
+
+
+
-
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index abba9201c978..93a89f0f4dec 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -6,7 +6,11 @@
import logging
-from odoo import models, api
+from odoo import models, api, _
+from odoo.exceptions import UserError
+from ..constantes import (
+ SEQUENCIAL_EMPRESA, SEQUENCIAL_FATURA, SEQUENCIAL_CARTEIRA
+)
_logger = logging.getLogger(__name__)
@@ -14,16 +18,35 @@
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
+ @api.multi
+ def get_invoice_fiscal_number(self):
+ """ Como neste modulo nao temos o numero do documento fiscal,
+ vamos retornar o numero do core e deixar este metodo
+ para caso alguem queira sobrescrever"""
+
+ self.ensure_one()
+ return self.number
+
@api.multi
def action_move_create(self):
- value = super(AccountInvoice, self).action_move_create()
for invoice in self:
- sequence = self.env['ir.sequence'].next_by_id(
- self.company_id.transaction_id_sequence.id)
- invoice.transaction_id = sequence
+ if invoice.company_id.own_number_type == SEQUENCIAL_EMPRESA:
+ sequence = invoice.company_id.get_own_number_sequence()
+ elif invoice.company_id.own_number_type == SEQUENCIAL_FATURA:
+ sequence = invoice.get_invoice_fiscal_number()
+ elif invoice.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
+ # TODO: Implementar uma sequencia na carteira de cobranca
+ raise NotImplementedError
+ else:
+ raise UserError(
+ _(u"Favor acessar aba Cobrança da configuração da sua "
+ u"empresa para determinar o tipo de sequencia utilizada"
+ u" nas cobrancas")
+ )
- return value
+ invoice.transaction_id = sequence
+ return super(AccountInvoice, self).action_move_create()
@api.multi
def finalize_invoice_move_lines(self, move_lines):
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index fc4ac56cecf1..5191b28467b8 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -3,7 +3,11 @@
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, fields
+from odoo import api, models, fields
+
+from ..constantes import (
+ SEQUENCIAL_EMPRESA, SEQUENCIAL_FATURA, SEQUENCIAL_CARTEIRA
+)
class ResCompany(models.Model):
@@ -11,9 +15,9 @@ class ResCompany(models.Model):
own_number_type = fields.Selection(
selection=[
- ('0', u'Sequêncial único por empresa'),
- ('1', u'Numero sequêncial da Fatura'),
- ('2', u'Sequêncial único por modo de pagamento'), ],
+ (SEQUENCIAL_EMPRESA, u'Sequêncial único por empresa'),
+ (SEQUENCIAL_FATURA, u'Numero sequêncial da Fatura'),
+ (SEQUENCIAL_CARTEIRA, u'Sequêncial único por carteira'), ],
string=u'Tipo de nosso número',
default='2'
)
@@ -23,5 +27,7 @@ class ResCompany(models.Model):
string=u'Sequência do Nosso Número'
)
- transaction_id_sequence = fields.Many2one('ir.sequence',
- string=u'Sequência da fatura')
+ @api.multi
+ def get_own_number_sequence(self):
+ self.ensure_one()
+ return self.own_number_sequence.next_by_id()
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index a50fb27b1ada..871306304b01 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -5,17 +5,17 @@
res.company
+ ref="l10n_br_account.l10n_br_account_company_form"/>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
From 8486b25845a09b6e642721cdaa8f594be39c863d Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 29 May 2019 23:18:56 -0300
Subject: [PATCH 057/612] =?UTF-8?q?[REF]=20Gera=C3=A7=C3=A3o=20do=20arquiv?=
=?UTF-8?q?o=20cnab400?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../__manifest__.py | 2 +-
.../data/l10n_br_payment_export_type.xml | 30 +++-----
.../febraban/cnab_400/bancos/bradesco.py | 12 ++--
.../febraban/cnab_400/cnab_400.py | 70 ++++++++++---------
.../models/payment_order.py | 28 +++++++-
5 files changed, 82 insertions(+), 60 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 2384efe30b35..04f7cda0451c 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -22,7 +22,7 @@
'l10n_br_account_payment_order',
],
'data': [
- # 'data/l10n_br_payment_export_type.xml',
+ 'data/l10n_br_payment_export_type.xml',
'data/boleto_data.xml',
'security/cnab_cobranca_security.xml',
diff --git a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
index 7b57456d4c32..4221e63cac63 100644
--- a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
+++ b/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
@@ -1,43 +1,33 @@
-
+
-
+
240
Cnab240
True
- payment
-
-
-
+ False
+ inbound
-
+
400
Cnab400
True
-
-
-
+ False
+ inbound
-
+
500
Cnab500
True
payment
-
-
-
+ False
+ inbound
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
index 72dff83b3acd..19d143b2910a 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
@@ -50,8 +50,8 @@ def _prepare_cobranca(self, line):
vals['cedente_conta_dv']), "utf-8")
vals['cedente_agencia_dv'] = unicode(str(
vals['cedente_agencia_dv']), "utf-8")
- vals['cedente_dv_ag_cc'] = unicode(str(
- vals['cedente_dv_ag_cc']), "utf-8")
+ # vals['cedente_dv_ag_cc'] = unicode(str(
+ # vals['cedente_dv_ag_cc']), "utf-8")
vals['sacado_cc_dv'] = u'0'
vals['identificacao_empresa_beneficiaria_banco'] = \
@@ -77,14 +77,14 @@ def retorna_id_empr_benef(self):
dig_conta = 7
carteira = self.adiciona_digitos(
- self.order.mode.boleto_carteira, dig_cart)
+ self.order.payment_mode_id.boleto_carteira, dig_cart)
agencia = self.adiciona_digitos(
- self.order.mode.bank_id.bra_number, dig_ag)
+ self.order.company_partner_bank_id.bra_number, dig_ag)
conta = self.adiciona_digitos(
- self.order.mode.bank_id.acc_number, dig_conta)
+ self.order.company_partner_bank_id.acc_number, dig_conta)
ident = u'0' + (carteira) + (agencia) + (conta) + \
- (self.order.mode.bank_id.acc_number_dig)
+ (self.order.company_partner_bank_id.acc_number_dig)
return ident
def adiciona_digitos(self, campo, num_digitos):
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 4ec1651eb03b..95b6cf9aa970 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -106,7 +106,9 @@ def _prepare_header(self):
:return:
"""
return {
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'controle_banco': int(
+ self.order.company_partner_bank_id.bank_id.code_bc
+ ),
'arquivo_data_de_geracao': self.data_hoje(),
'arquivo_hora_de_geracao': self.hora_agora(),
# TODO: Número sequencial de arquivo
@@ -115,21 +117,22 @@ def _prepare_header(self):
'cedente_inscricao_numero': int(punctuation_rm(
self.order.company_id.cnpj_cpf)),
'cedente_agencia': int(
- self.order.mode.bank_id.bra_number),
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- 'cedente_conta_dv': (self.order.mode.bank_id.acc_number_dig),
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv': (self.order.company_partner_bank_id.acc_number_dig),
+ 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
'cedente_nome': self.order.company_id.legal_name,
'arquivo_codigo': 1, # Remessa/Retorno
'servico_operacao': u'R',
- 'nome_banco': unicode(self.order.mode.bank_id.bank_name),
- 'codigo_empresa': int(self.order.mode.boleto_convenio),
+ 'nome_banco': unicode(self.order.company_partner_bank_id.bank_name),
+ 'codigo_empresa': int(self.order.payment_mode_id.boleto_convenio),
}
def get_file_numeration(self):
- numero = self.order.get_next_number()
- if not numero:
- numero = 1
+ # TODO: FIX ME
+ # numero = self.order.get_next_number()
+ # if not numero:
+ numero = 1
return numero
def format_date(self, srt_date):
@@ -166,22 +169,22 @@ def _prepare_cobranca(self, line):
prefixo, sulfixo = self.cep(line.partner_id.zip)
aceite = u'N'
- if not self.order.mode.boleto_aceite == 'S':
+ if not self.order.payment_mode_id.boleto_aceite == 'S':
aceite = u'A'
codigo_protesto = 0
dias_protestar = 0
- if self.order.mode.boleto_protesto == '3' \
- or self.order.mode.boleto_protesto == '0':
+ if self.order.payment_mode_id.boleto_protesto == '3' \
+ or self.order.payment_mode_id.boleto_protesto == '0':
codigo_protesto = 0
dias_protestar = 0
- elif self.order.mode.boleto_protesto == '1' \
- or self.order.mode.boleto_protesto == '2':
+ elif self.order.payment_mode_id.boleto_protesto == '1' \
+ or self.order.payment_mode_id.boleto_protesto == '2':
codigo_protesto = 6
- if (int(self.order.mode.boleto_protesto_prazo)) < 5:
+ if (int(self.order.payment_mode_id.boleto_protesto_prazo)) < 5:
dias_protestar = 5
else:
- dias_protestar = int(self.order.mode.boleto_protesto_prazo)
+ dias_protestar = int(self.order.payment_mode_id.boleto_protesto_prazo)
sacado_endereco = self.retorna_endereco(line.partner_id.id)
@@ -209,37 +212,39 @@ def _prepare_cobranca(self, line):
'segunda_instrucao': dias_protestar,
'sacado_cep': int(prefixo),
'sacado_cep_sufixo': int(sulfixo),
- 'sacador_avalista': self.order.mode.comunicacao_2,
+ 'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
# 'sacador_avalista': u'Protestar após 5 dias',
'num_seq_registro': self.controle_linha,
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'controle_banco': int(
+ self.order.company_partner_bank_id.bank_id.code_bc
+ ),
+ 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig,
+ 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
'identificacao_titulo': u'0000000', # TODO
'identificacao_titulo_banco': u'0000000', # TODO
- 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
+ 'identificacao_titulo_empresa': line.name, # FIXME
'vencimento_titulo': self.format_date(
- line.ml_maturity_date),
+ line.date),
'valor_titulo': Decimal(str(line.amount_currency)).quantize(
Decimal('1.00')),
# TODO: Código adotado para identificar o título de cobrança.
# 8 é Nota de cŕedito comercial
- 'especie_titulo': int(self.order.mode.boleto_especie),
+ 'especie_titulo': int(self.order.payment_mode_id.boleto_especie),
'aceite_titulo': aceite,
'data_emissao_titulo': self.format_date(
- line.ml_date_created),
+ line.date), # FIXME
# TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
# CEF/FEBRABAN e Itaú não tem.
'juros_mora_data': self.format_date(
- line.ml_maturity_date),
+ line.date),
# 'juros_mora_taxa_dia': Decimal('0.20'),
'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
- line.amount_currency, line.percent_interest),
+ line.amount_currency, 0), # line.percent_interest
'valor_abatimento': Decimal('0.00'),
'sacado_inscricao_tipo': int(
@@ -261,8 +266,9 @@ def _prepare_cobranca(self, line):
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': int(self.order.mode.boleto_carteira),
-
+ 'cobranca_carteira': int(
+ self.order.payment_mode_id.boleto_carteira
+ ),
'primeira_mensagem': u'',
# Trazer da nova tela do payment_mode
'identificacao_ocorrencia': 1,
@@ -282,7 +288,7 @@ def remessa(self, order):
"""
self.order = order
self.arquivo = ArquivoCobranca400(self.bank, **self._prepare_header())
- for line in order.line_ids:
+ for line in order.bank_line_ids:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
self.arquivo.trailer.num_seq_registro = self.controle_linha
diff --git a/l10n_br_account_payment_cobranca/models/payment_order.py b/l10n_br_account_payment_cobranca/models/payment_order.py
index 6abf7e48cbde..d3a282cd0392 100644
--- a/l10n_br_account_payment_cobranca/models/payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/payment_order.py
@@ -6,11 +6,20 @@
from __future__ import division, print_function, unicode_literals
-from odoo import models, fields
+from odoo import api, models, fields
+from ..febraban.cnab import Cnab
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO, CODIGO_INSTRUCAO_MOVIMENTO
+import logging
+
+_logger = logging.getLogger(__name__)
+try:
+ from cnab240.errors import (Cnab240Error)
+except ImportError as err:
+ _logger.debug = err
+
class PaymentOrder(models.Model):
_inherit = b'account.payment.order'
@@ -74,3 +83,20 @@ class PaymentOrder(models.Model):
# @api.multi
# def write_added_state_to_move_line(self, mov_line):
# mov_line.state_cnab = 'added'
+
+ @api.multi
+ def generate_payment_file(self):
+ """Returns (payment file as string, filename)"""
+ self.ensure_one()
+ if self.payment_method_id.code in ('240', '400', '500'):
+ try:
+ cnab = Cnab.get_cnab(
+ self.company_partner_bank_id.bank_id.code_bc,
+ self.payment_mode_id.payment_method_id.code
+ )()
+ return (cnab.remessa(self), self.name + '.REM')
+ except Cnab240Error as e:
+ from odoo import exceptions
+ raise exceptions.ValidationError(
+ "Campo preenchido incorretamente \n\n{0}".format(e))
+ return super(PaymentOrder, self).generate_payment_file()
From 0c4799da865c4e67e4581069f050aa72f47d71f1 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 01:59:19 -0300
Subject: [PATCH 058/612] [IMP] Melhorias diversas nos pagamentos
Signed-off-by: Luis Felipe Mileo
---
.../__manifest__.py | 23 +-
.../febraban/cnab_240/cnab_240.py | 70 +++---
.../febraban/pag_for/bancos/bradesco.py | 2 +-
.../febraban/pag_for/pag_for500.py | 22 +-
.../models/__init__.py | 12 +-
...ayment_line.py => account_payment_line.py} | 4 +-
...ayment_mode.py => account_payment_mode.py} | 0
...ment_order.py => account_payment_order.py} | 13 -
.../models/bank_payment_line.py | 6 +-
...ment_line.xml => account_payment_line.xml} | 21 +-
.../views/account_payment_mode.xml | 46 ++++
...nt_order.xml => account_payment_order.xml} | 5 -
.../views/bank_payment_line.xml | 10 +-
.../views/l10n_br_cnab_retorno_view.xml | 8 +-
.../views/payment_mode.xml | 45 ----
.../wizard/__init__.py | 3 +-
.../wizard/l10n_bank_payment_cnab_export.py | 89 -------
.../wizard/payment_order_create.py | 233 ++++++++++--------
18 files changed, 264 insertions(+), 348 deletions(-)
rename l10n_br_account_payment_cobranca/models/{payment_line.py => account_payment_line.py} (95%)
rename l10n_br_account_payment_cobranca/models/{payment_mode.py => account_payment_mode.py} (100%)
rename l10n_br_account_payment_cobranca/models/{payment_order.py => account_payment_order.py} (87%)
rename l10n_br_account_payment_cobranca/views/{payment_line.xml => account_payment_line.xml} (52%)
create mode 100644 l10n_br_account_payment_cobranca/views/account_payment_mode.xml
rename l10n_br_account_payment_cobranca/views/{payment_order.xml => account_payment_order.xml} (80%)
delete mode 100644 l10n_br_account_payment_cobranca/views/payment_mode.xml
delete mode 100644 l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 04f7cda0451c..cbadf03ba606 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -27,18 +27,21 @@
'security/cnab_cobranca_security.xml',
- 'views/l10n_br_payment_cnab.xml',
- 'views/payment_order.xml',
- 'views/l10n_br_cnab_sequence.xml',
- #'views/l10n_br_cobranca_cnab.xml',
- 'views/l10n_br_cobranca_cnab_lines.xml',
- 'views/account_move_line.xml',
+ 'views/res_company.xml',
+ 'views/account_payment_mode.xml',
'views/res_partner_bank.xml',
+ 'views/account_payment_order.xml',
+ 'views/account_payment_line.xml',
+ 'views/bank_payment_line.xml',
+
+ 'views/account_move_line.xml',
'views/l10n_br_cnab_retorno_view.xml',
- 'views/payment_mode.xml',
- 'views/res_company.xml',
- # 'views/payment_line.xml',
- # 'views/bank_payment_line.xml',
+
+ # 'views/l10n_br_payment_cnab.xml',
+ # 'views/l10n_br_cnab_sequence.xml',
+ # 'views/l10n_br_cobranca_cnab.xml',
+ # 'views/l10n_br_cobranca_cnab_lines.xml',
+
'security/ir.model.access.csv',
],
'demo': [
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index 578e955847e4..d8aa81aae44a 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -75,7 +75,9 @@ def _prepare_header(self):
header_arquivo = {
# CONTROLE
# 01.0
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'controle_banco': int(
+ self.order.company_partner_bank_id.bank_id.code_bc
+ ),
# 02.0 # Sequencia para o Arquivo
'controle_lote': 1,
# 03.0 0- Header do Arquivo
@@ -94,25 +96,25 @@ def _prepare_header(self):
'cedente_convenio': '0001222130126',
# 08.0
'cedente_agencia':
- int(self.order.mode.bank_id.bra_number),
+ int(self.order.company_partner_bank_id.bra_number),
# 09.0
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
# 10.0
'cedente_conta':
- int(punctuation_rm(self.order.mode.bank_id.acc_number)),
+ int(punctuation_rm(self.order.company_partner_bank_id.acc_number)),
# 11.0
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig[0],
# 12.0
'cedente_agencia_conta_dv':
- self.order.mode.bank_id.acc_number_dig[1]
- if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ self.order.company_partner_bank_id.acc_number_dig[1]
+ if len(self.order.company_partner_bank_id.acc_number_dig) > 1 else '',
# 13.0
'cedente_nome':
- self.order.mode.bank_id.partner_id.legal_name[:30]
- if self.order.mode.bank_id.partner_id.legal_name
- else self.order.mode.bank_id.partner_id.name[:30],
+ self.order.company_partner_bank_id.partner_id.legal_name[:30]
+ if self.order.company_partner_bank_id.partner_id.legal_name
+ else self.order.company_partner_bank_id.partner_id.name[:30],
# 14.0
- 'nome_banco': self.order.mode.bank_id.bank_name,
+ 'nome_banco': self.order.company_partner_bank_id.bank_name,
# 15.0
# CNAB - Uso Exclusivo FEBRABAN / CNAB
@@ -144,13 +146,13 @@ def _prepare_header_lote(self):
Preparar o header de LOTE para arquivo do CNAB
:return: dict - Header do arquivo
"""
- empresa = self.order.mode.bank_id.partner_id
+ empresa = self.order.company_partner_bank_id.partner_id
header_arquivo_lote = {
# CONTROLE
# 01.1
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
# 02.1 Sequencia para o Arquivo
'controle_lote': 1,
# 03.1 0- Header do Arquivo
@@ -178,23 +180,23 @@ def _prepare_header_lote(self):
'cedente_convenio': self.order.codigo_convenio,
# 12.1
'cedente_agencia':
- int(self.order.mode.bank_id.bra_number),
+ int(self.order.company_partner_bank_id.bra_number),
# 13.1
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
# 14.1
'cedente_conta':
- int(punctuation_rm(self.order.mode.bank_id.acc_number)),
+ int(punctuation_rm(self.order.company_partner_bank_id.acc_number)),
# 15.1
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
+ 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig[0],
# 16.1
'cedente_agencia_conta_dv':
- self.order.mode.bank_id.acc_number_dig[1]
- if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
+ self.order.company_partner_bank_id.acc_number_dig[1]
+ if len(self.order.company_partner_bank_id.acc_number_dig) > 1 else '',
# 17.1
'cedente_nome':
- self.order.mode.bank_id.partner_id.legal_name[:30]
- if self.order.mode.bank_id.partner_id.legal_name
- else self.order.mode.bank_id.partner_id.name[:30],
+ self.order.company_partner_bank_id.partner_id.legal_name[:30]
+ if self.order.company_partner_bank_id.partner_id.legal_name
+ else self.order.company_partner_bank_id.partner_id.name[:30],
# 18.1
'mensagem1': '',
@@ -236,7 +238,7 @@ def _prepare_cobranca(self, line):
# prefixo, sufixo = self.cep(line.partner_id.zip)
aceite = u'N'
- if not self.order.mode.boleto_aceite == 'S':
+ if not self.order.payment_mode_id.boleto_aceite == 'S':
aceite = u'A'
# Código agencia do cedente
@@ -255,11 +257,11 @@ def _prepare_cobranca(self, line):
# Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
return {
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
+ 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
+ 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig,
+ 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
'identificacao_titulo': u'0000000', # TODO
'identificacao_titulo_banco': u'0000000', # TODO
'identificacao_titulo_empresa': line.move_line_id.move_id.name,
@@ -271,7 +273,7 @@ def _prepare_cobranca(self, line):
# TODO: fépefwfwe
# TODO: Código adotado para identificar o título de cobrança.
# 8 é Nota de cŕedito comercial
- 'especie_titulo': int(self.order.mode.boleto_especie),
+ 'especie_titulo': int(self.order.payment_mode_id.boleto_especie),
'aceite_titulo': aceite,
'data_emissao_titulo': self.format_date(
line.ml_date_created),
@@ -293,12 +295,12 @@ def _prepare_cobranca(self, line):
'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
- 'codigo_protesto': int(self.order.mode.boleto_protesto),
- 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
+ 'codigo_protesto': int(self.order.payment_mode_id.boleto_protesto),
+ 'prazo_protesto': int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': int(self.order.mode.boleto_carteira),
+ 'cobranca_carteira': int(self.order.payment_mode_id.boleto_carteira),
}
def _prepare_pagamento(self, line):
@@ -314,7 +316,7 @@ def _prepare_pagamento(self, line):
# SEGMENTO A
# CONTROLE
# 01.3A
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
+ 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
# 02.3A
'controle_lote': 1,
# 03.3A - 3-Registros Iniciais do Lote
@@ -335,7 +337,7 @@ def _prepare_pagamento(self, line):
# 08.3A - 018-TED 700-DOC
'favorecido_camara': 0,
# 09.3A
- 'favorecido_banco': int(line.bank_id.bank_bic),
+ 'favorecido_banco': int(line.bank_id.code_bc),
# 10.3A
'favorecido_agencia': int(line.bank_id.bra_number),
# 11.3A
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
index 7fe3f4b77ed0..70acbd926382 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
@@ -26,7 +26,7 @@ def _prepare_header(self):
:return:
"""
vals = super(BradescoPagFor, self)._prepare_header()
- vals['codigo_comunicacao'] = int(self.order.mode.boleto_convenio)
+ vals['codigo_comunicacao'] = int(self.order.payment_mode_id.boleto_convenio)
return vals
def _prepare_cobranca(self, line, vals):
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index d3f27a497a25..3517406220cb 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -184,13 +184,13 @@ def _prepare_header(self):
self.order.company_id.cnpj_cpf)[9:12]),
'sufixo_cnpj': int(punctuation_rm(
self.order.company_id.cnpj_cpf)[12:14]),
- 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
+ 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
'cedente_agencia_conta_dv':
- self.order.mode.bank_id.bra_number_dig,
+ self.order.company_partner_bank_id.bra_number_dig,
'nome_empresa_pagadora': self.order.company_id.legal_name,
'cedente_codigo_agencia_digito':
- self.order.mode.bank_id.bra_number_dig,
+ self.order.company_partner_bank_id.bra_number_dig,
'arquivo_codigo': 1, # Remessa/Retorno
'servico_operacao': u'R',
'reservado_empresa': u'BRADESCO PAG FOR',
@@ -247,7 +247,7 @@ def _prepare_cobranca(self, line, vals):
prefixo, sulfixo = self.cep(line.partner_id.zip)
segmento = {
- 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
# 'especie_titulo': 8,
'tipo_inscricao': int(
@@ -327,8 +327,8 @@ def _prepare_cobranca(self, line, vals):
# FIXME: lib nao reconhece campo
'sequencial_trailer': int(self.get_file_numeration()),
'sequencial_transacao': self.controle_linha,
- 'codigo_protesto': int(self.order.mode.boleto_protesto),
- 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
+ 'codigo_protesto': int(self.order.payment_mode_id.boleto_protesto),
+ 'prazo_protesto': int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
@@ -410,7 +410,7 @@ def lancamento_credito_bradesco(self, line):
'numero_pagamento': self.adiciona_digitos_num_pag(
line.communication),
- 'carteira': int(self.order.mode.boleto_carteira),
+ 'carteira': int(self.order.payment_mode_id.boleto_carteira),
'nosso_numero': 0,
@@ -427,7 +427,7 @@ def lancamento_ted(self, line):
# modalidade 08.
vals = {
- 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
'especie_titulo': line.order_id.mode.type_purchase_payment,
# TODO: código do banco. Para a Modalidade de Pagamento valor
@@ -453,7 +453,7 @@ def lancamento_ted(self, line):
'fator_vencimento': 0, # FIXME
- # 'modalidade_pagamento': int(self.order.mode.boleto_especie),
+ # 'modalidade_pagamento': int(self.order.payment_mode_id.boleto_especie),
'tipo_movimento': 0,
# TODO Tipo de Movimento.
@@ -487,7 +487,7 @@ def lancamento_titulos_terceiros(self, line):
self.ler_linha_digitavel_codigos_ag_cc(line.linha_digitavel)
vals = {
- 'conta_complementar': int(self.order.mode.bank_id.acc_number),
+ 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
'especie_titulo': line.order_id.mode.type_purchase_payment,
# extrair do código de barras
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index b63e7e8dba3e..a8e684b1bae8 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -3,14 +3,14 @@
from . import account_invoice
from . import account_move_line
-# from . import bank_payment_line
+from . import account_payment_line
+from . import account_payment_mode
+from . import account_payment_order
+from . import bank_payment_line
from . import l10n_br_cnab
-from . import l10n_br_cnab_file_sufix_sequence
-from . import l10n_br_cnab_sequence
-from . import payment_line
-from . import payment_mode
-from . import payment_order
from . import res_company
from . import res_partner_bank
from . import res_partner
from .. import constantes
+# from . import l10n_br_cnab_file_sufix_sequence
+# from . import l10n_br_cnab_sequence
diff --git a/l10n_br_account_payment_cobranca/models/payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
similarity index 95%
rename from l10n_br_account_payment_cobranca/models/payment_line.py
rename to l10n_br_account_payment_cobranca/models/account_payment_line.py
index 29e2de530c55..bf43839aaadd 100644
--- a/l10n_br_account_payment_cobranca/models/payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -14,8 +14,8 @@ class PaymentLine(models.Model):
@api.model
def default_get(self, fields_list):
res = super(PaymentLine, self).default_get(fields_list)
- mode = self.env['payment.order'].browse(
- self.env.context.get('order_id')).mode
+ mode = self.env['account.payment.order'].browse(
+ self.env.context.get('order_id')).payment_mode_id
if mode.codigo_finalidade_doc:
res.update({
'codigo_finalidade_doc': mode.codigo_finalidade_doc})
diff --git a/l10n_br_account_payment_cobranca/models/payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/payment_mode.py
rename to l10n_br_account_payment_cobranca/models/account_payment_mode.py
diff --git a/l10n_br_account_payment_cobranca/models/payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
similarity index 87%
rename from l10n_br_account_payment_cobranca/models/payment_order.py
rename to l10n_br_account_payment_cobranca/models/account_payment_order.py
index d3a282cd0392..5bdb61673fa8 100644
--- a/l10n_br_account_payment_cobranca/models/payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -71,19 +71,6 @@ class PaymentOrder(models.Model):
default='0',
)
- # @api.multi
- # def set_to_draft(self, *args):
- # super(PaymentOrder, self).set_to_draft(*args)
- #
- # for order in self:
- # for line in order.line_ids:
- # self.write_added_state_to_move_line(line.move_line_id)
- # return True
-
- # @api.multi
- # def write_added_state_to_move_line(self, mov_line):
- # mov_line.state_cnab = 'added'
-
@api.multi
def generate_payment_file(self):
"""Returns (payment file as string, filename)"""
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 13d656618cf4..434ba77fe97f 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -13,8 +13,8 @@ class BankPaymentLine(models.Model):
@api.model
def default_get(self, fields_list):
res = super(BankPaymentLine, self).default_get(fields_list)
- mode = self.env['payment.order'].browse(
- self.env.context.get('order_id')).mode
+ mode = self.env['account.payment.order'].browse(
+ self.env.context.get('order_id')).payment_mode_id
if mode.codigo_finalidade_doc:
res.update({
'codigo_finalidade_doc': mode.codigo_finalidade_doc})
@@ -104,7 +104,7 @@ def same_fields_payment_line_and_bank_payment_line(self):
# TODO: Implementar campo brasileiros que permitem mesclar linhas
- # same_fields = [
+ same_fields = [] # Por segurança não vamos mesclar nada
# 'currency', 'partner_id',
# 'bank_id', 'date', 'state']
diff --git a/l10n_br_account_payment_cobranca/views/payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
similarity index 52%
rename from l10n_br_account_payment_cobranca/views/payment_line.xml
rename to l10n_br_account_payment_cobranca/views/account_payment_line.xml
index 6fd4ae30d263..c4e198b88bdc 100644
--- a/l10n_br_account_payment_cobranca/views/payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -3,24 +3,23 @@
account.payment.order.form
- account.payment.order
+ ref="account_payment_order.account_payment_line_form"/>
+ account.payment.line
-
- {'order_id': active_id or False,
- 'default_mode': mode}
-
-
-
-
+
+
+
+
+
+
+
-
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
new file mode 100644
index 000000000000..ab6ee4109161
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -0,0 +1,46 @@
+
+
+
+ cnab.payment.mode.l10n_br_payment.form.inherit
+
+ account.payment.mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_order.xml b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
similarity index 80%
rename from l10n_br_account_payment_cobranca/views/payment_order.xml
rename to l10n_br_account_payment_cobranca/views/account_payment_order.xml
index 3e17258cd7db..e68496d439d1 100644
--- a/l10n_br_account_payment_cobranca/views/payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
@@ -12,12 +12,7 @@
-
-
-
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index 8f217e6aec0f..c8a1a0b9b543 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -4,7 +4,7 @@
bank.payment.line.form
bank.payment.line
+ ref="account_payment_order.bank_payment_line_form"/>
@@ -17,7 +17,7 @@
-
@@ -28,8 +28,4 @@
-
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 03d9f5261e12..b87d9cb88591 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -202,15 +202,15 @@
- CNAB Retorno
+ Importar Retorno Bancário CNAB
ir.actions.act_window
l10n.br.cnab
form
tree,form
-
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/views/payment_mode.xml b/l10n_br_account_payment_cobranca/views/payment_mode.xml
deleted file mode 100644
index 28454d6991bb..000000000000
--- a/l10n_br_account_payment_cobranca/views/payment_mode.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- cnab.payment.mode.l10n_br_payment.form.inherit
-
- account.payment.mode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_cobranca/wizard/__init__.py
index b99aec60880c..9740fbe3f316 100644
--- a/l10n_br_account_payment_cobranca/wizard/__init__.py
+++ b/l10n_br_account_payment_cobranca/wizard/__init__.py
@@ -5,5 +5,4 @@
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-# from . import payment_order_create
-from . import l10n_bank_payment_cnab_export
+from . import payment_order_create
diff --git a/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py b/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
deleted file mode 100644
index 336f1bcf8d13..000000000000
--- a/l10n_br_account_payment_cobranca/wizard/l10n_bank_payment_cnab_export.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import base64
-import time
-
-from odoo import models, api, workflow, fields, _
-from odoo.exceptions import Warning as UserError
-from ..febraban.cnab import Cnab
-
-import logging
-
-_logger = logging.getLogger(__name__)
-try:
- from cnab240.errors import (Cnab240Error)
-except ImportError as err:
- _logger.debug = err
-
-
-class L10nPaymentCnab(models.TransientModel):
- _name = 'payment.cnab'
- _description = 'Export payment order(s) in cnab layout'
-
- name = fields.Char(string=u'Nome', size=255)
-
- cnab_file = fields.Binary(string='CNAB File', readonly=True)
-
- state = fields.Selection(
- string='state',
- selection=[('init', 'init'), ('done', 'done')],
- default='init',
- readonly=True
- )
-
- @api.multi
- def export(self):
- for order_id in self.env.context.get('active_ids', []):
-
- order = self.env['payment.order'].browse(order_id)
- if not order.line_ids:
- raise UserError(
- _('Error'),
- _('Adicione pelo menos uma linha na ordem de pagamento.'))
-
- # Criando instancia do CNAB a partir do código do banco
- cnab = Cnab.get_cnab(
- order.mode.bank_id.bank_bic, order.mode.type.code)()
-
- # Criando remessa de eventos
- try:
- remessa = cnab.remessa(order)
- except Cnab240Error as e:
- from odoo import exceptions
- raise exceptions.ValidationError(
- "Campo preenchido incorretamente \n\n{0}".format(e))
-
- if order.mode.type.code == '240':
- self.name = 'CB%s%s.REM' % (
- time.strftime('%d%m'), str(order.file_number))
- # elif order.mode.type.code == '400':
- # self.name = 'CB%s%s.REM' % (
- # time.strftime('%d%m'), str(suf_arquivo))
- elif order.mode.type.code == '500':
- self.name = 'PG%s%s.REM' % (
- time.strftime('%d%m'), str(order.file_number))
- self.state = 'done'
- self.cnab_file = base64.b64encode(remessa)
- order.cnab_file = base64.b64encode(remessa)
- order.cnab_filename = self.name
-
- workflow.trg_validate(
- self.env.uid, 'payment.order', order_id, 'done', self.env.cr)
-
- return {
- 'type': 'ir.actions.act_window',
- 'res_model': self._name,
- 'view_mode': 'form',
- 'view_type': 'form',
- 'res_id': self.id,
- 'target': 'new',
- }
-
- @api.multi
- def done(self):
- return {'type': 'ir.actions.act_window_close'}
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 729d0dc69b93..424476553e45 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -10,114 +10,137 @@
class PaymentOrderCreate(models.TransientModel):
- _inherit = 'payment.order.create'
+ _inherit = 'account.payment.line.create'
+
+ # @api.multi
+ # def extend_payment_order_domain(self, payment_order, domain):
+ # super(PaymentOrderCreate, self).extend_payment_order_domain(
+ # payment_order, domain)
+ #
+ # if payment_order.mode.type.code == '240':
+ # if payment_order.mode.payment_order_type == 'cobranca':
+ # domain += [
+ # ('debit', '>', 0)
+ # ]
+ #
+ # # TODO: Refactor this
+ # if ('invoice.payment_mode_id', '=', False) in domain:
+ # domain.remove(('invoice.payment_mode_id', '=', False))
+ # if ('date_maturity', '<=', self.duedate) in domain:
+ # domain.remove(('date_maturity', '<=', self.duedate))
+ # if ('date_maturity', '=', False) in domain:
+ # domain.remove(('date_maturity', '=', False))
+ # if ('date_maturity', '<=', self.duedate) in domain:
+ # domain.remove(('date_maturity', '<=', self.duedate))
+ #
+ # elif payment_order.mode.type.code == '400':
+ # if payment_order.mode.payment_order_type == 'cobranca':
+ # domain += [
+ # ('debit', '>', 0),
+ # ('account_id.type', '=', 'receivable'),
+ # '&',
+ # ('payment_mode_id', '=', payment_order.mode.id),
+ # '&',
+ # ('invoice.state', '=', 'open'),
+ # ('invoice.fiscal_category_id.'
+ # 'property_journal.revenue_expense', '=', True)
+ # ]
+ # # TODO: Refactory this
+ # # TODO: domain do state da move_line.
+ # # index = domain.index(('invoice.payment_mode_id', '=', False))
+ # # del domain[index - 1]
+ # # domain.removemove(('invoice.payment_mode_id', '=', False))
+ # # index = domain.index(('date_maturity', '<=', self.duedate))
+ # # del domain[index - 1]
+ # # domain.remove(('date_maturity', '=', False))
+ # # domain.remove(('date_maturity', '<=', self.duedate))
+ #
+ # elif payment_order.mode.type.code == '500':
+ # if payment_order.mode.payment_order_type == 'payment':
+ # domain += [
+ # '&', ('credit', '>', 0),
+ # ('account_id.type', '=', 'payable')
+ # ]
+ # # index = domain.index(('invoice.payment_mode_id', '=', False))
+ # # del domain[index - 1]
+ # # domain.remove(('invoice.payment_mode_id', '=', False))
+ # # index = domain.index(('date_maturity', '<=', self.duedate))
+ # # del domain[index - 1]
+ # # domain.remove(('date_maturity', '=', False))
+ # # domain.remove(('date_maturity', '<=', self.duedate))
+ #
+ # index = domain.index(('account_id.type', '=', 'receivable'))
+ # del domain[index - 1]
+ # domain.remove(('account_id.type', '=', 'receivable'))
+ #
+ # return True
+ #
+ # @api.multi
+ # def _prepare_payment_line(self, payment, line):
+ # res = super(PaymentOrderCreate, self)._prepare_payment_line(
+ # payment, line)
+ #
+ # # res['communication2'] = line.payment_mode_id.comunicacao_2
+ # res['percent_interest'] = line.payment_mode_id.cnab_percent_interest
+ #
+ # if payment.mode.type.code == '400':
+ # # write bool to move_line to avoid it being added on cnab again
+ # self.write_cnab_rejected_bool(line)
+ #
+ # return res
+ #
+ # @api.multi
+ # def filter_lines(self, lines):
+ # """ Filter move lines before proposing them for inclusion
+ # in the payment order.
+ #
+ # This implementation filters out move lines that are already
+ # included in draft or open payment orders. This prevents the
+ # user to include the same line in two different open payment
+ # orders. When the payment order is sent, it is assumed that
+ # the move will be reconciled soon (or immediately with
+ # account_banking_payment_transfer), so it will not be
+ # proposed anymore for payment.
+ #
+ # See also https://github.com/OCA/bank-payment/issues/93.
+ #
+ # :param lines: recordset of move lines
+ # :returns: list of move line ids
+ # """
+ #
+ # self.ensure_one()
+ # payment_lines = self.env['payment.line']. \
+ # search([('order_id.state', 'in', ('draft', 'open', 'done')),
+ # ('move_line_id', 'in', lines.ids)])
+ # # Se foi exportada e o cnab_rejeitado dela for true, pode adicionar
+ # # de novo
+ # to_exclude = set([l.move_line_id.id for l in payment_lines
+ # if not l.move_line_id.is_cnab_rejected])
+ # return [l.id for l in lines if l.id not in to_exclude]
+ #
+ # @api.multi
+ # def write_cnab_rejected_bool(self, line):
+ # line.write({'is_cnab_rejected': False})
+ #
@api.multi
- def extend_payment_order_domain(self, payment_order, domain):
- super(PaymentOrderCreate, self).extend_payment_order_domain(
- payment_order, domain)
+ def _prepare_move_line_domain(self):
+ """ Nenhuma linha deve ser adicionada novamente a nao ser que o
+ retorno do cnab informe que o registro falhou
- if payment_order.mode.type.code == '240':
- if payment_order.mode.payment_order_type == 'cobranca':
- domain += [
- ('debit', '>', 0)
- ]
-
- # TODO: Refactor this
- if ('invoice.payment_mode_id', '=', False) in domain:
- domain.remove(('invoice.payment_mode_id', '=', False))
- if ('date_maturity', '<=', self.duedate) in domain:
- domain.remove(('date_maturity', '<=', self.duedate))
- if ('date_maturity', '=', False) in domain:
- domain.remove(('date_maturity', '=', False))
- if ('date_maturity', '<=', self.duedate) in domain:
- domain.remove(('date_maturity', '<=', self.duedate))
-
- elif payment_order.mode.type.code == '400':
- if payment_order.mode.payment_order_type == 'cobranca':
- domain += [
- ('debit', '>', 0),
- ('account_id.type', '=', 'receivable'),
- '&',
- ('payment_mode_id', '=', payment_order.mode.id),
- '&',
- ('invoice.state', '=', 'open'),
- ('invoice.fiscal_category_id.'
- 'property_journal.revenue_expense', '=', True)
- ]
- # TODO: Refactory this
- # TODO: domain do state da move_line.
- # index = domain.index(('invoice.payment_mode_id', '=', False))
- # del domain[index - 1]
- # domain.removemove(('invoice.payment_mode_id', '=', False))
- # index = domain.index(('date_maturity', '<=', self.duedate))
- # del domain[index - 1]
- # domain.remove(('date_maturity', '=', False))
- # domain.remove(('date_maturity', '<=', self.duedate))
-
- elif payment_order.mode.type.code == '500':
- if payment_order.mode.payment_order_type == 'payment':
- domain += [
- '&', ('credit', '>', 0),
- ('account_id.type', '=', 'payable')
- ]
- # index = domain.index(('invoice.payment_mode_id', '=', False))
- # del domain[index - 1]
- # domain.remove(('invoice.payment_mode_id', '=', False))
- # index = domain.index(('date_maturity', '<=', self.duedate))
- # del domain[index - 1]
- # domain.remove(('date_maturity', '=', False))
- # domain.remove(('date_maturity', '<=', self.duedate))
-
- index = domain.index(('account_id.type', '=', 'receivable'))
- del domain[index - 1]
- domain.remove(('account_id.type', '=', 'receivable'))
-
- return True
-
- @api.multi
- def _prepare_payment_line(self, payment, line):
- res = super(PaymentOrderCreate, self)._prepare_payment_line(
- payment, line)
-
- # res['communication2'] = line.payment_mode_id.comunicacao_2
- res['percent_interest'] = line.payment_mode_id.cnab_percent_interest
-
- if payment.mode.type.code == '400':
- # write bool to move_line to avoid it being added on cnab again
- self.write_cnab_rejected_bool(line)
-
- return res
-
- @api.multi
- def filter_lines(self, lines):
- """ Filter move lines before proposing them for inclusion
- in the payment order.
-
- This implementation filters out move lines that are already
- included in draft or open payment orders. This prevents the
- user to include the same line in two different open payment
- orders. When the payment order is sent, it is assumed that
- the move will be reconciled soon (or immediately with
- account_banking_payment_transfer), so it will not be
- proposed anymore for payment.
-
- See also https://github.com/OCA/bank-payment/issues/93.
-
- :param lines: recordset of move lines
- :returns: list of move line ids
+ :return:
"""
+ domain = super(PaymentOrderCreate, self)._prepare_move_line_domain()
- self.ensure_one()
- payment_lines = self.env['payment.line']. \
- search([('order_id.state', 'in', ('draft', 'open', 'done')),
- ('move_line_id', 'in', lines.ids)])
- # Se foi exportada e o cnab_rejeitado dela for true, pode adicionar
- # de novo
- to_exclude = set([l.move_line_id.id for l in payment_lines
- if not l.move_line_id.is_cnab_rejected])
- return [l.id for l in lines if l.id not in to_exclude]
+ paylines = self.env['account.payment.line'].search([
+ ('state', 'in', ('draft', 'open', 'generated', 'uploaded')),
+ ('move_line_id', '!=', False)])
- @api.multi
- def write_cnab_rejected_bool(self, line):
- line.write({'is_cnab_rejected': False})
+ if paylines:
+ move_lines_ids = [
+ payline.move_line_id.id for payline in paylines
+ if not payline.move_line_id.is_cnab_rejected
+ ]
+ domain += [('id', 'not in', move_lines_ids)]
+
+ return domain
\ No newline at end of file
From 0ab91358533261937aadbb47a28f4e8682da9f51 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 03:09:48 -0300
Subject: [PATCH 059/612] =?UTF-8?q?[WIP]=20Gera=C3=A7=C3=A3o=20do=20PDF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_cobranca/__init__.py | 1 +
.../__manifest__.py | 2 +
.../boleto/document.py | 60 +++++++++---------
.../models/account_move_line.py | 62 +++++++++----------
.../reports/report.py | 24 +++----
5 files changed, 77 insertions(+), 72 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__init__.py b/l10n_br_account_payment_cobranca/__init__.py
index b8f61203412a..c8562ac383ea 100644
--- a/l10n_br_account_payment_cobranca/__init__.py
+++ b/l10n_br_account_payment_cobranca/__init__.py
@@ -7,3 +7,4 @@
from . import wizard
from . import models
+from . import reports
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index cbadf03ba606..35115af660b5 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -42,6 +42,8 @@
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
+ 'reports/report_print_button_view.xml',
+
'security/ir.model.access.csv',
],
'demo': [
diff --git a/l10n_br_account_payment_cobranca/boleto/document.py b/l10n_br_account_payment_cobranca/boleto/document.py
index 8365cbcdaa32..191eae183c97 100644
--- a/l10n_br_account_payment_cobranca/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/boleto/document.py
@@ -39,7 +39,7 @@ def getBoleto(move_line, nosso_numero):
@staticmethod
def getBoletoClass(move_line):
- bank_code = move_line.payment_mode_id.bank_id.bank.bic
+ bank_code = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bank_id.code_bc
return bank.get_class_for_codigo(bank_code)
def __init__(self, move_line, nosso_numero):
@@ -65,7 +65,7 @@ def _move_line(self, move_line):
self.boleto.data_vencimento = datetime.date(datetime.strptime(
move_line.date_maturity, '%Y-%m-%d'))
self.boleto.data_documento = datetime.date(datetime.strptime(
- move_line.invoice.date_invoice, '%Y-%m-%d'))
+ move_line.invoice_id.date_invoice, '%Y-%m-%d'))
self.boleto.data_processamento = date.today()
self.boleto.valor = str("%.2f" % move_line.debit or move_line.credit)
self.boleto.valor_documento = str("%.2f" % move_line.debit or
@@ -147,8 +147,8 @@ def __init__(self, move_line, nosso_numero):
# 1: Nosso Numero with 5 positions
# 2: Nosso Numero with 17 positions
self.boleto = Boleto.getBoletoClass(move_line)(7, 2)
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -157,8 +157,8 @@ class BoletoBarisul(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -167,11 +167,11 @@ class BoletoBradesco(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
- self.branch_digit = move_line.payment_mode_id.bank_id.bra_number_dig
+ self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
+ self.branch_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -181,10 +181,10 @@ class BoletoCaixa(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
+ self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -194,8 +194,8 @@ class BoletoHsbc(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -204,8 +204,8 @@ class BoletoItau157(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -214,8 +214,8 @@ class BoletoItau(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -224,8 +224,8 @@ class BoletoReal(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -234,8 +234,8 @@ class BoletoSantander101(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.ios = '0'
self.boleto.nosso_numero = self.nosso_numero
@@ -245,8 +245,8 @@ class BoletoStatander101201(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.ios = '0'
self.boleto.nosso_numero = self.nosso_numero
@@ -257,10 +257,10 @@ class BoletoCaixaSigcb(Boleto):
def __init__(self, move_line, nosso_numero):
from pyboleto.bank.caixa_sigcb import BoletoCaixaSigcb
self.boleto = BoletoCaixaSigcb()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.bank_id.acc_number_dig
+ self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -270,8 +270,8 @@ class BoletoSicredi(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.bank_id.acc_number
- self.branch_number = move_line.payment_mode_id.bank_id.bra_number
+ self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index b4d44965aeab..2d3ea116462f 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -44,41 +44,41 @@ class AccounMoveLine(models.Model):
u'Nosso Número', readonly=True)
@api.multi
- def send_payment(self):
+ def generate_boleto(self):
boleto_list = []
for move_line in self:
- try:
+ # try:
- if move_line.payment_mode_id.type_payment == '00':
- number_type = move_line.company_id.own_number_type
- if not move_line.boleto_own_number:
- if number_type == '0':
- nosso_numero = self.env['ir.sequence'].next_by_id(
- move_line.company_id.own_number_sequence.id)
- elif number_type == '1':
- nosso_numero = \
- move_line.transaction_ref.replace('/', '')
- else:
- nosso_numero = self.env['ir.sequence'].next_by_id(
- move_line.payment_mode_id.
- internal_sequence_id.id
- )
- else:
- nosso_numero = move_line.boleto_own_number
+ # if move_line.payment_mode_id.type_payment == '00':
+ # number_type = move_line.company_id.own_number_type
+ # if not move_line.boleto_own_number:
+ # if number_type == '0':
+ # nosso_numero = self.env['ir.sequence'].next_by_id(
+ # move_line.company_id.own_number_sequence.id)
+ # elif number_type == '1':
+ # nosso_numero = \
+ # move_line.transaction_ref.replace('/', '')
+ # else:
+ # nosso_numero = self.env['ir.sequence'].next_by_id(
+ # move_line.payment_mode_id.
+ # internal_sequence_id.id
+ # )
+ # else:
+ # nosso_numero = move_line.boleto_own_number
- boleto = Boleto.getBoleto(move_line, nosso_numero)
- if boleto:
- move_line.date_payment_created = date.today()
- move_line.transaction_ref = \
- boleto.boleto.format_nosso_numero()
- move_line.boleto_own_number = nosso_numero
+ boleto = Boleto.getBoleto(move_line, move_line.id)
+ # if boleto:
+ # move_line.date_payment_created = date.today()
+ # move_line.transaction_ref = \
+ # boleto.boleto.format_nosso_numero()
+ # move_line.boleto_own_number = nosso_numero
- boleto_list.append(boleto.boleto)
- except BoletoException as be:
- _logger.error(be.message or be.value, exc_info=True)
- continue
- except Exception as e:
- _logger.error(e.message or e.value, exc_info=True)
- continue
+ boleto_list.append(boleto.boleto)
+ # except BoletoException as be:
+ # _logger.error(be.message or be.value, exc_info=True)
+ # continue
+ # except Exception as e:
+ # _logger.error(e.message or e.value, exc_info=True)
+ # continue
return boleto_list
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index 8d868214cf5b..7d32c7b6ca3f 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -5,7 +5,7 @@
from __future__ import with_statement
-from odoo import pooler
+from odoo.api import Environment
from odoo.osv import osv
from odoo.report.interface import report_int
from odoo.report.render import render
@@ -32,24 +32,26 @@ class ReportCustom(report_int):
def create(self, cr, uid, ids, datas, context=False):
if not context:
context = {}
+
+ env = Environment(cr, uid, {})
+
active_ids = context.get('active_ids')
active_model = context.get('active_model')
- pool = pooler.get_pool(cr.dbname)
- ids_move_lines = []
- aml_obj = pool.get('account.move.line')
+ ids_move_lines = []
if active_model == 'account.invoice':
- ai_obj = pool.get('account.invoice')
- for account_invoice in ai_obj.browse(cr, uid, active_ids):
- for move_line in account_invoice.move_line_receivable_id:
- ids_move_lines.append(move_line.id)
+ for invoices in env['account.invoice'].browse(active_ids):
+ receivable_ids = invoices.mapped('move_line_receivable_id')
+ if receivable_ids:
+ ids_move_lines = receivable_ids
elif active_model == 'account.move.line':
- ids_move_lines = active_ids
- else:
+ ids_move_lines = env['account.move.line'].browse(active_ids)
+
+ if not ids_move_lines:
return False
- boleto_list = aml_obj.send_payment(cr, uid, ids_move_lines)
+ boleto_list = ids_move_lines.generate_boleto()
if not boleto_list:
raise osv.except_osv(
'Error !', ('Não é possível gerar os boletos\n'
From f5312c1c352aa8c2f75932c748cec0e985813d94 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 13:57:13 -0300
Subject: [PATCH 060/612] [NEW] Boleto Itau 400
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_240/bancos/itau.py | 10 +-
.../febraban/cnab_400/bancos/itau.py | 158 ++++++++++++++++++
.../febraban/cnab_400/cnab_400.py | 7 +-
.../models/account_invoice.py | 66 +++++---
.../models/account_move_line.py | 4 +-
.../models/account_payment_mode.py | 18 +-
6 files changed, 220 insertions(+), 43 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
index 7ea0487f37cb..61d461f9065c 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
@@ -32,11 +32,11 @@ def _prepare_header(self):
:return:
"""
vals = super(Itau240, self)._prepare_header()
- vals['cedente_dv_ag_cc'] = int(
- vals['cedente_dv_ag_cc'])
- vals['cedente_agencia_dv'] = int(
- vals['cedente_agencia_dv']),
- return vals
+ # vals['cedente_dv_ag_cc'] = int(
+ # vals['cedente_dv_ag_cc'])
+ # vals['cedente_agencia_dv'] = int(
+ # vals['cedente_agencia_dv']),
+ # return vals
def _prepare_cobranca(self, line):
"""
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
new file mode 100644
index 000000000000..e9b9ec880afd
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -0,0 +1,158 @@
+# -*- coding: utf-8 -*-
+# © 2019 KMEE INFORMATICA LTDA
+# @author Luis Felipe Mileo
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from __future__ import division, print_function, unicode_literals
+
+import re
+import string
+from decimal import Decimal
+from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
+
+from ..cnab_400 import Cnab400
+
+
+class Itau400(Cnab400):
+
+ def __init__(self):
+ super(Cnab400, self).__init__()
+ from cnab240.bancos import itau_cobranca_400
+ self.bank = itau_cobranca_400
+ self.controle_linha = 2
+
+ @property
+ def inscricao_tipo(self):
+ # TODO: Implementar codigo para PIS/PASEP
+ if self.order.company_id.partner_id.is_company:
+ return 2
+ else:
+ return 1
+
+ def _prepare_header(self):
+ """
+
+ :param order:
+ :return:
+ """
+ self.controle_linha = 1
+ return {
+ 'cedente_agencia': int(
+ self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(
+ self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv': int(
+ self.order.company_partner_bank_id.acc_number_dig),
+ 'cedente_nome': unicode(self.order.company_id.legal_name),
+ 'arquivo_data_de_geracao': self.data_hoje(),
+ 'arquivo_hora_de_geracao': self.hora_agora(),
+ # TODO: Número sequencial de arquivo
+ 'arquivo_sequencia': int(self.get_file_numeration()),
+ }
+
+ def _prepare_cobranca(self, line):
+ """
+
+ :param line:
+ :return:
+ """
+ sacado_endereco = self.retorna_endereco(line.partner_id.id)
+
+ vals = {
+ 'cedente_inscricao_tipo': self.inscricao_tipo,
+ 'cedente_inscricao_numero': int(punctuation_rm(
+ self.order.company_id.cnpj_cpf)),
+ 'cedente_agencia': int(
+ self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(
+ self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv': int(
+ self.order.company_partner_bank_id.acc_number_dig
+ ),
+ 'instrucao': 0, # TODO VERIFICAR
+ 'identificacao_titulo_empresa': line.name,
+ 'nosso_numero': 0, # TODO
+ 'quantidade_moeda': 0,
+ 'carteira_numero': int(
+ self.order.payment_mode_id.boleto_carteira
+ ),
+ 'carteira_cod': self.order.payment_mode_id.boleto_modalidade,
+ 'identificacao_ocorrencia': 1,
+ 'numero_documento': self.adiciona_digitos_num_doc(
+ line.communication),
+ 'vencimento_titulo': self.format_date(
+ line.date),
+ 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
+ Decimal('1.00')),
+ 'agencia_cobradora': 0,
+ 'especie_titulo': self.order.payment_mode_id.boleto_especie,
+ 'aceite_titulo': self.order.payment_mode_id.boleto_aceite,
+ 'data_emissao_titulo': self.format_date(
+ line.date), # FIXME
+ 'primeira_instrucao': int(
+ self.order.payment_mode_id.boleto_protesto
+ ),
+ 'segunda_instrucao': int(
+ self.order.payment_mode_id.boleto_protesto_prazo
+
+ ),
+ 'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
+ line.amount_currency,
+ self.order.payment_mode_id.cnab_percent_interest
+ ),
+ 'data_limite_desconto': 0,
+ 'valor_desconto': Decimal('0.00'),
+ 'valor_iof': Decimal('0.00'),
+ 'valor_abatimento': Decimal('0.00'),
+ 'sacado_inscricao_tipo': int(
+ self.sacado_inscricao_tipo(line.partner_id)),
+ 'sacado_inscricao_numero': int(
+ self.rmchar(line.partner_id.cnpj_cpf)),
+ 'sacado_nome': line.partner_id.legal_name,
+ 'sacado_endereco': sacado_endereco,
+ 'sacado_bairro': line.partner_id.district,
+ 'sacado_cep': int(line.partner_id.zip.replace('-', '')),
+ 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
+ 'sacado_uf': line.partner_id.state_id.code,
+ 'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
+ 'juros_mora_data': 0,
+ # self.format_date(
+ # line.date),
+ 'prazo': 0, # De 5 a 120 dias.
+ # 'sacador_avalista': u'Protestar após 5 dias',
+ 'num_seq_registro': self.controle_linha,
+ }
+ self.controle_linha += 1
+ return vals
+
+ def nosso_numero(self, format):
+ digito = format[-1:]
+ carteira = format[:3]
+ nosso_numero = re.sub(
+ '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
+ return carteira, nosso_numero, digito
+
+ def retorna_id_empr_benef(self):
+ dig_cart = 3
+ dig_ag = 5
+ dig_conta = 7
+
+ carteira = self.adiciona_digitos(
+ self.order.payment_mode_id.boleto_carteira, dig_cart)
+ agencia = self.adiciona_digitos(
+ self.order.company_partner_bank_id.bra_number, dig_ag)
+ conta = self.adiciona_digitos(
+ self.order.company_partner_bank_id.acc_number, dig_conta)
+
+ ident = u'0' + (carteira) + (agencia) + (conta) + \
+ (self.order.company_partner_bank_id.acc_number_dig)
+ return ident
+
+ def adiciona_digitos(self, campo, num_digitos):
+ chars_faltantes = num_digitos - len(campo)
+ return (u'0' * chars_faltantes) + campo
+
+
+def str_to_unicode(inp_str):
+ inp_str = unicode(inp_str, "utf-8")
+ return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 95b6cf9aa970..e69dd3031fd0 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -88,6 +88,9 @@ def get_bank(bank):
if bank == '237':
from .bancos.bradesco import Bradesco400
return Bradesco400
+ elif bank == '341':
+ from .bancos.itau import Itau400
+ return Itau400
else:
return Cnab400
@@ -349,9 +352,7 @@ def monta_endereco(self, partner_item):
' ' +
number +
' ' +
- complemento +
- ' ' +
- distrito
+ complemento
# + ' ' +
# partner_item.l10n_br_city_id.name +
# ' ' + partner_item.state_id.name
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 93a89f0f4dec..d57e1de38c69 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -29,13 +29,15 @@ def get_invoice_fiscal_number(self):
@api.multi
def action_move_create(self):
+ result = super(AccountInvoice, self).action_move_create()
- for invoice in self:
- if invoice.company_id.own_number_type == SEQUENCIAL_EMPRESA:
- sequence = invoice.company_id.get_own_number_sequence()
- elif invoice.company_id.own_number_type == SEQUENCIAL_FATURA:
- sequence = invoice.get_invoice_fiscal_number()
- elif invoice.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
+ for inv in self:
+ # Verificar se é boleto para criar o numero
+ if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
+ sequence = inv.company_id.get_own_number_sequence()
+ elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
+ sequence = inv.get_invoice_fiscal_number()
+ elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
# TODO: Implementar uma sequencia na carteira de cobranca
raise NotImplementedError
else:
@@ -44,27 +46,39 @@ def action_move_create(self):
u"empresa para determinar o tipo de sequencia utilizada"
u" nas cobrancas")
)
+ inv.transaction_id = sequence
+ for index, interval in enumerate(inv.move_line_receivable_id):
+ interval.transaction_ref = (
+ inv.transaction_id + '/' + str(index+1)
+ )
+
+ return result
- invoice.transaction_id = sequence
- return super(AccountInvoice, self).action_move_create()
@api.multi
- def finalize_invoice_move_lines(self, move_lines):
- """ Propagate the transaction_id from the invoice to the move lines.
+ def invoice_validate(self):
+ result = super(AccountInvoice, self).invoice_validate()
+ self.create_account_payment_line()
+ return result
+
- The transaction id is written on the move lines only if the account is
- the same than the invoice's one.
- """
- move_lines = super(AccountInvoice, self).finalize_invoice_move_lines(
- move_lines)
- for invoice in self:
- if invoice.transaction_id:
- invoice_account_id = invoice.account_id.id
- index = 1
- for line in move_lines:
- # line is a tuple (0, 0, {values})
- if invoice_account_id == line[2]['account_id']:
- line[2]['transaction_ref'] = u'{0}/{1:02d}'.format(
- invoice.transaction_id, index)
- index += 1
- return move_lines
+ # @api.multi
+ # def finalize_invoice_move_lines(self, move_lines):
+ # """ Propagate the transaction_id from the invoice to the move lines.
+ #
+ # The transaction id is written on the move lines only if the account is
+ # the same than the invoice's one.
+ # """
+ # move_lines = super(AccountInvoice, self).finalize_invoice_move_lines(
+ # move_lines)
+ # for invoice in self:
+ # if invoice.transaction_id:
+ # invoice_account_id = invoice.account_id.id
+ # index = 1
+ # for line in move_lines:
+ # # line is a tuple (0, 0, {values})
+ # if invoice_account_id == line[2]['account_id']:
+ # line[2]['transaction_ref'] = u'{0}/{1:02d}'.format(
+ # invoice.transaction_id, index)
+ # index += 1
+ # return move_lines
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 2d3ea116462f..f9a28f1425e3 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -67,7 +67,9 @@ def generate_boleto(self):
# else:
# nosso_numero = move_line.boleto_own_number
- boleto = Boleto.getBoleto(move_line, move_line.id)
+ boleto = Boleto.getBoleto(
+ move_line, move_line.transaction_ref.replace('/','')
+ )
# if boleto:
# move_line.date_payment_created = date.today()
# move_line.transaction_ref = \
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index b3bfc3caa1c4..326ef0b3b358 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -88,14 +88,16 @@ class PaymentMode(models.Model):
('17', u'CONTA DE PRESTAÇÃO DE SERVIÇOS'),
('99', u'DIVERSOS'),
], string=u'Espécie do Título', default='01')
- boleto_protesto = fields.Selection([
- ('0', u'Sem instrução'),
- ('1', u'Protestar (Dias Corridos)'),
- ('2', u'Protestar (Dias Úteis)'),
- ('3', u'Não protestar'),
- ('7', u'Negativar (Dias Corridos)'),
- ('8', u'Não Negativar')
- ], string=u'Códigos de Protesto', default='0')
+ boleto_protesto = fields.Char(
+ # [ Deixado manualmente, pois cada banco parece ter sua tabela.
+ # ('0', u'Sem instrução'),
+ # ('1', u'Protestar (Dias Corridos)'),
+ # ('2', u'Protestar (Dias Úteis)'),
+ # ('3', u'Não protestar'),
+ # ('7', u'Negativar (Dias Corridos)'),
+ # ('8', u'Não Negativar')
+ # ]
+ string=u'Códigos de Protesto', default='0')
boleto_protesto_prazo = fields.Char(u'Prazo protesto', size=2)
@api.constrains('boleto_type', 'boleto_carteira',
From 1c6cba4908902e1ec7137ac172a8b06a024f2e19 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 14:41:05 -0300
Subject: [PATCH 061/612] [REM] Modelos obsoletos
Signed-off-by: Luis Felipe Mileo
---
.../__manifest__.py | 1 -
.../l10n_br_cnab_file_sufix_sequence.py | 17 -------
.../models/l10n_br_cnab_sequence.py | 23 ----------
.../security/ir.model.access.csv | 2 -
.../views/l10n_br_cnab_sequence.xml | 46 -------------------
5 files changed, 89 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
delete mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
delete mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 35115af660b5..9a51f9c41714 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -38,7 +38,6 @@
'views/l10n_br_cnab_retorno_view.xml',
# 'views/l10n_br_payment_cnab.xml',
- # 'views/l10n_br_cnab_sequence.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
deleted file mode 100644
index ad7dbf8c3795..000000000000
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_file_sufix_sequence.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import models, fields
-
-
-class L10nBrCnabFileSufixSequence(models.Model):
- _name = 'l10n_br_cnab_file_sufix.sequence'
-
- code = fields.Char(u'Código')
- name = fields.Char(u'Nome')
- internal_sequence_id = fields.Many2one(
- 'ir.sequence', u'Sequência Interna')
- parent_payment_mode_suf = fields.Many2one(
- 'payment.mode', "Conta de exportação", select=True)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
deleted file mode 100644
index 2cee6a2ac3dc..000000000000
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_sequence.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import models, fields
-
-
-class L10nBrCnabSequence(models.Model):
- _name = 'l10n_br_cnab.sequence'
-
- code = fields.Char(u'Código')
- name = fields.Char(u'Nome')
- internal_sequence_id = fields.Many2one(
- 'ir.sequence', u'Sequência Interna')
- parent_payment_mode = fields.Many2one(
- 'payment.mode', "Conta de exportação", select=True)
-
- # 'parent_id': fields.many2one('res.partner.category',
- # 'Parent Category', select=True, ondelete='cascade')
- # 400: um modo de cobrança = 1 conta bancária = 1 sequencia de arquivo
- # 500: n modos de pagamento (ted, doc) = 1 conta bancária = 1 sequencia de
- # arquivo
diff --git a/l10n_br_account_payment_cobranca/security/ir.model.access.csv b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
index 8ed4b5e73dc6..78218cfacd8a 100644
--- a/l10n_br_account_payment_cobranca/security/ir.model.access.csv
+++ b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
@@ -2,5 +2,3 @@
access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,,1,0,0,0
access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,,1,0
access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,,1,0,0,0
-access_l10n_br_cnab_sequence,access_l10n_br_cnab_sequence,model_l10n_br_cnab_sequence,,1,0,0,0
-access_l10n_br_cnab_file_sufix_sequence,access_l10n_br_cnab_file_sufix_sequence,model_l10n_br_cnab_file_sufix_sequence,,1,0,0,0
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
deleted file mode 100644
index 6f6785d0b38b..000000000000
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_sequence.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
- l10n_br_cnab_sequence.form.view
- l10n_br_cnab.sequence
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- l10n_br_cnab_sequence.tree.view
- l10n_br_cnab.sequence
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 9c957970c70b45f94bf6f6c07454fa6b83a785d6 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Thu, 30 May 2019 15:48:34 -0300
Subject: [PATCH 062/612] =?UTF-8?q?[IMP]adic=C3=A3o=20de=20estados=20cnab?=
=?UTF-8?q?=20para=20valida=C3=A7=C3=B5es=20na=20geracao=20de=20boleto=20e?=
=?UTF-8?q?=20adicao=20de=20linhas=20para=20payment=20order?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_move_line.py | 61 +++++++++++++------
.../models/account_payment_order.py | 8 +++
.../models/l10n_br_cnab.py | 11 +++-
.../views/account_move_line.xml | 2 +-
.../wizard/payment_order_create.py | 4 +-
5 files changed, 64 insertions(+), 22 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index f9a28f1425e3..41c7535e3db9 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -6,34 +6,35 @@
import logging
from datetime import date
-from odoo import models, fields, api
+from odoo import models, fields, api, _
from ..boleto.document import Boleto
from ..boleto.document import BoletoException
+from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
-# ESTADOS_CNAB = [
-# ('draft', u'Inicial'),
-# ('added', u'Adicionada à ordem de pagamento'),
-# ('exported', u'Exportada'),
-# ('accepted', u'Aceita'),
-# ('not_accepted', u'Não aceita pelo banco'), # importar novamente
-# ]
+ESTADOS_CNAB = [
+ ('draft', u'Inicial'), # ok
+ ('added', u'Adicionada à ordem de pagamento'), # ok
+ ('exported', u'Exportada'), # ok
+ ('accepted', u'Aceita'),
+ ('not_accepted', u'Não aceita pelo banco'), # importar novamente
+]
class AccounMoveLine(models.Model):
_inherit = "account.move.line"
- #
- # state_cnab = fields.Selection(
- # ESTADOS_CNAB, u'Estados CNAB', default='draft')
-
- is_cnab_rejected = fields.Boolean(
- u'Pode ser exportada novamente', default=False,
- help='Marque esse campo para indicar um título que pode ser '
- 'exportado novamente pelo CNAB')
- cnab_rejected_code = fields.Char(u'Rejeição')
+
+ state_cnab = fields.Selection(
+ ESTADOS_CNAB, u'Estados CNAB', default='draft')
+
+ # is_cnab_rejected = fields.Boolean(
+ # u'Pode ser exportada novamente', default=False,
+ # help='Marque esse campo para indicar um título que pode ser '
+ # 'exportado novamente pelo CNAB')
+ # cnab_rejected_code = fields.Char(u'Rejeição')
# transaction_ref = fields.char('Transaction Ref.',
# select=True,
# store=True,
@@ -43,11 +44,37 @@ class AccounMoveLine(models.Model):
boleto_own_number = fields.Char(
u'Nosso Número', readonly=True)
+ @api.multi
+ def create_payment_line_from_move_line(self, payment_order):
+ """
+ Altera estado do cnab para adicionado a ordem
+ :param payment_order:
+ :return:
+ """
+ self.state_cnab = 'added'
+ return super(AccounMoveLine, self).create_payment_line_from_move_line(
+ payment_order
+ )
+
+
@api.multi
def generate_boleto(self):
boleto_list = []
for move_line in self:
+
+ if move_line.state_cnab != 'accepted':
+ if move_line.state_cnab == 'not_accepted':
+ raise UserError(_(
+ u'O arquivo CNAB relacionado a essa nota foi '
+ u'transmitido com erro, é necessário corrigi-lo '
+ u'e reenviá-lo'
+ ))
+ raise UserError(_(
+ u'É necessário transmitir e processar o retorno do CNAB'
+ u' referente a essa nota para garantir que o '
+ u'boleto está registrado no banco'
+ ))
# try:
# if move_line.payment_mode_id.type_payment == '00':
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 5bdb61673fa8..1c4d0d1fe95c 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -71,6 +71,14 @@ class PaymentOrder(models.Model):
default='0',
)
+ @api.multi
+ def open2generated(self):
+ action = super(PaymentOrder, self).open2generated()
+ if self.state == 'generated':
+ for payment_line in self.payment_line_ids:
+ payment_line.move_line_id.state_cnab = 'exported'
+ return action
+
@api.multi
def generate_payment_file(self):
"""Returns (payment file as string, filename)"""
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index e6ff58cbae17..7e9cedd22138 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -182,9 +182,16 @@ def processar_arquivo_retorno(self):
self.env['l10n.br.cnab.evento'].create(vals_evento)
if evento.ocorrencias and bank_payment_line_id:
if '00' in ocorrencias:
- bank_payment_line_id.write({'state2': 'paid'})
+ bank_state = 'paid'
+ cnab_state = 'accepted'
+
else:
- bank_payment_line_id.write({'state2': 'exception'})
+ bank_state = 'exception'
+ cnab_state = 'not_accepted'
+
+ bank_payment_line_id.state2 = bank_state
+ for payment_line in bank_payment_line_id.payment_line_ids:
+ payment_line.move_line_id.state_cnab = cnab_state
return self.write({'state': 'done'})
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index 435b9313a25c..ca449a82e8a5 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 424476553e45..de0723af4266 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -139,8 +139,8 @@ def _prepare_move_line_domain(self):
if paylines:
move_lines_ids = [
payline.move_line_id.id for payline in paylines
- if not payline.move_line_id.is_cnab_rejected
+ if payline.move_line_id.state_cnab == 'not_accepted'
]
domain += [('id', 'not in', move_lines_ids)]
- return domain
\ No newline at end of file
+ return domain
From 471ee348ed45e1fb13580576314cf6fc404756d9 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 17:10:45 -0300
Subject: [PATCH 063/612] [REF] Melhorias no sequencial e controle de retorno
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_400/bancos/itau.py | 18 +++++++++---------
.../models/account_invoice.py | 5 ++++-
.../models/account_move_line.py | 18 ++++++++++++++++--
.../models/account_payment_line.py | 9 +++++----
.../models/account_payment_order.py | 8 ++++++++
.../models/bank_payment_line.py | 7 +++++++
.../views/account_move_line.xml | 2 ++
.../views/account_payment_line.xml | 3 ++-
.../views/bank_payment_line.xml | 2 ++
9 files changed, 55 insertions(+), 17 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index e9b9ec880afd..cebd51d7b094 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -19,7 +19,7 @@ def __init__(self):
super(Cnab400, self).__init__()
from cnab240.bancos import itau_cobranca_400
self.bank = itau_cobranca_400
- self.controle_linha = 2
+ self.controle_linha = 1
@property
def inscricao_tipo(self):
@@ -35,8 +35,7 @@ def _prepare_header(self):
:param order:
:return:
"""
- self.controle_linha = 1
- return {
+ vals = {
'cedente_agencia': int(
self.order.company_partner_bank_id.bra_number),
'cedente_conta': int(
@@ -46,9 +45,10 @@ def _prepare_header(self):
'cedente_nome': unicode(self.order.company_id.legal_name),
'arquivo_data_de_geracao': self.data_hoje(),
'arquivo_hora_de_geracao': self.hora_agora(),
- # TODO: Número sequencial de arquivo
- 'arquivo_sequencia': int(self.get_file_numeration()),
+ 'num_seq_registro': self.controle_linha,
}
+ self.controle_linha += 1
+ return vals
def _prepare_cobranca(self, line):
"""
@@ -59,6 +59,10 @@ def _prepare_cobranca(self, line):
sacado_endereco = self.retorna_endereco(line.partner_id.id)
vals = {
+ 'identificacao_titulo_empresa': line.name,
+ 'nosso_numero': line.nosso_numero,
+ 'numero_documento': self.adiciona_digitos_num_doc(
+ line.numero_documento),
'cedente_inscricao_tipo': self.inscricao_tipo,
'cedente_inscricao_numero': int(punctuation_rm(
self.order.company_id.cnpj_cpf)),
@@ -70,16 +74,12 @@ def _prepare_cobranca(self, line):
self.order.company_partner_bank_id.acc_number_dig
),
'instrucao': 0, # TODO VERIFICAR
- 'identificacao_titulo_empresa': line.name,
- 'nosso_numero': 0, # TODO
'quantidade_moeda': 0,
'carteira_numero': int(
self.order.payment_mode_id.boleto_carteira
),
'carteira_cod': self.order.payment_mode_id.boleto_modalidade,
'identificacao_ocorrencia': 1,
- 'numero_documento': self.adiciona_digitos_num_doc(
- line.communication),
'vencimento_titulo': self.format_date(
line.date),
'valor_titulo': Decimal(str(line.amount_currency)).quantize(
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index d57e1de38c69..f43b1baed57a 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -48,9 +48,12 @@ def action_move_create(self):
)
inv.transaction_id = sequence
for index, interval in enumerate(inv.move_line_receivable_id):
- interval.transaction_ref = (
+ nosso_numero = (
inv.transaction_id + '/' + str(index+1)
)
+ interval.transaction_ref = nosso_numero
+ interval.nosso_numero = nosso_numero
+ interval.numero_documento = inv.get_invoice_fiscal_number()
return result
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 41c7535e3db9..f69c71733b8b 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -41,8 +41,22 @@ class AccounMoveLine(models.Model):
# related='name')
date_payment_created = fields.Date(
u'Data da criação do pagamento', readonly=True)
- boleto_own_number = fields.Char(
- u'Nosso Número', readonly=True)
+ nosso_numero = fields.Char(
+ string=u'Nosso Numero',
+ )
+ numero_documento = fields.Char(
+ string=u'Número documento'
+ )
+
+ @api.multi
+ def _prepare_payment_line_vals(self, payment_order):
+ vals = super(AccounMoveLine, self)._prepare_payment_line_vals(
+ payment_order
+ )
+ vals['nosso_numero'] = self.nosso_numero
+ vals['numero_documento'] = self.numero_documento
+ vals['communication'] = self.id
+ return vals
@api.multi
def create_payment_line_from_move_line(self, payment_order):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index bf43839aaadd..ff3e2905556c 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -34,10 +34,11 @@ def default_get(self, fields_list):
})
return res
- seu_numero = fields.Char(
- string=u'Seu Número',
- size=20,
- help=u'Campo G064'
+ nosso_numero = fields.Char(
+ string=u'Nosso Numero',
+ )
+ numero_documento = fields.Char(
+ string=u'Número documento'
)
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 1c4d0d1fe95c..94d9aa002064 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -71,6 +71,14 @@ class PaymentOrder(models.Model):
default='0',
)
+ @api.model
+ def _prepare_bank_payment_line(self, paylines):
+ result = super(PaymentOrder, self)._prepare_bank_payment_line(paylines)
+ result['nosso_numero'] = paylines.nosso_numero
+ result['numero_documento'] = paylines.numero_documento
+ result['communication'] = paylines.move_line_id.id
+ return result
+
@api.multi
def open2generated(self):
action = super(PaymentOrder, self).open2generated()
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 434ba77fe97f..d22be4039530 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -89,6 +89,12 @@ def default_get(self, fields_list):
string=u'Código de finalidade complementar',
help=u'Campo P013 do CNAB',
)
+ nosso_numero = fields.Char(
+ string=u'Nosso Numero',
+ )
+ numero_documento = fields.Char(
+ string=u'Número documento'
+ )
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
@@ -102,6 +108,7 @@ def same_fields_payment_line_and_bank_payment_line(self):
BankPaymentLine, self
).same_fields_payment_line_and_bank_payment_line()
+
# TODO: Implementar campo brasileiros que permitem mesclar linhas
same_fields = [] # Por segurança não vamos mesclar nada
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index ca449a82e8a5..8ecdd1349e5b 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -9,6 +9,8 @@
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
index c4e198b88bdc..cea643fd5666 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -13,7 +13,8 @@
-
+
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index c8a1a0b9b543..bdab577a42b3 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -8,6 +8,8 @@
+
+
From 0168d159b665c57573d8119b63ac1b1b42d4f014 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 May 2019 17:41:09 -0300
Subject: [PATCH 064/612] [REF] Melhorias no numero do documento, nosso numero
e identificador empresa
Signed-off-by: Luis Felipe Mileo
Signed-off-by: Luis Felipe Mileo
---
.../boleto/document.py | 8 +--
.../febraban/cnab_400/bancos/itau.py | 4 +-
.../models/account_invoice.py | 50 +++++++++++--------
.../models/account_move_line.py | 6 ++-
.../models/account_payment_line.py | 3 ++
.../models/account_payment_order.py | 3 +-
.../models/bank_payment_line.py | 3 ++
.../views/account_move_line.xml | 10 ++--
.../views/account_payment_line.xml | 1 +
.../views/bank_payment_line.xml | 1 +
10 files changed, 53 insertions(+), 36 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/boleto/document.py b/l10n_br_account_payment_cobranca/boleto/document.py
index 191eae183c97..ae4d55218811 100644
--- a/l10n_br_account_payment_cobranca/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/boleto/document.py
@@ -73,7 +73,7 @@ def _move_line(self, move_line):
self.boleto.especie = \
move_line.currency_id and move_line.currency_id.symbol or 'R$'
self.boleto.quantidade = '' # str("%.2f" % move_line.amount_currency)
- self.boleto.numero_documento = move_line.name.encode('utf-8')
+ self.boleto.numero_documento = move_line.numero_documento
def _payment_mode(self, payment_mode_id):
"""
@@ -94,7 +94,7 @@ def _cedente(self, company):
self.boleto.cedente_documento = company.cnpj_cpf.encode('utf-8')
self.boleto.cedente_bairro = company.district
self.boleto.cedente_cep = company.zip
- self.boleto.cedente_cidade = company.city
+ self.boleto.cedente_cidade = company.l10n_br_city_id.name
self.boleto.cedente_logradouro = company.street + ', ' + company.number
self.boleto.cedente_uf = company.state_id.code
self.boleto.agencia_cedente = self.getBranchNumber()
@@ -107,8 +107,8 @@ def _sacado(self, partner):
:return:
"""
self.boleto.sacado_endereco = partner.street + ', ' + partner.number
- self.boleto.sacado_cidade = partner.city
- self.boleto.sacado_bairro = partner.district
+ self.boleto.sacado_cidade = partner.l10n_br_city_id.name
+ self.boleto.sacado_bairro = partner.district or ''
self.boleto.sacado_uf = partner.state_id.code
self.boleto.sacado_cep = partner.zip
self.boleto.sacado_nome = partner.legal_name
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index cebd51d7b094..c423650c5582 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -59,8 +59,8 @@ def _prepare_cobranca(self, line):
sacado_endereco = self.retorna_endereco(line.partner_id.id)
vals = {
- 'identificacao_titulo_empresa': line.name,
- 'nosso_numero': line.nosso_numero,
+ 'identificacao_titulo_empresa': line.identificacao_titulo_empresa,
+ 'nosso_numero': int(line.nosso_numero),
'numero_documento': self.adiciona_digitos_num_doc(
line.numero_documento),
'cedente_inscricao_tipo': self.inscricao_tipo,
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index f43b1baed57a..c26455806a04 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -32,31 +32,38 @@ def action_move_create(self):
result = super(AccountInvoice, self).action_move_create()
for inv in self:
- # Verificar se é boleto para criar o numero
- if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
- sequence = inv.company_id.get_own_number_sequence()
- elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
- sequence = inv.get_invoice_fiscal_number()
- elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
- # TODO: Implementar uma sequencia na carteira de cobranca
- raise NotImplementedError
- else:
- raise UserError(
- _(u"Favor acessar aba Cobrança da configuração da sua "
- u"empresa para determinar o tipo de sequencia utilizada"
- u" nas cobrancas")
- )
- inv.transaction_id = sequence
+
+ # inv.transaction_id = sequence
for index, interval in enumerate(inv.move_line_receivable_id):
- nosso_numero = (
- inv.transaction_id + '/' + str(index+1)
+ numero_documento = (
+ inv.get_invoice_fiscal_number() +
+ '/' +
+ str(index + 1).zfill(2)
)
- interval.transaction_ref = nosso_numero
- interval.nosso_numero = nosso_numero
- interval.numero_documento = inv.get_invoice_fiscal_number()
- return result
+ # Verificar se é boleto para criar o numero
+ if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
+ sequence = inv.company_id.get_own_number_sequence()
+ elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
+ sequence = numero_documento.replace('/', '')
+ elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
+ # TODO: Implementar uma sequencia na carteira de cobranca
+ raise NotImplementedError
+ else:
+ raise UserError(_(
+ u"Favor acessar aba Cobrança da configuração da"
+ u" sua empresa para determinar o tipo de "
+ u"sequencia utilizada nas cobrancas"
+ ))
+ interval.transaction_ref = sequence
+ interval.nosso_numero = sequence
+ interval.numero_documento = numero_documento
+ interval.identificacao_titulo_empresa = hex(
+ interval.id
+ ).upper()
+
+ return result
@api.multi
def invoice_validate(self):
@@ -64,7 +71,6 @@ def invoice_validate(self):
self.create_account_payment_line()
return result
-
# @api.multi
# def finalize_invoice_move_lines(self, move_lines):
# """ Propagate the transaction_id from the invoice to the move lines.
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index f69c71733b8b..ace886169b14 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -47,6 +47,9 @@ class AccounMoveLine(models.Model):
numero_documento = fields.Char(
string=u'Número documento'
)
+ identificacao_titulo_empresa = fields.Char(
+ string=u'Identificação Titulo Empresa',
+ )
@api.multi
def _prepare_payment_line_vals(self, payment_order):
@@ -55,7 +58,8 @@ def _prepare_payment_line_vals(self, payment_order):
)
vals['nosso_numero'] = self.nosso_numero
vals['numero_documento'] = self.numero_documento
- vals['communication'] = self.id
+ vals['identificacao_titulo_empresa'] = \
+ self.identificacao_titulo_empresa
return vals
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index ff3e2905556c..c6eea459b04c 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -40,6 +40,9 @@ def default_get(self, fields_list):
numero_documento = fields.Char(
string=u'Número documento'
)
+ identificacao_titulo_empresa = fields.Char(
+ string=u'Identificação Titulo Empresa',
+ )
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
string=u'Complemento do Tipo de Serviço',
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 94d9aa002064..37114ad1272d 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -76,7 +76,8 @@ def _prepare_bank_payment_line(self, paylines):
result = super(PaymentOrder, self)._prepare_bank_payment_line(paylines)
result['nosso_numero'] = paylines.nosso_numero
result['numero_documento'] = paylines.numero_documento
- result['communication'] = paylines.move_line_id.id
+ result['identificacao_titulo_empresa'] = \
+ paylines.identificacao_titulo_empresa
return result
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index d22be4039530..9741c4102f07 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -95,6 +95,9 @@ def default_get(self, fields_list):
numero_documento = fields.Char(
string=u'Número documento'
)
+ identificacao_titulo_empresa = fields.Char(
+ string=u'Identificação Titulo Empresa',
+ )
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index 8ecdd1349e5b..e52294bb1c62 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -7,12 +7,10 @@
-
-
-
-
-
-
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
index cea643fd5666..dab2602d8930 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -15,6 +15,7 @@
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index bdab577a42b3..413930550a0a 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -10,6 +10,7 @@
+
From 52c9704df7c415b84bb3fdb2cbd246483b266858 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Fri, 31 May 2019 16:05:12 -0300
Subject: [PATCH 065/612] =?UTF-8?q?[FIX]=20Bairro=20pode=20ser=20vazio=20e?=
=?UTF-8?q?nt=C3=A3o=20n=C3=A3o=20passar=20o=20valor=20como=20False?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py | 2 +-
.../febraban/cnab_400/bancos/itau.py | 2 +-
l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index d8aa81aae44a..0da0e4bea1af 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -290,7 +290,7 @@ def _prepare_cobranca(self, line):
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
line.partner_id.street + ' ' + line.partner_id.number),
- 'sacado_bairro': line.partner_id.district,
+ 'sacado_bairro': line.partner_id.district or '',
'sacado_cep': self.get_cep('prefixo', line.partner_id.zip),
'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index c423650c5582..8373fcd72e59 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -110,7 +110,7 @@ def _prepare_cobranca(self, line):
self.rmchar(line.partner_id.cnpj_cpf)),
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': sacado_endereco,
- 'sacado_bairro': line.partner_id.district,
+ 'sacado_bairro': line.partner_id.district or '',
'sacado_cep': int(line.partner_id.zip.replace('-', '')),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index e69dd3031fd0..14431595cb53 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -263,7 +263,7 @@ def _prepare_cobranca(self, line):
'sacado_endereco': sacado_endereco,
- 'sacado_bairro': line.partner_id.district,
+ 'sacado_bairro': line.partner_id.district or '',
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
'codigo_baixa': 2,
From 0cdd910be5669b1048dc117c143b9f51df14fba5 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Fri, 31 May 2019 16:53:04 -0300
Subject: [PATCH 066/612] =?UTF-8?q?[IMP]controle=20de=20gera=C3=A7=C3=A3o?=
=?UTF-8?q?=20de=20nosso=5Fnumero?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 3 ++-
.../models/account_payment_mode.py | 6 ++++++
.../views/account_payment_mode.xml | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index c26455806a04..b8ecf29d6ff9 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -57,7 +57,8 @@ def action_move_create(self):
))
interval.transaction_ref = sequence
- interval.nosso_numero = sequence
+ interval.nosso_numero = sequence if \
+ interval.payment_mode_id.gera_nosso_numero else '0'
interval.numero_documento = numero_documento
interval.identificacao_titulo_empresa = hex(
interval.id
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 326ef0b3b358..eb34c45dd112 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -99,6 +99,12 @@ class PaymentMode(models.Model):
# ]
string=u'Códigos de Protesto', default='0')
boleto_protesto_prazo = fields.Char(u'Prazo protesto', size=2)
+ gera_nosso_numero = fields.Boolean(
+ string=u'Gerar nosso número?',
+ help=u'Dependendo da carteira, banco, etc. '
+ u'O nosso número pode ser gerado pelo banco.',
+ default=True
+ )
@api.constrains('boleto_type', 'boleto_carteira',
'boleto_modalidade', 'boleto_convenio',
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index ab6ee4109161..2c31b05ca854 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -18,6 +18,7 @@
+
From bf6075e1cf4447d80afd517965355bae2724c985 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 31 May 2019 18:07:48 -0300
Subject: [PATCH 067/612] [IMP] Refatoracao retorno
---
.../febraban/cnab.py | 49 +++++++-
.../febraban/cnab_400/bancos/itau.py | 12 +-
.../febraban/cnab_400/cnab_400.py | 2 +-
.../models/l10n_br_cnab.py | 114 +++++++++++-------
4 files changed, 124 insertions(+), 53 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
index 5c9f1d016640..add68c646751 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -7,12 +7,20 @@
# TODO: implement abc factory?
from __future__ import division, print_function, unicode_literals
+import base64
+import codecs
+
+try:
+ from cnab240.tipos import ArquivoCobranca400
+except ImportError as err:
+ _logger.debug = (err)
class Cnab(object):
def __init__(self):
- pass
+ self.arquivo = False
+ self.cnab_type = False
@staticmethod
def get_cnab(bank, cnab_type='240'):
@@ -28,8 +36,39 @@ def get_cnab(bank, cnab_type='240'):
else:
return False
- def remessa(self, order):
- return False
+ @staticmethod
+ def remessa(order):
+ cnab = Cnab.get_cnab(
+ order.company_partner_bank_id.bank_id.code_bc,
+ order.payment_mode_id.payment_method_id.code
+ )()
+ return cnab.remessa(order)
+
+ @staticmethod
+ def detectar_retorno(cnab_file_object):
+ arquivo_retono = base64.b64decode(cnab_file_object)
+ f = open('/tmp/cnab_retorno.ret', 'wb')
+ f.write(arquivo_retono)
+ f.close()
+ arquivo_retorno = codecs.open(
+ '/tmp/cnab_retorno.ret',
+ encoding='ascii'
+ )
+ header = arquivo_retorno.readline()
+ arquivo_retorno.seek(0)
+
+ if 210 < len(header) < 410:
+ cnab_type = '400'
+ banco = header[76:79]
+ elif len(header) < 210:
+ cnab_type = '240'
+ banco = header[:3]
+
+ cnab = Cnab.get_cnab(banco, cnab_type)()
+ return cnab.retorno(arquivo_retorno)
- def retorno(self, cnab_file):
- return object
+ def retorno(self, arquivo_retorno):
+ return ArquivoCobranca400(
+ self.classe_retorno,
+ arquivo=arquivo_retorno
+ )
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 8373fcd72e59..42fcbc32b6ad 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -17,10 +17,18 @@ class Itau400(Cnab400):
def __init__(self):
super(Cnab400, self).__init__()
- from cnab240.bancos import itau_cobranca_400
- self.bank = itau_cobranca_400
self.controle_linha = 1
+ def remessa(self, order):
+ from cnab240.bancos import itau_cobranca_400
+ self.classe_remessa = itau_cobranca_400
+ return super(Cnab400, self).remessa(order)
+
+ def retorno(self, arquivo_retorno):
+ from cnab240.bancos import itau_cobranca_retorno_400
+ self.classe_retorno = itau_cobranca_retorno_400
+ return super(Cnab400, self).retorno(arquivo_retorno)
+
@property
def inscricao_tipo(self):
# TODO: Implementar codigo para PIS/PASEP
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 14431595cb53..e9aa74b9be66 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -290,7 +290,7 @@ def remessa(self, order):
:return:
"""
self.order = order
- self.arquivo = ArquivoCobranca400(self.bank, **self._prepare_header())
+ self.arquivo = ArquivoCobranca400(self.remessa, **self._prepare_header())
for line in order.bank_line_ids:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
self.arquivo.trailer.num_seq_registro = self.controle_linha
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 7e9cedd22138..3cd5f5625e79 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -3,20 +3,14 @@
# @author Luiz Felipe do Divino Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import base64
-import codecs
import logging
from datetime import datetime
from ..constantes import CODIGO_OCORRENCIAS
+from ..febraban.cnab import Cnab
from odoo import api, models, fields, exceptions
_logger = logging.getLogger(__name__)
-try:
- from cnab240.bancos import bancodobrasil
- from cnab240.tipos import Arquivo
-except ImportError as err:
- _logger.debug = (err)
STATE = [
('draft', 'Novo'),
@@ -82,62 +76,92 @@ class L10nBrHrCnab(models.Model):
_name = "l10n.br.cnab"
_rec_name = "display_name"
+
+ def _busca_conta(self, banco, agencia, conta):
+ return self.env['res.partner.bank'].search([
+ # ('acc_number', '=', str(banco)),
+ ('bra_number', '=', str(agencia)),
+ ('acc_number', '=', str(conta))
+ ]).id
+
+ def _cria_lote(self, header, lote, evento, trailer):
+
+ if lote.header:
+ lote_bank_account_id = self._busca_conta(
+ lote.header.codigo_do_banco,
+ lote.header.cedente_agencia,
+ lote.header.cedente_conta,
+ ).id
+ else:
+ lote_bank_account_id = self.bank_account_id
+
+ vals = {
+ 'account_bank_id': lote_bank_account_id.id,
+ # 'empresa_inscricao_numero':
+ # str(header.empresa_inscricao_numero),
+ # 'empresa_inscricao_tipo':
+ # TIPO_INSCRICAO_EMPRESA[header.empresa_inscricao_tipo],
+ # 'servico_operacao': TIPO_OPERACAO[header.servico_operacao],
+ # 'tipo_servico': TIPO_SERVICO[str(header.servico_servico)],
+ # 'mensagem': header.mensagem1,
+ # 'total_valores': float(trailer.somatoria_valores),
+ 'servico_operacao': header.literal_retorno,
+ 'tipo_servico': header.literal_servico,
+ 'qtd_registros': trailer.totais_quantidade_registros,
+ 'total_valores': float(trailer.valor_total_titulos/100),
+ 'cnab_id': self.id,
+ }
+
+ lote_id = self.env['l10n.br.cnab.lote'].create(vals)
+
+ return lote_id, lote_bank_account_id
+
+
@api.multi
def processar_arquivo_retorno(self):
- arquivo_retono = base64.b64decode(self.arquivo_retorno)
- f = open('/tmp/cnab_retorno.ret', 'wb')
- f.write(arquivo_retono)
- f.close()
- arquivo_retono = codecs.open('/tmp/cnab_retorno.ret', encoding='ascii')
- arquivo_parser = Arquivo(bancodobrasil, arquivo=arquivo_retono)
- if not arquivo_parser.header.arquivo_codigo == u'2':
- raise exceptions.Warning(
- u"Este não é um arquivo de retorno!"
- )
+ arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
+ # if not arquivo_parser.header.arquivo_codigo == u'2':
+ # raise exceptions.Warning(
+ # u"Este não é um arquivo de retorno!"
+ # )
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
- self.data_arquivo = fields.Date.from_string(
- data_arquivo[4:] + "-" + data_arquivo[2:4] + "-" +
- data_arquivo[0:2]
+ self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
+
+ self.bank_account_id = self._busca_conta(
+ arquivo_parser.header.codigo_do_banco,
+ arquivo_parser.header.cedente_agencia,
+ arquivo_parser.header.cedente_conta,
)
- self.bank_account_id = self.env['res.partner.bank'].search(
- [('acc_number', '=', arquivo_parser.header.cedente_conta)]).id
- self.num_lotes = arquivo_parser.trailer.totais_quantidade_lotes
+
+ self.num_lotes = len(arquivo_parser.lotes)
self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
for lote in arquivo_parser.lotes:
- account_bank_id_lote = self.env['res.partner.bank'].search(
- [('acc_number', '=', lote.header.cedente_conta)]
- ).id
- vals = {
- 'account_bank_id': account_bank_id_lote,
- 'empresa_inscricao_numero':
- str(lote.header.empresa_inscricao_numero),
- 'empresa_inscricao_tipo':
- TIPO_INSCRICAO_EMPRESA[lote.header.empresa_inscricao_tipo],
- 'servico_operacao':
- TIPO_OPERACAO[lote.header.servico_operacao],
- 'tipo_servico': TIPO_SERVICO[str(lote.header.servico_servico)],
- 'mensagem': lote.header.mensagem1,
- 'qtd_registros': lote.trailer.quantidade_registros,
- 'total_valores': float(lote.trailer.somatoria_valores),
- 'cnab_id': self.id,
- }
- lote_id = self.env['l10n.br.cnab.lote'].create(vals)
+
+ header = lote.header or arquivo_parser.header
+ trailer = lote.trailer or arquivo_parser.trailer
+
+ lote_id = False
+
for evento in lote.eventos:
+ if not lote_id:
+ lote_id, lote_bank_account_id = self._cria_lote(
+ header, lote, evento, trailer)
+
data_evento = str(
evento.credito_data_real)
data_evento = fields.Date.from_string(
data_evento[4:] + "-" + data_evento[2:4] + "-" +
data_evento[0:2]
)
- account_bank_id_lote = self.env['res.partner.bank'].search(
+ lote_bank_account_id = self.env['res.partner.bank'].search(
[
('bra_number', '=', evento.favorecido_agencia),
('bra_number_dig', '=', evento.favorecido_agencia_dv),
('acc_number', '=', evento.favorecido_conta),
('acc_number_dig', '=', evento.favorecido_conta_dv)
])
- account_bank_id_lote = account_bank_id_lote.ids[0] \
- if account_bank_id_lote else False
+ lote_bank_account_id = lote_bank_account_id.ids[0] \
+ if lote_bank_account_id else False
favorecido_partner = self.env['res.partner.bank'].search(
[('owner_name', 'ilike', evento.favorecido_nome)]
)
@@ -160,7 +184,7 @@ def processar_arquivo_retorno(self):
'data_real_pagamento': data_evento,
'segmento': evento.servico_segmento,
'favorecido_nome': favorecido_partner,
- 'favorecido_conta_bancaria': account_bank_id_lote,
+ 'favorecido_conta_bancaria': lote_bank_account_id,
'nosso_numero': str(evento.credito_nosso_numero),
'seu_numero': evento.credito_seu_numero,
'tipo_moeda': evento.credito_moeda_tipo,
From c34bade482b60a3b2a5e43772c705bff847caf88 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 31 May 2019 18:53:08 -0300
Subject: [PATCH 068/612] [REF] Abstracy Factory cnab
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab.py | 5 ++++-
.../febraban/cnab_400/bancos/itau.py | 4 ++--
.../febraban/cnab_400/cnab_400.py | 2 +-
.../models/account_payment_order.py | 19 +++++++++----------
4 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
index add68c646751..bc920074f29c 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -37,7 +37,7 @@ def get_cnab(bank, cnab_type='240'):
return False
@staticmethod
- def remessa(order):
+ def gerar_remessa(order):
cnab = Cnab.get_cnab(
order.company_partner_bank_id.bank_id.code_bc,
order.payment_mode_id.payment_method_id.code
@@ -72,3 +72,6 @@ def retorno(self, arquivo_retorno):
self.classe_retorno,
arquivo=arquivo_retorno
)
+
+ def remessa(self, order):
+ pass
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 42fcbc32b6ad..622ac7d2be39 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -22,12 +22,12 @@ def __init__(self):
def remessa(self, order):
from cnab240.bancos import itau_cobranca_400
self.classe_remessa = itau_cobranca_400
- return super(Cnab400, self).remessa(order)
+ return super(Itau400, self).remessa(order)
def retorno(self, arquivo_retorno):
from cnab240.bancos import itau_cobranca_retorno_400
self.classe_retorno = itau_cobranca_retorno_400
- return super(Cnab400, self).retorno(arquivo_retorno)
+ return super(Itau400, self).retorno(arquivo_retorno)
@property
def inscricao_tipo(self):
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index e9aa74b9be66..5525bffcca58 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -290,7 +290,7 @@ def remessa(self, order):
:return:
"""
self.order = order
- self.arquivo = ArquivoCobranca400(self.remessa, **self._prepare_header())
+ self.arquivo = ArquivoCobranca400(self.classe_remessa, **self._prepare_header())
for line in order.bank_line_ids:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
self.arquivo.trailer.num_seq_registro = self.controle_linha
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 37114ad1272d..ffcd9383bb7b 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -88,19 +88,18 @@ def open2generated(self):
payment_line.move_line_id.state_cnab = 'exported'
return action
+ def _generate_payment_file(self):
+ try:
+ return Cnab.gerar_remessa(order=self), self.name + '.REM'
+ except Cnab240Error as e:
+ from odoo import exceptions
+ raise exceptions.ValidationError(
+ "Campo preenchido incorretamente \n\n{0}".format(e))
+
@api.multi
def generate_payment_file(self):
"""Returns (payment file as string, filename)"""
self.ensure_one()
if self.payment_method_id.code in ('240', '400', '500'):
- try:
- cnab = Cnab.get_cnab(
- self.company_partner_bank_id.bank_id.code_bc,
- self.payment_mode_id.payment_method_id.code
- )()
- return (cnab.remessa(self), self.name + '.REM')
- except Cnab240Error as e:
- from odoo import exceptions
- raise exceptions.ValidationError(
- "Campo preenchido incorretamente \n\n{0}".format(e))
+ return self._generate_payment_file()
return super(PaymentOrder, self).generate_payment_file()
From 946ae25b74e4edccd4df06ecf9475f7ce0749e16 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 31 May 2019 18:53:34 -0300
Subject: [PATCH 069/612] [FIX] State cnab write
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_cobranca/models/account_move_line.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index ace886169b14..388943c89bdc 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -69,7 +69,7 @@ def create_payment_line_from_move_line(self, payment_order):
:param payment_order:
:return:
"""
- self.state_cnab = 'added'
+ self.write({'state_cnab': 'added'})
return super(AccounMoveLine, self).create_payment_line_from_move_line(
payment_order
)
From bb1de77318d110b3f2a6a49a043cb4614c358207 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 31 May 2019 19:18:56 -0300
Subject: [PATCH 070/612] [REM] Arquivos indevidos ".orig"
Signed-off-by: Luis Felipe Mileo
---
.../__init__.py.orig | 30 --------
.../__openerp__.py.orig | 69 -------------------
2 files changed, 99 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/__init__.py.orig
delete mode 100644 l10n_br_account_payment_cobranca/__openerp__.py.orig
diff --git a/l10n_br_account_payment_cobranca/__init__.py.orig b/l10n_br_account_payment_cobranca/__init__.py.orig
deleted file mode 100644
index 2ed5d635172a..000000000000
--- a/l10n_br_account_payment_cobranca/__init__.py.orig
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- encoding: utf-8 -*-
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from . import wizard
-from . import model
-<<<<<<< HEAD
-
-=======
-import constantes
->>>>>>> [WIP] Criação dos campos faltantes
diff --git a/l10n_br_account_payment_cobranca/__openerp__.py.orig b/l10n_br_account_payment_cobranca/__openerp__.py.orig
deleted file mode 100644
index 8c289f80394c..000000000000
--- a/l10n_br_account_payment_cobranca/__openerp__.py.orig
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- coding: utf-8 -*-
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-{
- 'name': 'Account Payment CNAB',
- 'version': '8.0.1.0.0',
- 'category': 'Banking addons',
- 'license': 'AGPL-3',
- 'author': 'KMEE, Odoo Community Association (OCA)',
- 'website': 'http://www.kmee.com.br',
- 'external_dependencies': {
- 'python': ['cnab240',
- 'pyboleto'],
- },
- 'depends': [
- 'l10n_br_account_payment_boleto',
- 'l10n_br_account_payment_mode',
- 'l10n_br_account_product',
- ],
- 'data': [
- 'security/cnab_cobranca_security.xml',
- 'view/l10n_br_payment_cnab.xml',
- 'view/payment_order.xml',
- 'view/l10n_br_cnab_sequence.xml',
- 'view/l10n_br_cobranca_cnab.xml',
- 'view/l10n_br_cobranca_cnab_lines.xml',
- 'view/account_move_line.xml',
- 'view/res_partner_bank.xml',
- 'view/l10n_br_cnab_retorno_view.xml',
- 'view/payment_mode.xml',
- 'view/payment_line.xml',
- 'view/bank_payment_line.xml',
- 'data/l10n_br_payment_export_type.xml',
-<<<<<<< HEAD
- 'data/l10n_br_payment_mode.xml',
-=======
- 'security/ir.model.access.csv',
->>>>>>> [ADD] Regras de segurança para novos modelos
- ],
- 'demo': [
- # 'demo/l10n_br_payment_mode.xml',
- ],
- 'test': [
- 'tests/invoice_create.yml'
- ],
- "installable": True,
- "auto_install": False,
-}
From a21294730dea82ce662cfa956d31798ec58c53ef Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 31 May 2019 19:25:06 -0300
Subject: [PATCH 071/612] =?UTF-8?q?[REF]=20Removendo=20c=C3=B3digo=20obsol?=
=?UTF-8?q?eto=20e=20movendo=20boleto=20para=20pasta=20febraban?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../{ => febraban}/boleto/__init__.py | 0
.../{ => febraban}/boleto/document.py | 0
.../models/account_invoice.py | 21 ----
.../models/account_move_line.py | 49 +-------
.../models/account_payment_mode.py | 4 +-
.../reports/report.py | 2 +-
.../wizard/payment_order_create.py | 111 ------------------
7 files changed, 5 insertions(+), 182 deletions(-)
rename l10n_br_account_payment_cobranca/{ => febraban}/boleto/__init__.py (100%)
rename l10n_br_account_payment_cobranca/{ => febraban}/boleto/document.py (100%)
diff --git a/l10n_br_account_payment_cobranca/boleto/__init__.py b/l10n_br_account_payment_cobranca/febraban/boleto/__init__.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/boleto/__init__.py
rename to l10n_br_account_payment_cobranca/febraban/boleto/__init__.py
diff --git a/l10n_br_account_payment_cobranca/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/boleto/document.py
rename to l10n_br_account_payment_cobranca/febraban/boleto/document.py
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index b8ecf29d6ff9..6bcee4c76081 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -71,24 +71,3 @@ def invoice_validate(self):
result = super(AccountInvoice, self).invoice_validate()
self.create_account_payment_line()
return result
-
- # @api.multi
- # def finalize_invoice_move_lines(self, move_lines):
- # """ Propagate the transaction_id from the invoice to the move lines.
- #
- # The transaction id is written on the move lines only if the account is
- # the same than the invoice's one.
- # """
- # move_lines = super(AccountInvoice, self).finalize_invoice_move_lines(
- # move_lines)
- # for invoice in self:
- # if invoice.transaction_id:
- # invoice_account_id = invoice.account_id.id
- # index = 1
- # for line in move_lines:
- # # line is a tuple (0, 0, {values})
- # if invoice_account_id == line[2]['account_id']:
- # line[2]['transaction_ref'] = u'{0}/{1:02d}'.format(
- # invoice.transaction_id, index)
- # index += 1
- # return move_lines
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 388943c89bdc..5ee01b1dcfa1 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -4,12 +4,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from datetime import date
-
from odoo import models, fields, api, _
-from ..boleto.document import Boleto
-from ..boleto.document import BoletoException
+from ..febraban.boleto.document import Boleto
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -29,16 +26,6 @@ class AccounMoveLine(models.Model):
state_cnab = fields.Selection(
ESTADOS_CNAB, u'Estados CNAB', default='draft')
-
- # is_cnab_rejected = fields.Boolean(
- # u'Pode ser exportada novamente', default=False,
- # help='Marque esse campo para indicar um título que pode ser '
- # 'exportado novamente pelo CNAB')
- # cnab_rejected_code = fields.Char(u'Rejeição')
- # transaction_ref = fields.char('Transaction Ref.',
- # select=True,
- # store=True,
- # related='name')
date_payment_created = fields.Date(
u'Data da criação do pagamento', readonly=True)
nosso_numero = fields.Char(
@@ -74,7 +61,6 @@ def create_payment_line_from_move_line(self, payment_order):
payment_order
)
-
@api.multi
def generate_boleto(self):
boleto_list = []
@@ -93,39 +79,8 @@ def generate_boleto(self):
u' referente a essa nota para garantir que o '
u'boleto está registrado no banco'
))
- # try:
-
- # if move_line.payment_mode_id.type_payment == '00':
- # number_type = move_line.company_id.own_number_type
- # if not move_line.boleto_own_number:
- # if number_type == '0':
- # nosso_numero = self.env['ir.sequence'].next_by_id(
- # move_line.company_id.own_number_sequence.id)
- # elif number_type == '1':
- # nosso_numero = \
- # move_line.transaction_ref.replace('/', '')
- # else:
- # nosso_numero = self.env['ir.sequence'].next_by_id(
- # move_line.payment_mode_id.
- # internal_sequence_id.id
- # )
- # else:
- # nosso_numero = move_line.boleto_own_number
-
boleto = Boleto.getBoleto(
- move_line, move_line.transaction_ref.replace('/','')
+ move_line, move_line.nosso_numero
)
- # if boleto:
- # move_line.date_payment_created = date.today()
- # move_line.transaction_ref = \
- # boleto.boleto.format_nosso_numero()
- # move_line.boleto_own_number = nosso_numero
-
boleto_list.append(boleto.boleto)
- # except BoletoException as be:
- # _logger.error(be.message or be.value, exc_info=True)
- # continue
- # except Exception as e:
- # _logger.error(e.message or e.value, exc_info=True)
- # continue
return boleto_list
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index eb34c45dd112..84e15268420c 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -9,7 +9,7 @@
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, AVISO_FAVORECIDO
-from ..boleto.document import getBoletoSelection
+from ..febraban.boleto.document import getBoletoSelection
selection = getBoletoSelection()
@@ -96,7 +96,7 @@ class PaymentMode(models.Model):
# ('3', u'Não protestar'),
# ('7', u'Negativar (Dias Corridos)'),
# ('8', u'Não Negativar')
- # ]
+ # ]
string=u'Códigos de Protesto', default='0')
boleto_protesto_prazo = fields.Char(u'Prazo protesto', size=2)
gera_nosso_numero = fields.Boolean(
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index 7d32c7b6ca3f..8eab85c1a511 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -10,7 +10,7 @@
from odoo.report.interface import report_int
from odoo.report.render import render
-from ..boleto.document import Boleto
+from ..febraban.boleto.document import Boleto
class ExternalPdf(render):
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index de0723af4266..a324fa19f97a 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -12,117 +12,6 @@
class PaymentOrderCreate(models.TransientModel):
_inherit = 'account.payment.line.create'
- # @api.multi
- # def extend_payment_order_domain(self, payment_order, domain):
- # super(PaymentOrderCreate, self).extend_payment_order_domain(
- # payment_order, domain)
- #
- # if payment_order.mode.type.code == '240':
- # if payment_order.mode.payment_order_type == 'cobranca':
- # domain += [
- # ('debit', '>', 0)
- # ]
- #
- # # TODO: Refactor this
- # if ('invoice.payment_mode_id', '=', False) in domain:
- # domain.remove(('invoice.payment_mode_id', '=', False))
- # if ('date_maturity', '<=', self.duedate) in domain:
- # domain.remove(('date_maturity', '<=', self.duedate))
- # if ('date_maturity', '=', False) in domain:
- # domain.remove(('date_maturity', '=', False))
- # if ('date_maturity', '<=', self.duedate) in domain:
- # domain.remove(('date_maturity', '<=', self.duedate))
- #
- # elif payment_order.mode.type.code == '400':
- # if payment_order.mode.payment_order_type == 'cobranca':
- # domain += [
- # ('debit', '>', 0),
- # ('account_id.type', '=', 'receivable'),
- # '&',
- # ('payment_mode_id', '=', payment_order.mode.id),
- # '&',
- # ('invoice.state', '=', 'open'),
- # ('invoice.fiscal_category_id.'
- # 'property_journal.revenue_expense', '=', True)
- # ]
- # # TODO: Refactory this
- # # TODO: domain do state da move_line.
- # # index = domain.index(('invoice.payment_mode_id', '=', False))
- # # del domain[index - 1]
- # # domain.removemove(('invoice.payment_mode_id', '=', False))
- # # index = domain.index(('date_maturity', '<=', self.duedate))
- # # del domain[index - 1]
- # # domain.remove(('date_maturity', '=', False))
- # # domain.remove(('date_maturity', '<=', self.duedate))
- #
- # elif payment_order.mode.type.code == '500':
- # if payment_order.mode.payment_order_type == 'payment':
- # domain += [
- # '&', ('credit', '>', 0),
- # ('account_id.type', '=', 'payable')
- # ]
- # # index = domain.index(('invoice.payment_mode_id', '=', False))
- # # del domain[index - 1]
- # # domain.remove(('invoice.payment_mode_id', '=', False))
- # # index = domain.index(('date_maturity', '<=', self.duedate))
- # # del domain[index - 1]
- # # domain.remove(('date_maturity', '=', False))
- # # domain.remove(('date_maturity', '<=', self.duedate))
- #
- # index = domain.index(('account_id.type', '=', 'receivable'))
- # del domain[index - 1]
- # domain.remove(('account_id.type', '=', 'receivable'))
- #
- # return True
- #
- # @api.multi
- # def _prepare_payment_line(self, payment, line):
- # res = super(PaymentOrderCreate, self)._prepare_payment_line(
- # payment, line)
- #
- # # res['communication2'] = line.payment_mode_id.comunicacao_2
- # res['percent_interest'] = line.payment_mode_id.cnab_percent_interest
- #
- # if payment.mode.type.code == '400':
- # # write bool to move_line to avoid it being added on cnab again
- # self.write_cnab_rejected_bool(line)
- #
- # return res
- #
- # @api.multi
- # def filter_lines(self, lines):
- # """ Filter move lines before proposing them for inclusion
- # in the payment order.
- #
- # This implementation filters out move lines that are already
- # included in draft or open payment orders. This prevents the
- # user to include the same line in two different open payment
- # orders. When the payment order is sent, it is assumed that
- # the move will be reconciled soon (or immediately with
- # account_banking_payment_transfer), so it will not be
- # proposed anymore for payment.
- #
- # See also https://github.com/OCA/bank-payment/issues/93.
- #
- # :param lines: recordset of move lines
- # :returns: list of move line ids
- # """
- #
- # self.ensure_one()
- # payment_lines = self.env['payment.line']. \
- # search([('order_id.state', 'in', ('draft', 'open', 'done')),
- # ('move_line_id', 'in', lines.ids)])
- # # Se foi exportada e o cnab_rejeitado dela for true, pode adicionar
- # # de novo
- # to_exclude = set([l.move_line_id.id for l in payment_lines
- # if not l.move_line_id.is_cnab_rejected])
- # return [l.id for l in lines if l.id not in to_exclude]
- #
- # @api.multi
- # def write_cnab_rejected_bool(self, line):
- # line.write({'is_cnab_rejected': False})
- #
-
@api.multi
def _prepare_move_line_domain(self):
""" Nenhuma linha deve ser adicionada novamente a nao ser que o
From 5c65e059fff0011b926fe212792169772b020dd3 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 00:54:18 -0300
Subject: [PATCH 072/612] [IMP] Retorno CNAB
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab.py | 2 +-
.../models/l10n_br_cnab.py | 269 +++++++++++++-----
2 files changed, 195 insertions(+), 76 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
index bc920074f29c..35354003c1cb 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -65,7 +65,7 @@ def detectar_retorno(cnab_file_object):
banco = header[:3]
cnab = Cnab.get_cnab(banco, cnab_type)()
- return cnab.retorno(arquivo_retorno)
+ return cnab_type, cnab.retorno(arquivo_retorno)
def retorno(self, arquivo_retorno):
return ArquivoCobranca400(
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 3cd5f5625e79..b478e7cda92e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -71,12 +71,95 @@
9: 'Outros',
}
+CODIGO_OCORRENCIAS_CNAB200 = {
+ 2: 'ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)',
+ 3: 'ENTRADA REJEITADA (NOTA 20 – TABELA 1)',
+ 4: 'ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA',
+ 5: 'ALTERAÇÃO DE DADOS – BAIXA',
+ 6: 'LIQUIDAÇÃO NORMAL',
+ 7: 'LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)',
+ 8: 'LIQUIDAÇÃO EM CARTÓRIO',
+ 9: 'BAIXA SIMPLES',
+ 10: 'BAIXA POR TER SIDO LIQUIDADO',
+ 11: 'EM SER (SÓ NO RETORNO MENSAL)',
+ 12: 'ABATIMENTO CONCEDIDO',
+ 13: 'ABATIMENTO CANCELADO',
+ 14: 'VENCIMENTO ALTERADO',
+ 15: 'BAIXAS REJEITADAS (NOTA 20 – TABELA 4)',
+ 16: 'INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)',
+ 17: 'ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)',
+ 18: 'COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)',
+ 19: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO',
+ 20: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA',
+ 21: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR',
+ 23: 'TÍTULO ENVIADO A CARTÓRIO/TARIFA',
+ 24: 'INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)',
+ 25: 'ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)',
+ 26: 'TARIFA DE AVISO DE COBRANÇA',
+ 27: 'TARIFA DE EXTRATO POSIÇÃO (B40X)',
+ 28: 'TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES',
+ 29: 'TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS',
+ 30: 'DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)',
+ 32: 'BAIXA POR TER SIDO PROTESTADO',
+ 33: 'CUSTAS DE PROTESTO',
+ 34: 'CUSTAS DE SUSTAÇÃO',
+ 35: 'CUSTAS DE CARTÓRIO DISTRIBUIDOR',
+ 36: 'CUSTAS DE EDITAL',
+ 37: 'TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA',
+ 38: 'TARIFA DE INSTRUÇÃO',
+ 39: 'TARIFA DE OCORRÊNCIAS',
+ 40: 'TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA',
+ 41: 'DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)',
+ 42: 'DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES',
+ 43: 'DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS',
+ 44: 'DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS',
+ 45: 'DÉBITO MENSAL DE TARIFAS – PROTESTO',
+ 46: 'DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO',
+ 47: 'BAIXA COM TRANSFERÊNCIA PARA DESCONTO',
+ 48: 'CUSTAS DE SUSTAÇÃO JUDICIAL',
+ 51: 'TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA',
+ 52: 'TARIFA MENSAL BAIXAS NA CARTEIRA',
+ 53: 'TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA',
+ 54: 'TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA',
+ 55: 'TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA',
+ 56: 'CUSTAS DE IRREGULARIDADE',
+ 57: 'INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)',
+ 59: 'BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG',
+ 60: 'ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)',
+ 61: 'TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)',
+ 62: 'DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)',
+ 63: 'TÍTULO SUSTADO JUDICIALMENTE',
+ 64: 'ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO',
+ 65: 'PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO',
+ 69: 'CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)',
+ 71: 'ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO',
+ 72: 'BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE',
+ 73: 'CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL',
+ 74: 'INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)',
+ 75: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA',
+ 76: 'CHEQUE COMPENSADO',
+ 77: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA',
+ 78: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA',
+ 79: 'NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)',
+ 80: 'CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA',
+ 82: 'CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA',
+ 83: 'CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA',
+ 85: 'TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA',
+ 86: 'TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA',
+ 87: 'TARIFA SMS COBRANÇA ATIVA ELETRÔNICA',
+ 88: 'TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA',
+ 89: 'TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA',
+ 90: 'TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA',
+ 91: 'TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA',
+ 92: 'TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA',
+ 93: 'TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO',
+}
+
class L10nBrHrCnab(models.Model):
_name = "l10n.br.cnab"
_rec_name = "display_name"
-
def _busca_conta(self, banco, agencia, conta):
return self.env['res.partner.bank'].search([
# ('acc_number', '=', str(banco)),
@@ -108,7 +191,7 @@ def _cria_lote(self, header, lote, evento, trailer):
'servico_operacao': header.literal_retorno,
'tipo_servico': header.literal_servico,
'qtd_registros': trailer.totais_quantidade_registros,
- 'total_valores': float(trailer.valor_total_titulos/100),
+ 'total_valores': float(trailer.valor_total_titulos / 100),
'cnab_id': self.id,
}
@@ -116,10 +199,112 @@ def _cria_lote(self, header, lote, evento, trailer):
return lote_id, lote_bank_account_id
+ def _lote_400(self, evento, lote_id):
+
+ bank_payment_line_id = self.env['bank.payment.line'].search([
+ ('name', '=', evento.nosso_numero)
+ ])
+
+ vals_evento = {
+ 'data_ocorrencia': evento.data_ocorrencia,
+ # 'segmento': evento.servico_segmento,
+ # 'favorecido_nome': evento.nome_pagador,
+ # 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'nosso_numero': str(evento.nosso_numero),
+ 'seu_numero': evento.numero_documento,
+ # 'tipo_moeda': evento.credito_moeda_tipo,
+ 'valor_pagamento': evento.valor_principal,
+ 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'str_motiv_a': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ # 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
+ # ocorrencias[0] else '',
+ # 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
+ # ocorrencias[1] else '',
+ # 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
+ # ocorrencias[2] else '',
+ # 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
+ # ocorrencias[3] else '',
+ # 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
+ # ocorrencias[4] else '',
+ 'bank_payment_line_id': bank_payment_line_id.id,
+ 'lote_id': lote_id.id,
+ }
+ self.env['l10n.br.cnab.evento'].create(vals_evento)
+
+ def _lote_240(self, evento, lote_id):
+ data_evento = str(
+ evento.credito_data_real)
+ data_evento = fields.Date.from_string(
+ data_evento[4:] + "-" + data_evento[2:4] + "-" +
+ data_evento[0:2]
+ )
+ lote_bank_account_id = self.env['res.partner.bank'].search(
+ [
+ ('bra_number', '=', evento.favorecido_agencia),
+ ('bra_number_dig', '=', evento.favorecido_agencia_dv),
+ ('acc_number', '=', evento.favorecido_conta),
+ ('acc_number_dig', '=', evento.favorecido_conta_dv)
+ ])
+ lote_bank_account_id = lote_bank_account_id.ids[0] \
+ if lote_bank_account_id else False
+ favorecido_partner = self.env['res.partner.bank'].search(
+ [('owner_name', 'ilike', evento.favorecido_nome)]
+ )
+ favorecido_partner = favorecido_partner[0].partner_id.id \
+ if favorecido_partner else False
+ bank_payment_line_id = self.env['bank.payment.line'].search(
+ [
+ ('name', '=', evento.credito_seu_numero)
+ ]
+ )
+ ocorrencias_dic = dict(CODIGO_OCORRENCIAS)
+ ocorrencias = [
+ evento.ocorrencias[0:2],
+ evento.ocorrencias[2:4],
+ evento.ocorrencias[4:6],
+ evento.ocorrencias[6:8],
+ evento.ocorrencias[8:10]
+ ]
+ vals_evento = {
+ 'data_real_pagamento': data_evento,
+ 'segmento': evento.servico_segmento,
+ 'favorecido_nome': favorecido_partner,
+ 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'nosso_numero': str(evento.credito_nosso_numero),
+ 'seu_numero': evento.credito_seu_numero,
+ 'tipo_moeda': evento.credito_moeda_tipo,
+ 'valor_pagamento': evento.credito_valor_pagamento,
+ 'ocorrencias': evento.ocorrencias,
+ 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
+ ocorrencias[0] else '',
+ 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
+ ocorrencias[1] else '',
+ 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
+ ocorrencias[2] else '',
+ 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
+ ocorrencias[3] else '',
+ 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
+ ocorrencias[4] else '',
+ 'lote_id': lote_id.id,
+ 'bank_payment_line_id': bank_payment_line_id.id,
+ }
+ self.env['l10n.br.cnab.evento'].create(vals_evento)
+ if evento.ocorrencias and bank_payment_line_id:
+ if '00' in ocorrencias:
+ bank_state = 'paid'
+ cnab_state = 'accepted'
+
+ else:
+ bank_state = 'exception'
+ cnab_state = 'not_accepted'
+
+ bank_payment_line_id.state2 = bank_state
+ for payment_line in bank_payment_line_id.payment_line_ids:
+ payment_line.move_line_id.state_cnab = cnab_state
@api.multi
def processar_arquivo_retorno(self):
- arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
+ cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
# if not arquivo_parser.header.arquivo_codigo == u'2':
# raise exceptions.Warning(
# u"Este não é um arquivo de retorno!"
@@ -137,8 +322,8 @@ def processar_arquivo_retorno(self):
self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
for lote in arquivo_parser.lotes:
- header = lote.header or arquivo_parser.header
- trailer = lote.trailer or arquivo_parser.trailer
+ header = lote.header or arquivo_parser.header
+ trailer = lote.trailer or arquivo_parser.trailer
lote_id = False
@@ -147,76 +332,10 @@ def processar_arquivo_retorno(self):
lote_id, lote_bank_account_id = self._cria_lote(
header, lote, evento, trailer)
- data_evento = str(
- evento.credito_data_real)
- data_evento = fields.Date.from_string(
- data_evento[4:] + "-" + data_evento[2:4] + "-" +
- data_evento[0:2]
- )
- lote_bank_account_id = self.env['res.partner.bank'].search(
- [
- ('bra_number', '=', evento.favorecido_agencia),
- ('bra_number_dig', '=', evento.favorecido_agencia_dv),
- ('acc_number', '=', evento.favorecido_conta),
- ('acc_number_dig', '=', evento.favorecido_conta_dv)
- ])
- lote_bank_account_id = lote_bank_account_id.ids[0] \
- if lote_bank_account_id else False
- favorecido_partner = self.env['res.partner.bank'].search(
- [('owner_name', 'ilike', evento.favorecido_nome)]
- )
- favorecido_partner = favorecido_partner[0].partner_id.id \
- if favorecido_partner else False
- bank_payment_line_id = self.env['bank.payment.line'].search(
- [
- ('name', '=', evento.credito_seu_numero)
- ]
- )
- ocorrencias_dic = dict(CODIGO_OCORRENCIAS)
- ocorrencias = [
- evento.ocorrencias[0:2],
- evento.ocorrencias[2:4],
- evento.ocorrencias[4:6],
- evento.ocorrencias[6:8],
- evento.ocorrencias[8:10]
- ]
- vals_evento = {
- 'data_real_pagamento': data_evento,
- 'segmento': evento.servico_segmento,
- 'favorecido_nome': favorecido_partner,
- 'favorecido_conta_bancaria': lote_bank_account_id,
- 'nosso_numero': str(evento.credito_nosso_numero),
- 'seu_numero': evento.credito_seu_numero,
- 'tipo_moeda': evento.credito_moeda_tipo,
- 'valor_pagamento': evento.credito_valor_pagamento,
- 'ocorrencias': evento.ocorrencias,
- 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
- ocorrencias[0] else '',
- 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
- ocorrencias[1] else '',
- 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
- ocorrencias[2] else '',
- 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
- ocorrencias[3] else '',
- 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
- ocorrencias[4] else '',
- 'lote_id': lote_id.id,
- 'bank_payment_line_id': bank_payment_line_id.id,
- }
- self.env['l10n.br.cnab.evento'].create(vals_evento)
- if evento.ocorrencias and bank_payment_line_id:
- if '00' in ocorrencias:
- bank_state = 'paid'
- cnab_state = 'accepted'
-
- else:
- bank_state = 'exception'
- cnab_state = 'not_accepted'
-
- bank_payment_line_id.state2 = bank_state
- for payment_line in bank_payment_line_id.payment_line_ids:
- payment_line.move_line_id.state_cnab = cnab_state
-
+ if cnab_type == '240':
+ self._lote_240(evento, lote_id)
+ else:
+ self._lote_400(evento, lote_id)
return self.write({'state': 'done'})
@api.multi
From 24c6a13c76029cd2b5753d8821e81c27026968ef Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 01:21:12 -0300
Subject: [PATCH 073/612] =?UTF-8?q?[REF]=20Organiza=C3=A7=C3=A3o=20do=20c?=
=?UTF-8?q?=C3=B3digo=20de=20retorno?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../models/__init__.py | 5 +-
.../models/bank_payment_line.py | 2 +-
.../models/l10n_br_cnab.py | 154 +++++-------------
.../models/l10n_br_cnab_evento.py | 73 +++++++++
.../models/l10n_br_cnab_lote.py | 55 +++++++
.../views/l10n_br_cnab_retorno_view.xml | 14 +-
6 files changed, 182 insertions(+), 121 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
create mode 100644 l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index a8e684b1bae8..b6ccb60fb73a 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -8,9 +8,10 @@
from . import account_payment_order
from . import bank_payment_line
from . import l10n_br_cnab
+from . import l10n_br_cnab_evento
+from . import l10n_br_cnab_lote
from . import res_company
from . import res_partner_bank
from . import res_partner
from .. import constantes
-# from . import l10n_br_cnab_file_sufix_sequence
-# from . import l10n_br_cnab_sequence
+
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 9741c4102f07..e0e5f2a22b39 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -80,7 +80,7 @@ def default_get(self, fields_list):
)
evento_id = fields.One2many(
string="Eventos CNAB",
- comodel_name="l10n.br.cnab.evento",
+ comodel_name="l10n_br.cnab.evento",
inverse_name="bank_payment_line_id",
readonly=True
)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index b478e7cda92e..8dabc8f8210f 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -157,9 +157,44 @@
class L10nBrHrCnab(models.Model):
- _name = "l10n.br.cnab"
+ _name = "l10n_br.cnab"
_rec_name = "display_name"
+ arquivo_retorno = fields.Binary(
+ string='Arquivo Retorno'
+ )
+ bank_account_id = fields.Many2one(
+ string="Conta cedente",
+ comodel_name="res.partner.bank",
+ )
+ data = fields.Date(
+ string="Data CNAB",
+ required=True,
+ default=datetime.now()
+ )
+ data_arquivo = fields.Datetime(
+ string="Data Criação no Banco",
+ )
+ lote_id = fields.One2many(
+ string="Lotes",
+ comodel_name="l10n_br.cnab.lote",
+ inverse_name="cnab_id"
+ )
+ name = fields.Char(
+ string="Name",
+ )
+ num_eventos = fields.Integer(
+ string=u"Número de Eventos",
+ )
+ num_lotes = fields.Integer(
+ string=u"Número de Lotes",
+ )
+ state = fields.Selection(
+ string=u"Estágio",
+ selection=STATE,
+ default="draft",
+ )
+
def _busca_conta(self, banco, agencia, conta):
return self.env['res.partner.bank'].search([
# ('acc_number', '=', str(banco)),
@@ -195,7 +230,7 @@ def _cria_lote(self, header, lote, evento, trailer):
'cnab_id': self.id,
}
- lote_id = self.env['l10n.br.cnab.lote'].create(vals)
+ lote_id = self.env['l10n_br.cnab.lote'].create(vals)
return lote_id, lote_bank_account_id
@@ -206,15 +241,16 @@ def _lote_400(self, evento, lote_id):
])
vals_evento = {
+ 'bank_payment_line_id': bank_payment_line_id.id,
'data_ocorrencia': evento.data_ocorrencia,
# 'segmento': evento.servico_segmento,
# 'favorecido_nome': evento.nome_pagador,
# 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'lote_id': lote_id.id,
'nosso_numero': str(evento.nosso_numero),
+ 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
'seu_numero': evento.numero_documento,
# 'tipo_moeda': evento.credito_moeda_tipo,
- 'valor_pagamento': evento.valor_principal,
- 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
'str_motiv_a': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
@@ -226,10 +262,9 @@ def _lote_400(self, evento, lote_id):
# ocorrencias[3] else '',
# 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
# ocorrencias[4] else '',
- 'bank_payment_line_id': bank_payment_line_id.id,
- 'lote_id': lote_id.id,
+ 'valor_pagamento': evento.valor_principal,
}
- self.env['l10n.br.cnab.evento'].create(vals_evento)
+ self.env['l10n_br.cnab.evento'].create(vals_evento)
def _lote_240(self, evento, lote_id):
data_evento = str(
@@ -288,7 +323,7 @@ def _lote_240(self, evento, lote_id):
'lote_id': lote_id.id,
'bank_payment_line_id': bank_payment_line_id.id,
}
- self.env['l10n.br.cnab.evento'].create(vals_evento)
+ self.env['l10n_br.cnab.evento'].create(vals_evento)
if evento.ocorrencias and bank_payment_line_id:
if '00' in ocorrencias:
bank_state = 'paid'
@@ -350,106 +385,3 @@ def create(self, vals):
name = self._get_name(vals['data'])
vals.update({'name': name})
return super(L10nBrHrCnab, self).create(vals)
-
- arquivo_retorno = fields.Binary(string='Arquivo Retorno')
- data = fields.Date(
- string="Data CNAB",
- required=True,
- default=datetime.now()
- )
- name = fields.Char(
- string="Name",
- )
- lote_id = fields.One2many(
- string="Lotes",
- comodel_name="l10n.br.cnab.lote",
- inverse_name="cnab_id"
- )
- state = fields.Selection(
- string=u"Estágio",
- selection=STATE,
- default="draft",
- )
- data_arquivo = fields.Datetime(
- string="Data Criação no Banco",
- )
- bank_account_id = fields.Many2one(
- string="Conta cedente",
- comodel_name="res.partner.bank",
- )
- num_lotes = fields.Integer(
- string=u"Número de Lotes",
- )
- num_eventos = fields.Integer(
- string=u"Número de Eventos",
- )
-
-
-class L10nBrHrCnabLote(models.Model):
- _name = "l10n.br.cnab.lote"
-
- account_bank_id = fields.Many2one(
- string=u"Conta Bancária",
- comodel_name="res.partner.bank",
- )
- empresa_inscricao_numero = fields.Char(string=u"Número de Inscrição")
- empresa_inscricao_tipo = fields.Char(string=u"Tipo de Inscrição")
- servico_operacao = fields.Char(string=u"Tipo de Operação")
- tipo_servico = fields.Char(strin=u"Tipo do Serviço")
- mensagem = fields.Char(string="Mensagem")
- qtd_registros = fields.Integer(string="Quantidade de Registros")
- total_valores = fields.Float(string="Valor Total")
- evento_id = fields.One2many(
- string="Eventos",
- comodel_name="l10n.br.cnab.evento",
- inverse_name="lote_id",
- )
- cnab_id = fields.Many2one(
- string="CNAB",
- comodel_name="l10n.br.cnab"
- )
- state = fields.Selection(
- string="State",
- related="cnab_id.state",
- selection=STATE,
- default="draft",
- )
-
-
-class L10nBrHrCnabEvento(models.Model):
- _name = "l10n.br.cnab.evento"
-
- data_real_pagamento = fields.Datetime(string="Data Real do Pagamento")
- segmento = fields.Char(string="Segmento")
- favorecido_nome = fields.Many2one(
- string="Favorecido",
- comodel_name="res.partner"
- )
- favorecido_conta_bancaria = fields.Many2one(
- string=u"Conta Bancária",
- comodel_name="res.partner.bank",
- )
- nosso_numero = fields.Char(string=u"Nosso Número")
- seu_numero = fields.Char(string=u"Seu Número")
- tipo_moeda = fields.Char(string=u"Tipo de Moeda")
- valor_pagamento = fields.Float(string="Valor do Pagamento")
- ocorrencias = fields.Char(string=u"Ocorrências")
- str_motiv_a = fields.Char(u'Motivo da ocorrência 01')
- str_motiv_b = fields.Char(u'Motivo de ocorrência 02')
- str_motiv_c = fields.Char(u'Motivo de ocorrência 03')
- str_motiv_d = fields.Char(u'Motivo de ocorrência 04')
- str_motiv_e = fields.Char(u'Motivo de ocorrência 05')
- bank_payment_line_id = fields.Many2one(
- string="Bank Payment Line",
- comodel_name="bank.payment.line",
- )
- lote_id = fields.Many2one(
- string="Lote",
- comodel_name="l10n.br.cnab.lote",
- )
- state = fields.Selection(
- string="State",
- related="lote_id.state",
- selection=STATE,
- default="draft",
- )
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
new file mode 100644
index 000000000000..540c16ac534d
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# © 2012 KMEE INFORMATICA LTDA
+# @author Luiz Felipe do Divino Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+import logging
+from odoo import api, models, fields, exceptions
+from .l10n_br_cnab import STATE
+
+_logger = logging.getLogger(__name__)
+
+
+class L10nBrCnabEvento(models.Model):
+ _name = "l10n_br.cnab.evento"
+
+ bank_payment_line_id = fields.Many2one(
+ string="Bank Payment Line",
+ comodel_name="bank.payment.line",
+ )
+ data_real_pagamento = fields.Datetime(
+ string="Data Real do Pagamento"
+ )
+ favorecido_conta_bancaria = fields.Many2one(
+ string=u"Conta Bancária",
+ comodel_name="res.partner.bank",
+ )
+ favorecido_nome = fields.Many2one(
+ string="Favorecido",
+ comodel_name="res.partner"
+ )
+ lote_id = fields.Many2one(
+ string="Lote",
+ comodel_name="l10n_br.cnab.lote",
+ )
+ nosso_numero = fields.Char(
+ string=u"Nosso Número"
+ )
+ ocorrencias = fields.Char(
+ string=u"Ocorrências"
+ )
+ segmento = fields.Char(
+ string="Segmento"
+ )
+ seu_numero = fields.Char(
+ string=u"Seu Número"
+ )
+ state = fields.Selection(
+ string="State",
+ related="lote_id.state",
+ selection=STATE,
+ default="draft",
+ )
+ str_motiv_a = fields.Char(
+ u'Motivo da ocorrência 01'
+ )
+ str_motiv_b = fields.Char(
+ u'Motivo de ocorrência 02'
+ )
+ str_motiv_c = fields.Char(
+ u'Motivo de ocorrência 03'
+ )
+ str_motiv_d = fields.Char(
+ u'Motivo de ocorrência 04'
+ )
+ str_motiv_e = fields.Char(
+ u'Motivo de ocorrência 05'
+ )
+ tipo_moeda = fields.Char(
+ string=u"Tipo de Moeda"
+ )
+ valor_pagamento = fields.Float(
+ string="Valor do Pagamento"
+ )
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
new file mode 100644
index 000000000000..a9d63798d84b
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+# © 2012 KMEE INFORMATICA LTDA
+# @author Luiz Felipe do Divino Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+import logging
+from odoo import api, models, fields, exceptions
+from .l10n_br_cnab import STATE
+_logger = logging.getLogger(__name__)
+
+
+class L10nBrCnabLote(models.Model):
+
+ _name = "l10n_br.cnab.lote"
+
+ account_bank_id = fields.Many2one(
+ string=u"Conta Bancária",
+ comodel_name="res.partner.bank",
+ )
+ cnab_id = fields.Many2one(
+ string="CNAB",
+ comodel_name="l10n_br.cnab"
+ )
+ empresa_inscricao_numero = fields.Char(
+ string=u"Número de Inscrição"
+ )
+ empresa_inscricao_tipo = fields.Char(
+ string=u"Tipo de Inscrição"
+ )
+ evento_id = fields.One2many(
+ string="Eventos",
+ comodel_name="l10n_br.cnab.evento",
+ inverse_name="lote_id",
+ )
+ mensagem = fields.Char(
+ string="Mensagem"
+ )
+ qtd_registros = fields.Integer(
+ string="Quantidade de Registros"
+ )
+ servico_operacao = fields.Char(
+ string=u"Tipo de Operação"
+ )
+ state = fields.Selection(
+ string="State",
+ related="cnab_id.state",
+ selection=STATE,
+ default="draft",
+ )
+ tipo_servico = fields.Char(
+ string=u"Tipo do Serviço"
+ )
+ total_valores = fields.Float(
+ string="Valor Total"
+ )
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index b87d9cb88591..0f5f0da574ff 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -6,7 +6,7 @@
cnab.retorno.tree
- l10n.br.cnab
+ l10n_br.cnab
@@ -22,7 +22,7 @@
cnab.lote.tree
- l10n.br.cnab.lote
+ l10n_br.cnab.lote
@@ -41,7 +41,7 @@
cnab.evento.tree
- l10n.br.cnab.evento
+ l10n_br.cnab.evento
@@ -63,7 +63,7 @@
cnab.retorno.evento.form.view
- l10n.br.cnab.evento
+ l10n_br.cnab.evento
@@ -110,7 +110,7 @@
cnab.retorno.lote.form.view
- l10n.br.cnab.lote
+ l10n_br.cnab.lote
@@ -151,7 +151,7 @@
cnab.retorno.form.view
- l10n.br.cnab
+ l10n_br.cnab
@@ -204,7 +204,7 @@
Importar Retorno Bancário CNAB
ir.actions.act_window
- l10n.br.cnab
+ l10n_br.cnab
form
tree,form
From 62e5ff583f9c229b91e3cc3a2b1c1811fca9b6f1 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 01:23:03 -0300
Subject: [PATCH 074/612] [REF] oca-autopep8
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_240/cnab_240.py | 2 +-
.../febraban/cnab_400/cnab_400.py | 28 ++++++++++---------
.../febraban/pag_for/bancos/bradesco.py | 3 +-
.../febraban/pag_for/pag_for500.py | 2 +-
.../models/__init__.py | 1 -
.../models/account_invoice.py | 6 ++--
.../models/account_move_line.py | 2 +-
.../models/bank_payment_line.py | 1 -
8 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index 0da0e4bea1af..fb5153f54b33 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -289,7 +289,7 @@ def _prepare_cobranca(self, line):
self.rmchar(line.partner_id.cnpj_cpf)),
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
- line.partner_id.street + ' ' + line.partner_id.number),
+ line.partner_id.street + ' ' + line.partner_id.number),
'sacado_bairro': line.partner_id.district or '',
'sacado_cep': self.get_cep('prefixo', line.partner_id.zip),
'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 5525bffcca58..b0b1bd44a5c7 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -187,7 +187,8 @@ def _prepare_cobranca(self, line):
if (int(self.order.payment_mode_id.boleto_protesto_prazo)) < 5:
dias_protestar = 5
else:
- dias_protestar = int(self.order.payment_mode_id.boleto_protesto_prazo)
+ dias_protestar = int(
+ self.order.payment_mode_id.boleto_protesto_prazo)
sacado_endereco = self.retorna_endereco(line.partner_id.id)
@@ -239,7 +240,7 @@ def _prepare_cobranca(self, line):
'especie_titulo': int(self.order.payment_mode_id.boleto_especie),
'aceite_titulo': aceite,
'data_emissao_titulo': self.format_date(
- line.date), # FIXME
+ line.date), # FIXME
# TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
# CEF/FEBRABAN e Itaú não tem.
'juros_mora_data': self.format_date(
@@ -247,7 +248,7 @@ def _prepare_cobranca(self, line):
# 'juros_mora_taxa_dia': Decimal('0.20'),
'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
- line.amount_currency, 0), # line.percent_interest
+ line.amount_currency, 0), # line.percent_interest
'valor_abatimento': Decimal('0.00'),
'sacado_inscricao_tipo': int(
@@ -290,7 +291,8 @@ def remessa(self, order):
:return:
"""
self.order = order
- self.arquivo = ArquivoCobranca400(self.classe_remessa, **self._prepare_header())
+ self.arquivo = ArquivoCobranca400(
+ self.classe_remessa, **self._prepare_header())
for line in order.bank_line_ids:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
self.arquivo.trailer.num_seq_registro = self.controle_linha
@@ -348,15 +350,15 @@ def monta_endereco(self, partner_item):
distrito = self.check_address_item_filled(partner_item.district)
str_endereco = (
- street +
- ' ' +
- number +
- ' ' +
- complemento
- # + ' ' +
- # partner_item.l10n_br_city_id.name +
- # ' ' + partner_item.state_id.name
- )
+ street +
+ ' ' +
+ number +
+ ' ' +
+ complemento
+ # + ' ' +
+ # partner_item.l10n_br_city_id.name +
+ # ' ' + partner_item.state_id.name
+ )
return str_endereco
def check_address_item_filled(self, item):
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
index 70acbd926382..a428ecb96f5e 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
@@ -26,7 +26,8 @@ def _prepare_header(self):
:return:
"""
vals = super(BradescoPagFor, self)._prepare_header()
- vals['codigo_comunicacao'] = int(self.order.payment_mode_id.boleto_convenio)
+ vals['codigo_comunicacao'] = int(
+ self.order.payment_mode_id.boleto_convenio)
return vals
def _prepare_cobranca(self, line, vals):
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index 3517406220cb..0fc989eaff81 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -260,7 +260,7 @@ def _prepare_cobranca(self, line, vals):
self.rmchar(line.partner_id.cnpj_cpf)[12:14]),
'nome_forn': line.partner_id.legal_name,
'endereco_forn': (
- line.partner_id.street + ' ' + line.partner_id.number),
+ line.partner_id.street + ' ' + line.partner_id.number),
'cep_forn': int(prefixo),
'cep_complemento_forn': int(sulfixo),
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index b6ccb60fb73a..671b81dd8565 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -14,4 +14,3 @@
from . import res_partner_bank
from . import res_partner
from .. import constantes
-
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 6bcee4c76081..ec58bb977277 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -36,9 +36,9 @@ def action_move_create(self):
# inv.transaction_id = sequence
for index, interval in enumerate(inv.move_line_receivable_id):
numero_documento = (
- inv.get_invoice_fiscal_number() +
- '/' +
- str(index + 1).zfill(2)
+ inv.get_invoice_fiscal_number() +
+ '/' +
+ str(index + 1).zfill(2)
)
# Verificar se é boleto para criar o numero
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 5ee01b1dcfa1..33e019cb87cb 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -17,7 +17,7 @@
('added', u'Adicionada à ordem de pagamento'), # ok
('exported', u'Exportada'), # ok
('accepted', u'Aceita'),
- ('not_accepted', u'Não aceita pelo banco'), # importar novamente
+ ('not_accepted', u'Não aceita pelo banco'), # importar novamente
]
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index e0e5f2a22b39..009ac952e4f8 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -111,7 +111,6 @@ def same_fields_payment_line_and_bank_payment_line(self):
BankPaymentLine, self
).same_fields_payment_line_and_bank_payment_line()
-
# TODO: Implementar campo brasileiros que permitem mesclar linhas
same_fields = [] # Por segurança não vamos mesclar nada
From 0bf4eb4aec9767b7e6b2e1a1d33b19d456494f48 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 11:43:35 -0300
Subject: [PATCH 075/612] =?UTF-8?q?[REF]=20Corre=C3=A7=C3=B5es=20diversas?=
=?UTF-8?q?=20de=20sintaxe?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../febraban/boleto/document.py | 100 ++++++++++++------
.../febraban/cnab.py | 6 +-
.../febraban/cnab_240/bancos/itau.py | 2 +-
.../febraban/cnab_240/cnab_240.py | 62 +++++++----
.../febraban/cnab_400/cnab_400.py | 38 ++++---
.../febraban/pag_for/pag_for500.py | 61 +++++++----
.../models/l10n_br_cnab.py | 31 +++---
.../models/l10n_br_cnab_evento.py | 6 +-
.../models/l10n_br_cnab_lote.py | 2 +-
.../views/l10n_br_cnab_retorno_view.xml | 5 +-
10 files changed, 206 insertions(+), 107 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
index ae4d55218811..dd78233d7734 100644
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
@@ -39,7 +39,9 @@ def getBoleto(move_line, nosso_numero):
@staticmethod
def getBoletoClass(move_line):
- bank_code = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bank_id.code_bc
+ bank_code = \
+ move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bank_id.code_bc
return bank.get_class_for_codigo(bank_code)
def __init__(self, move_line, nosso_numero):
@@ -95,7 +97,8 @@ def _cedente(self, company):
self.boleto.cedente_bairro = company.district
self.boleto.cedente_cep = company.zip
self.boleto.cedente_cidade = company.l10n_br_city_id.name
- self.boleto.cedente_logradouro = company.street + ', ' + company.number
+ self.boleto.cedente_logradouro = \
+ company.street + ', ' + company.number
self.boleto.cedente_uf = company.state_id.code
self.boleto.agencia_cedente = self.getBranchNumber()
self.boleto.conta_cedente = self.getAccountNumber()
@@ -106,7 +109,8 @@ def _sacado(self, partner):
:param partner:
:return:
"""
- self.boleto.sacado_endereco = partner.street + ', ' + partner.number
+ self.boleto.sacado_endereco = \
+ partner.street + ', ' + partner.number
self.boleto.sacado_cidade = partner.l10n_br_city_id.name
self.boleto.sacado_bairro = partner.district or ''
self.boleto.sacado_uf = partner.state_id.code
@@ -147,8 +151,12 @@ def __init__(self, move_line, nosso_numero):
# 1: Nosso Numero with 5 positions
# 2: Nosso Numero with 17 positions
self.boleto = Boleto.getBoletoClass(move_line)(7, 2)
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.acc_number
+ self.branch_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -157,8 +165,12 @@ class BoletoBarisul(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.acc_number
+ self.branch_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -167,11 +179,17 @@ class BoletoBradesco(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.acc_number
+ self.branch_number = \
+ move_line.payment_mode_id.fixed_journal_id. \
+ bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
- self.branch_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number_dig
+ self.account_digit = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number_dig
+ self.branch_digit = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -181,10 +199,13 @@ class BoletoCaixa(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
+ self.account_digit = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -194,8 +215,10 @@ class BoletoHsbc(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -204,8 +227,10 @@ class BoletoItau157(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -214,8 +239,10 @@ class BoletoItau(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -224,8 +251,10 @@ class BoletoReal(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -234,8 +263,10 @@ class BoletoSantander101(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.ios = '0'
self.boleto.nosso_numero = self.nosso_numero
@@ -245,8 +276,10 @@ class BoletoStatander101201(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.ios = '0'
self.boleto.nosso_numero = self.nosso_numero
@@ -257,10 +290,13 @@ class BoletoCaixaSigcb(Boleto):
def __init__(self, move_line, nosso_numero):
from pyboleto.bank.caixa_sigcb import BoletoCaixaSigcb
self.boleto = BoletoCaixaSigcb()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
# bank specific
- self.account_digit = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number_dig
+ self.account_digit = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number_dig
# end bank specific
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
@@ -270,8 +306,10 @@ class BoletoSicredi(Boleto):
def __init__(self, move_line, nosso_numero):
self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id.fixed_journal_id.bank_account_id.bra_number
+ self.account_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.acc_number
+ self.branch_number = move_line.payment_mode_id. \
+ fixed_journal_id.bank_account_id.bra_number
Boleto.__init__(self, move_line, nosso_numero)
self.boleto.nosso_numero = self.nosso_numero
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
index 35354003c1cb..c6907c3f7e1f 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -4,12 +4,16 @@
# @author Daniel Sadamo
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-# TODO: implement abc factory?
from __future__ import division, print_function, unicode_literals
+
+import logging
import base64
import codecs
+_logger = logging.getLogger(__name__)
+
+
try:
from cnab240.tipos import ArquivoCobranca400
except ImportError as err:
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
index 61d461f9065c..537fe22d9007 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
@@ -36,7 +36,7 @@ def _prepare_header(self):
# vals['cedente_dv_ag_cc'])
# vals['cedente_agencia_dv'] = int(
# vals['cedente_agencia_dv']),
- # return vals
+ return vals
def _prepare_cobranca(self, line):
"""
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index fb5153f54b33..05888f9abd17 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -98,16 +98,21 @@ def _prepare_header(self):
'cedente_agencia':
int(self.order.company_partner_bank_id.bra_number),
# 09.0
- 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
+ 'cedente_agencia_dv':
+ self.order.company_partner_bank_id.bra_number_dig,
# 10.0
'cedente_conta':
- int(punctuation_rm(self.order.company_partner_bank_id.acc_number)),
+ int(punctuation_rm(
+ self.order.company_partner_bank_id.acc_number)),
# 11.0
- 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig[0],
+ 'cedente_conta_dv':
+ self.order.company_partner_bank_id.acc_number_dig[0],
# 12.0
'cedente_agencia_conta_dv':
self.order.company_partner_bank_id.acc_number_dig[1]
- if len(self.order.company_partner_bank_id.acc_number_dig) > 1 else '',
+ if len(
+ self.order.company_partner_bank_id.acc_number_dig
+ ) > 1 else '',
# 13.0
'cedente_nome':
self.order.company_partner_bank_id.partner_id.legal_name[:30]
@@ -182,16 +187,21 @@ def _prepare_header_lote(self):
'cedente_agencia':
int(self.order.company_partner_bank_id.bra_number),
# 13.1
- 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
+ 'cedente_agencia_dv':
+ self.order.company_partner_bank_id.bra_number_dig,
# 14.1
'cedente_conta':
- int(punctuation_rm(self.order.company_partner_bank_id.acc_number)),
+ int(punctuation_rm(
+ self.order.company_partner_bank_id.acc_number)),
# 15.1
- 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig[0],
+ 'cedente_conta_dv':
+ self.order.company_partner_bank_id.acc_number_dig[0],
# 16.1
'cedente_agencia_conta_dv':
self.order.company_partner_bank_id.acc_number_dig[1]
- if len(self.order.company_partner_bank_id.acc_number_dig) > 1 else '',
+ if len(
+ self.order.company_partner_bank_id.acc_number_dig
+ ) > 1 else '',
# 17.1
'cedente_nome':
self.order.company_partner_bank_id.partner_id.legal_name[:30]
@@ -257,11 +267,16 @@ def _prepare_cobranca(self, line):
# Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
return {
- 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
- 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig,
- 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
+ 'controle_banco': int(
+ self.order.company_partner_bank_id.code_bc),
+ 'cedente_agencia': int(
+ self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(
+ self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv':
+ self.order.company_partner_bank_id.acc_number_dig,
+ 'cedente_agencia_dv':
+ self.order.company_partner_bank_id.bra_number_dig,
'identificacao_titulo': u'0000000', # TODO
'identificacao_titulo_banco': u'0000000', # TODO
'identificacao_titulo_empresa': line.move_line_id.move_id.name,
@@ -291,16 +306,21 @@ def _prepare_cobranca(self, line):
'sacado_endereco': (
line.partner_id.street + ' ' + line.partner_id.number),
'sacado_bairro': line.partner_id.district or '',
- 'sacado_cep': self.get_cep('prefixo', line.partner_id.zip),
- 'sacado_cep_sufixo': self.get_cep('sufixo', line.partner_id.zip),
+ 'sacado_cep':
+ self.get_cep('prefixo', line.partner_id.zip),
+ 'sacado_cep_sufixo':
+ self.get_cep('sufixo', line.partner_id.zip),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
- 'codigo_protesto': int(self.order.payment_mode_id.boleto_protesto),
- 'prazo_protesto': int(self.order.payment_mode_id.boleto_protesto_prazo),
+ 'codigo_protesto':
+ int(self.order.payment_mode_id.boleto_protesto),
+ 'prazo_protesto':
+ int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': int(self.order.payment_mode_id.boleto_carteira),
+ 'cobranca_carteira':
+ int(self.order.payment_mode_id.boleto_carteira),
}
def _prepare_pagamento(self, line):
@@ -316,7 +336,8 @@ def _prepare_pagamento(self, line):
# SEGMENTO A
# CONTROLE
# 01.3A
- 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
+ 'controle_banco':
+ int(self.order.company_partner_bank_id.code_bc),
# 02.3A
'controle_lote': 1,
# 03.3A - 3-Registros Iniciais do Lote
@@ -510,7 +531,8 @@ def remessa(self, order):
# Decimal('1.00'))
remessa = unicode(self.arquivo)
- return unicodedata.normalize('NFKD', remessa).encode('ascii', 'ignore')
+ return unicodedata.normalize(
+ 'NFKD', remessa).encode('ascii', 'ignore')
def get_cep(self, tipo, value):
'''
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index b0b1bd44a5c7..25c2fb9fa3cc 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -121,14 +121,20 @@ def _prepare_header(self):
self.order.company_id.cnpj_cpf)),
'cedente_agencia': int(
self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': (self.order.company_partner_bank_id.acc_number_dig),
- 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
- 'cedente_nome': self.order.company_id.legal_name,
+ 'cedente_conta':
+ int(self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv':
+ self.order.company_partner_bank_id.acc_number_dig,
+ 'cedente_agencia_dv':
+ self.order.company_partner_bank_id.bra_number_dig,
+ 'cedente_nome':
+ self.order.company_id.legal_name,
'arquivo_codigo': 1, # Remessa/Retorno
'servico_operacao': u'R',
- 'nome_banco': unicode(self.order.company_partner_bank_id.bank_name),
- 'codigo_empresa': int(self.order.payment_mode_id.boleto_convenio),
+ 'nome_banco':
+ unicode(self.order.company_partner_bank_id.bank_name),
+ 'codigo_empresa':
+ int(self.order.payment_mode_id.boleto_convenio),
}
def get_file_numeration(self):
@@ -216,17 +222,23 @@ def _prepare_cobranca(self, line):
'segunda_instrucao': dias_protestar,
'sacado_cep': int(prefixo),
'sacado_cep_sufixo': int(sulfixo),
- 'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
+ 'sacador_avalista':
+ self.order.payment_mode_id.comunicacao_2,
# 'sacador_avalista': u'Protestar após 5 dias',
- 'num_seq_registro': self.controle_linha,
+ 'num_seq_registro':
+ self.controle_linha,
'controle_banco': int(
self.order.company_partner_bank_id.bank_id.code_bc
),
- 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': self.order.company_partner_bank_id.acc_number_dig,
- 'cedente_agencia_dv': self.order.company_partner_bank_id.bra_number_dig,
+ 'cedente_agencia': int(
+ self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta': int(
+ self.order.company_partner_bank_id.acc_number),
+ 'cedente_conta_dv':
+ self.order.company_partner_bank_id.acc_number_dig,
+ 'cedente_agencia_dv':
+ self.order.company_partner_bank_id.bra_number_dig,
'identificacao_titulo': u'0000000', # TODO
'identificacao_titulo_banco': u'0000000', # TODO
'identificacao_titulo_empresa': line.name, # FIXME
@@ -347,7 +359,7 @@ def monta_endereco(self, partner_item):
street = self.check_address_item_filled(partner_item.street)
number = self.check_address_item_filled(partner_item.number)
complemento = self.check_address_item_filled(partner_item.street2)
- distrito = self.check_address_item_filled(partner_item.district)
+ # distrito = self.check_address_item_filled(partner_item.district)
str_endereco = (
street +
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index 0fc989eaff81..ac3c2451adb5 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -184,8 +184,10 @@ def _prepare_header(self):
self.order.company_id.cnpj_cpf)[9:12]),
'sufixo_cnpj': int(punctuation_rm(
self.order.company_id.cnpj_cpf)[12:14]),
- 'cedente_agencia': int(self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(self.order.company_partner_bank_id.acc_number),
+ 'cedente_agencia':
+ int(self.order.company_partner_bank_id.bra_number),
+ 'cedente_conta':
+ int(self.order.company_partner_bank_id.acc_number),
'cedente_agencia_conta_dv':
self.order.company_partner_bank_id.bra_number_dig,
'nome_empresa_pagadora': self.order.company_id.legal_name,
@@ -196,7 +198,8 @@ def _prepare_header(self):
'reservado_empresa': u'BRADESCO PAG FOR',
# Sequencial crescente e nunca pode ser repetido
'numero_lista_debito': int(self.get_file_numeration()),
- # TODO: Sequencial crescente de 1 a 1 no arquivo. O primeiro header
+ # TODO: Sequencial crescente de
+ # 1 a 1 no arquivo. O primeiro header
# será sempre 000001
'sequencial': 1
}
@@ -231,7 +234,8 @@ def sacado_inscricao_tipo(self, partner_id):
return 1
def rmchar(self, format):
- return re.sub('[%s]' % re.escape(string.punctuation), '', format or '')
+ return re.sub('[%s]' % re.escape(
+ string.punctuation), '', format or '')
def _prepare_cobranca(self, line, vals):
"""
@@ -247,7 +251,8 @@ def _prepare_cobranca(self, line, vals):
prefixo, sulfixo = self.cep(line.partner_id.zip)
segmento = {
- 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
+ 'conta_complementar':
+ int(self.order.company_partner_bank_id.acc_number),
# 'especie_titulo': 8,
'tipo_inscricao': int(
@@ -327,8 +332,10 @@ def _prepare_cobranca(self, line, vals):
# FIXME: lib nao reconhece campo
'sequencial_trailer': int(self.get_file_numeration()),
'sequencial_transacao': self.controle_linha,
- 'codigo_protesto': int(self.order.payment_mode_id.boleto_protesto),
- 'prazo_protesto': int(self.order.payment_mode_id.boleto_protesto_prazo),
+ 'codigo_protesto':
+ int(self.order.payment_mode_id.boleto_protesto),
+ 'prazo_protesto':
+ int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
@@ -351,7 +358,8 @@ def remessa(self, order):
cont_lote = 0
for line in order.line_ids:
- self.arquivo.incluir_pagamento(**self.incluir_pagamento_for(line))
+ self.arquivo.incluir_pagamento(
+ **self.incluir_pagamento_for(line))
pag_valor_titulos += line.amount_currency
self.arquivo.trailer.total_valor_arq = Decimal(
pag_valor_titulos).quantize(Decimal('1.00'))
@@ -427,33 +435,42 @@ def lancamento_ted(self, line):
# modalidade 08.
vals = {
- 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
- 'especie_titulo': line.order_id.mode.type_purchase_payment,
+ 'conta_complementar':
+ int(self.order.company_partner_bank_id.acc_number),
+ 'especie_titulo':
+ line.order_id.mode.type_purchase_payment,
# TODO: código do banco. Para a Modalidade de Pagamento valor
# pode variar
- 'codigo_banco_forn': int(line.bank_id.bank.bic),
- 'codigo_agencia_forn': int(line.bank_id.bra_number),
- 'digito_agencia_forn_transacao': line.bank_id.bra_number_dig,
- 'conta_corrente_forn': int(line.bank_id.acc_number),
- 'digito_conta_forn_transacao': line.bank_id.acc_number_dig,
+ 'codigo_banco_forn':
+ int(line.bank_id.bank.bic),
+ 'codigo_agencia_forn':
+ int(line.bank_id.bra_number),
+ 'digito_agencia_forn_transacao':
+ line.bank_id.bra_number_dig,
+ 'conta_corrente_forn':
+ int(line.bank_id.acc_number),
+ 'digito_conta_forn_transacao':
+ line.bank_id.acc_number_dig,
# TODO Gerado pelo cliente pagador quando do agendamento de
# pagamento por parte desse, exceto para a modalidade 30 -
# Títulos em Cobrança Bradesco
# communication
- 'numero_pagamento': self.adiciona_digitos_num_pag(
- line.communication),
+ 'numero_pagamento':
+ self.adiciona_digitos_num_pag(
+ line.communication),
'carteira': 0,
'nosso_numero': 0,
'vencimento_titulo': self.format_date_ano_mes_dia(
- line.ml_maturity_date),
+ line.ml_maturity_date),
'fator_vencimento': 0, # FIXME
- # 'modalidade_pagamento': int(self.order.payment_mode_id.boleto_especie),
+ # 'modalidade_pagamento':
+ # int(self.order.payment_mode_id.boleto_especie),
'tipo_movimento': 0,
# TODO Tipo de Movimento.
@@ -487,8 +504,10 @@ def lancamento_titulos_terceiros(self, line):
self.ler_linha_digitavel_codigos_ag_cc(line.linha_digitavel)
vals = {
- 'conta_complementar': int(self.order.company_partner_bank_id.acc_number),
- 'especie_titulo': line.order_id.mode.type_purchase_payment,
+ 'conta_complementar':
+ int(self.order.company_partner_bank_id.acc_number),
+ 'especie_titulo':
+ line.order_id.mode.type_purchase_payment,
# extrair do código de barras
'codigo_banco_forn': res_cods_ag_cc['codigo_banco_forn'],
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 8dabc8f8210f..c5be9c0edfe0 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luiz Felipe do Divino Costa
+# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
@@ -8,7 +9,7 @@
from ..constantes import CODIGO_OCORRENCIAS
from ..febraban.cnab import Cnab
-from odoo import api, models, fields, exceptions
+from odoo import api, models, fields
_logger = logging.getLogger(__name__)
@@ -72,9 +73,9 @@
}
CODIGO_OCORRENCIAS_CNAB200 = {
- 2: 'ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)',
- 3: 'ENTRADA REJEITADA (NOTA 20 – TABELA 1)',
- 4: 'ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA',
+ 2: 'ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)', # noqa
+ 3: 'ENTRADA REJEITADA (NOTA 20 – TABELA 1)', # noqa
+ 4: 'ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA', # noqa
5: 'ALTERAÇÃO DE DADOS – BAIXA',
6: 'LIQUIDAÇÃO NORMAL',
7: 'LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)',
@@ -88,12 +89,12 @@
15: 'BAIXAS REJEITADAS (NOTA 20 – TABELA 4)',
16: 'INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)',
17: 'ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)',
- 18: 'COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)',
+ 18: 'COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)', # noqa
19: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO',
20: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA',
21: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR',
23: 'TÍTULO ENVIADO A CARTÓRIO/TARIFA',
- 24: 'INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)',
+ 24: 'INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)', # noqa
25: 'ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)',
26: 'TARIFA DE AVISO DE COBRANÇA',
27: 'TARIFA DE EXTRATO POSIÇÃO (B40X)',
@@ -108,7 +109,7 @@
37: 'TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA',
38: 'TARIFA DE INSTRUÇÃO',
39: 'TARIFA DE OCORRÊNCIAS',
- 40: 'TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA',
+ 40: 'TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA', # noqa
41: 'DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)',
42: 'DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES',
43: 'DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS',
@@ -134,16 +135,16 @@
69: 'CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)',
71: 'ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO',
72: 'BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE',
- 73: 'CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL',
+ 73: 'CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL', # noqa
74: 'INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)',
- 75: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA',
+ 75: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA', # noqa
76: 'CHEQUE COMPENSADO',
- 77: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA',
- 78: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA',
+ 77: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA', # noqa
+ 78: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA', # noqa
79: 'NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)',
80: 'CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA',
82: 'CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA',
- 83: 'CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA',
+ 83: 'CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA', # noqa
85: 'TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA',
86: 'TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA',
87: 'TARIFA SMS COBRANÇA ATIVA ELETRÔNICA',
@@ -248,10 +249,12 @@ def _lote_400(self, evento, lote_id):
# 'favorecido_conta_bancaria': lote_bank_account_id,
'lote_id': lote_id.id,
'nosso_numero': str(evento.nosso_numero),
- 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'ocorrencias':
+ CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
'seu_numero': evento.numero_documento,
# 'tipo_moeda': evento.credito_moeda_tipo,
- 'str_motiv_a': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'str_motiv_a':
+ CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
# 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 540c16ac534d..3643d66a4873 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import api, models, fields, exceptions
+from odoo import models, fields
from .l10n_br_cnab import STATE
_logger = logging.getLogger(__name__)
@@ -20,11 +20,11 @@ class L10nBrCnabEvento(models.Model):
data_real_pagamento = fields.Datetime(
string="Data Real do Pagamento"
)
- favorecido_conta_bancaria = fields.Many2one(
+ favorecido_conta_bancaria_id = fields.Many2one(
string=u"Conta Bancária",
comodel_name="res.partner.bank",
)
- favorecido_nome = fields.Many2one(
+ favorecido_id = fields.Many2one(
string="Favorecido",
comodel_name="res.partner"
)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index a9d63798d84b..a6986a0aa1be 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import api, models, fields, exceptions
+from odoo import models, fields
from .l10n_br_cnab import STATE
_logger = logging.getLogger(__name__)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 0f5f0da574ff..4fa183ebcb6a 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -46,7 +46,8 @@
-
+
+
@@ -76,7 +77,7 @@
attrs="{'readonly': [('state', '=', 'done')]}"/>
-
From 00de8b3ae5aa1a99b923c963a1980bf9314a6661 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 14:11:19 -0300
Subject: [PATCH 076/612] [NEW] Processamento do retorno do lote aceito
Signed-off-by: Luis Felipe Mileo
---
.../models/l10n_br_cnab.py | 47 +++++++++++++-
.../views/l10n_br_cnab_retorno_view.xml | 64 +++++++++----------
2 files changed, 73 insertions(+), 38 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index c5be9c0edfe0..c97ba243249e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -72,6 +72,28 @@
9: 'Outros',
}
+
+RETORNO_400_CONFIRMADA = [
+ 2,
+]
+
+RETORNO_400_REJEITADA = [
+ 3,
+]
+
+RETORNO_400_LIQUIDACAO = [
+ 6,
+ 7,
+ 8,
+]
+
+RETORNO_400_BAIXA = [
+ 9,
+ 10,
+]
+
+
+
CODIGO_OCORRENCIAS_CNAB200 = {
2: 'ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)', # noqa
3: 'ENTRADA REJEITADA (NOTA 20 – TABELA 1)', # noqa
@@ -237,9 +259,10 @@ def _cria_lote(self, header, lote, evento, trailer):
def _lote_400(self, evento, lote_id):
- bank_payment_line_id = self.env['bank.payment.line'].search([
- ('name', '=', evento.nosso_numero)
- ])
+ bank_payment_line_id = self.env['bank.payment.line'].search([(
+ 'identificacao_titulo_empresa', '=',
+ evento.identificacao_titulo_empresa
+ )], limit=1)
vals_evento = {
'bank_payment_line_id': bank_payment_line_id.id,
@@ -269,6 +292,24 @@ def _lote_400(self, evento, lote_id):
}
self.env['l10n_br.cnab.evento'].create(vals_evento)
+ if evento.codigo_ocorrencia and bank_payment_line_id:
+ cnab_state = False
+ if evento.codigo_ocorrencia in RETORNO_400_CONFIRMADA:
+ cnab_state = 'accepted'
+ elif evento.codigo_ocorrencia in RETORNO_400_REJEITADA:
+ cnab_state = 'not_accepted'
+ elif evento.codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
+ cnab_state = 'accepted'
+ bank_state = 'paid'
+ elif evento.codigo_ocorrencia in RETORNO_400_BAIXA:
+ cnab_state = 'accepted'
+ # bank_state = ''
+
+ if cnab_state:
+ for pay_order_line_id in bank_payment_line_id.payment_line_ids:
+ pay_order_line_id.move_line_id.state_cnab = cnab_state
+ # TODO: Processar liquidacão e baixa de pagamento.
+
def _lote_240(self, evento, lote_id):
data_evento = str(
evento.credito_data_real)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 4fa183ebcb6a..8a7c3a7c9d99 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -44,6 +44,7 @@
l10n_br.cnab.evento
+
@@ -53,11 +54,6 @@
-
-
-
-
-
@@ -163,41 +159,39 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
From b4e5dee03a5edc0265392c19fc0e0e819f8a70cb Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 16:01:19 -0300
Subject: [PATCH 077/612] =?UTF-8?q?[NEW]=20Melhorias=20no=20processo=20de?=
=?UTF-8?q?=20exporta=C3=A7=C3=A3o=20dos=20registros?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_400/cnab_400.py | 27 ++++++++++++++--
.../models/account_move_line.py | 1 +
.../models/account_payment_order.py | 32 ++++++++++++-------
.../models/bank_payment_line.py | 6 ++++
.../models/l10n_br_cnab.py | 3 +-
.../views/account_payment_order.xml | 28 ++++++++++++++++
6 files changed, 83 insertions(+), 14 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 25c2fb9fa3cc..381ebbf672cb 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -18,6 +18,7 @@
_logger = logging.getLogger(__name__)
try:
from cnab240.tipos import ArquivoCobranca400
+ from cnab240.errors import Cnab240Error
except ImportError as err:
_logger.debug = (err)
@@ -306,8 +307,30 @@ def remessa(self, order):
self.arquivo = ArquivoCobranca400(
self.classe_remessa, **self._prepare_header())
for line in order.bank_line_ids:
- self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
- self.arquivo.trailer.num_seq_registro = self.controle_linha
+ try:
+ self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
+ self.arquivo.trailer.num_seq_registro = self.controle_linha
+ line.is_erro_exportacao = False
+ line.mensagem_erro_exportacao = ''
+
+ for payment_line in line.payment_line_ids:
+ payment_line.move_line_id.state_cnab = 'exported'
+
+ except Cnab240Error as e:
+ mensagem = ''
+ if hasattr(e, 'campo'):
+ mensagem += u' Campo ' + e.campo.nome
+ mensagem += u' valor ' + str(e.campo.valor)
+ mensagem += u' inválido'
+ else:
+ mensagem += u' Erro desconhecido'
+ line.is_erro_exportacao = True
+ line.mensagem_erro_exportacao = mensagem
+
+ for payment_line in line.payment_line_ids:
+ payment_line.move_line_id.state_cnab = 'exporting_error'
+
+ continue
remessa = unicode(self.arquivo)
return unicodedata.normalize(
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 33e019cb87cb..9a20a6e006e4 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -16,6 +16,7 @@
('draft', u'Inicial'), # ok
('added', u'Adicionada à ordem de pagamento'), # ok
('exported', u'Exportada'), # ok
+ ('exporting_error', u'Erro ao exportar'), # ok
('accepted', u'Aceita'),
('not_accepted', u'Não aceita pelo banco'), # importar novamente
]
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index ffcd9383bb7b..a8f30ef51d2f 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -70,6 +70,14 @@ class PaymentOrder(models.Model):
help='Campo G061 do CNAB',
default='0',
)
+ bank_line_error_ids = fields.One2many(
+ comodel_name='bank.payment.line',
+ inverse_name='order_id',
+ string="Bank Payment Error Lines",
+ readonly=True,
+ domain=[('is_erro_exportacao', '=', True)],
+ )
+
@api.model
def _prepare_bank_payment_line(self, paylines):
@@ -80,21 +88,11 @@ def _prepare_bank_payment_line(self, paylines):
paylines.identificacao_titulo_empresa
return result
- @api.multi
- def open2generated(self):
- action = super(PaymentOrder, self).open2generated()
- if self.state == 'generated':
- for payment_line in self.payment_line_ids:
- payment_line.move_line_id.state_cnab = 'exported'
- return action
-
def _generate_payment_file(self):
try:
return Cnab.gerar_remessa(order=self), self.name + '.REM'
except Cnab240Error as e:
- from odoo import exceptions
- raise exceptions.ValidationError(
- "Campo preenchido incorretamente \n\n{0}".format(e))
+ _logger.error("Erro ao gerar o arquivo: \n\n{0}".format(e))
@api.multi
def generate_payment_file(self):
@@ -103,3 +101,15 @@ def generate_payment_file(self):
if self.payment_method_id.code in ('240', '400', '500'):
return self._generate_payment_file()
return super(PaymentOrder, self).generate_payment_file()
+
+ @api.multi
+ def open2generated(self):
+ result = super(PaymentOrder, self).open2generated()
+
+ if self.bank_line_error_ids:
+ self.message_post(
+ 'Erro ao gerar o arquivo,'
+ ' verifique a aba "Linhas com problemas"')
+ return False
+ self.message_post('Arquivo gerado com sucesso')
+ return result
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 009ac952e4f8..9b1fa7f04b25 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -98,6 +98,12 @@ def default_get(self, fields_list):
identificacao_titulo_empresa = fields.Char(
string=u'Identificação Titulo Empresa',
)
+ is_erro_exportacao = fields.Boolean(
+ string=u'Contem erro de exportação',
+ )
+ mensagem_erro_exportacao = fields.Char(
+ string=u'Mensagem de erro',
+ )
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index c97ba243249e..d2f028f74897 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -83,7 +83,7 @@
RETORNO_400_LIQUIDACAO = [
6,
- 7,
+ # 7, TODO: Implementar a baixa parcial;
8,
]
@@ -308,6 +308,7 @@ def _lote_400(self, evento, lote_id):
if cnab_state:
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
pay_order_line_id.move_line_id.state_cnab = cnab_state
+
# TODO: Processar liquidacão e baixa de pagamento.
def _lote_240(self, evento, lote_id):
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order.xml b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
index e68496d439d1..ffd381c9c1ae 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
@@ -8,6 +8,18 @@
ref="account_payment_order.account_payment_order_form"/>
+
@@ -18,6 +30,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From cb909a254f1000fec7747ff4f62517b2efffd49a Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 16:07:53 -0300
Subject: [PATCH 078/612] [REF] punctuation_rm
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_240/cnab_240.py | 6 +-----
.../febraban/cnab_400/bancos/itau.py | 2 +-
.../febraban/cnab_400/cnab_400.py | 4 ----
.../febraban/pag_for/pag_for500.py | 8 ++------
4 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index 05888f9abd17..43623992fd71 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -301,7 +301,7 @@ def _prepare_cobranca(self, line):
'sacado_inscricao_tipo': int(
self.get_inscricao_tipo(line.partner_id)),
'sacado_inscricao_numero': int(
- self.rmchar(line.partner_id.cnpj_cpf)),
+ punctuation_rm(line.partner_id.cnpj_cpf)),
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
line.partner_id.street + ' ' + line.partner_id.number),
@@ -565,10 +565,6 @@ def data_hoje(self):
def hora_agora(self):
return (int(time.strftime("%H%M%S")))
- def rmchar(self, format):
- return re.sub('[%s]' % re.escape(string.punctuation), '',
- format or '')
-
def nosso_numero(self, format):
"""
Hook para ser sobrescrito e adicionar informação
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 622ac7d2be39..4e500e1ab31c 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -115,7 +115,7 @@ def _prepare_cobranca(self, line):
'sacado_inscricao_tipo': int(
self.sacado_inscricao_tipo(line.partner_id)),
'sacado_inscricao_numero': int(
- self.rmchar(line.partner_id.cnpj_cpf)),
+ punctuation_rm(line.partner_id.cnpj_cpf)),
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': sacado_endereco,
'sacado_bairro': line.partner_id.district or '',
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 381ebbf672cb..f34577f6ee51 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -164,10 +164,6 @@ def sacado_inscricao_tipo(self, partner_id):
else:
return 1
- def rmchar(self, format):
- return re.sub('[%s]' % re.escape(string.punctuation), '',
- format or '')
-
def codificar(self, texto):
return texto.encode('utf-8')
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index ac3c2451adb5..68beca5e3cf9 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -233,10 +233,6 @@ def sacado_inscricao_tipo(self, partner_id):
else:
return 1
- def rmchar(self, format):
- return re.sub('[%s]' % re.escape(
- string.punctuation), '', format or '')
-
def _prepare_cobranca(self, line, vals):
"""
@@ -260,9 +256,9 @@ def _prepare_cobranca(self, line, vals):
'cnpj_cpf_base_forn': int(
self.rmchar(line.partner_id.cnpj_cpf)[0:8]),
'cnpj_cpf_filial_forn': int(
- self.rmchar(line.partner_id.cnpj_cpf)[9:12]),
+ punctuation_rm(line.partner_id.cnpj_cpf)[9:12]),
'cnpj_cpf_forn_sufixo': int(
- self.rmchar(line.partner_id.cnpj_cpf)[12:14]),
+ punctuation_rm(line.partner_id.cnpj_cpf)[12:14]),
'nome_forn': line.partner_id.legal_name,
'endereco_forn': (
line.partner_id.street + ' ' + line.partner_id.number),
From 9098e2ed7a6aad51d35e62d5a53f41e320921332 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 16:13:15 -0300
Subject: [PATCH 079/612] [FIX] Erro ao exportar linha s/ cpf_cnpj
---
.../febraban/cnab_240/cnab_240.py | 8 ++++----
.../febraban/cnab_400/bancos/itau.py | 4 ++--
.../febraban/cnab_400/cnab_400.py | 4 ++--
.../febraban/pag_for/pag_for500.py | 12 ++++++------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index 43623992fd71..4d60a336d0d0 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -300,8 +300,8 @@ def _prepare_cobranca(self, line):
'valor_abatimento': Decimal('0.00'),
'sacado_inscricao_tipo': int(
self.get_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': int(
- punctuation_rm(line.partner_id.cnpj_cpf)),
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
line.partner_id.street + ' ' + line.partner_id.number),
@@ -425,8 +425,8 @@ def _prepare_pagamento(self, line):
'favorecido_tipo_inscricao':
self.get_inscricao_tipo(line.partner_id),
# 08.3B
- 'favorecido_num_inscricao':
- int(punctuation_rm(line.partner_id.cnpj_cpf)),
+ 'favorecido_num_inscricao': line.partner_id.cnpj_cpf and
+ int(punctuation_rm(line.partner_id.cnpj_cpf)) or '',
# 09.3B
'favorecido_endereco_rua': line.partner_id.street or '',
# 10.3B
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 4e500e1ab31c..004b04e25666 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -114,8 +114,8 @@ def _prepare_cobranca(self, line):
'valor_abatimento': Decimal('0.00'),
'sacado_inscricao_tipo': int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': int(
- punctuation_rm(line.partner_id.cnpj_cpf)),
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': sacado_endereco,
'sacado_bairro': line.partner_id.district or '',
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index f34577f6ee51..d54df3872bfc 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -262,8 +262,8 @@ def _prepare_cobranca(self, line):
'valor_abatimento': Decimal('0.00'),
'sacado_inscricao_tipo': int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': int(
- self.rmchar(line.partner_id.cnpj_cpf)),
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
# 'sacado_endereco': (
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index 68beca5e3cf9..6ba0bc5be1fd 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -253,12 +253,12 @@ def _prepare_cobranca(self, line, vals):
'tipo_inscricao': int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'cnpj_cpf_base_forn': int(
- self.rmchar(line.partner_id.cnpj_cpf)[0:8]),
- 'cnpj_cpf_filial_forn': int(
- punctuation_rm(line.partner_id.cnpj_cpf)[9:12]),
- 'cnpj_cpf_forn_sufixo': int(
- punctuation_rm(line.partner_id.cnpj_cpf)[12:14]),
+ 'cnpj_cpf_base_forn': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)[0:8]) or '',
+ 'cnpj_cpf_filial_forn': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)[9:12]) or '',
+ 'cnpj_cpf_forn_sufixo': line.partner_id.cnpj_cpf and int(
+ punctuation_rm(line.partner_id.cnpj_cpf)[12:14]) or '',
'nome_forn': line.partner_id.legal_name,
'endereco_forn': (
line.partner_id.street + ' ' + line.partner_id.number),
From b228cc317724d12f3db3c9a29061de478faf1bb4 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 16:19:46 -0300
Subject: [PATCH 080/612] [IMP] Conversao para int
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab.py | 8 ++
.../febraban/cnab_240/bancos/bb.py | 2 +-
.../febraban/cnab_240/bancos/bradesco.py | 2 +-
.../febraban/cnab_240/bancos/cef.py | 6 +-
.../febraban/cnab_240/bancos/itau.py | 12 +--
.../febraban/cnab_240/cnab_240.py | 52 ++++++-------
.../febraban/cnab_400/bancos/bradesco.py | 2 +-
.../febraban/cnab_400/bancos/itau.py | 28 +++----
.../febraban/cnab_400/cnab_400.py | 40 +++++-----
.../febraban/pag_for/bancos/bradesco.py | 4 +-
.../febraban/pag_for/pag_for500.py | 78 +++++++++----------
11 files changed, 121 insertions(+), 113 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
index c6907c3f7e1f..869d227a2b01 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab.py
@@ -79,3 +79,11 @@ def retorno(self, arquivo_retorno):
def remessa(self, order):
pass
+
+ def convert_int(self, campo):
+ if campo:
+ return int(campo)
+ # Retornamos de propósito vazio para que a cnab240 acuse o erro do
+ # registro em branco pois, se retornarmos ZERO o erro vai passar
+ # despercebido
+ return ''
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
index 3beec62fb3d4..5826a47b9484 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
@@ -41,7 +41,7 @@ def _prepare_cobranca(self, line):
# vals['desconto1_percentual'] = Decimal('0.00')
# vals['valor_iof'] = Decimal('0.00')
# # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- # vals['identificacao_titulo_banco'] = int(
+ # vals['identificacao_titulo_banco'] = self.convert_int(
# vals['identificacao_titulo_banco'])
# vals['cedente_conta_dv'] = unicode(str(
# vals['cedente_conta_dv']), "utf-8")
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
index f936f4f1cfc7..7f9d5eb282b5 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
@@ -42,7 +42,7 @@ def _prepare_cobranca(self, line):
vals['desconto1_percentual'] = Decimal('0.00')
vals['valor_iof'] = Decimal('0.00')
# vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- vals['identificacao_titulo_banco'] = int(
+ vals['identificacao_titulo_banco'] = self.convert_int(
vals['identificacao_titulo_banco'])
vals['cedente_conta_dv'] = unicode(str(
vals['cedente_conta_dv']), "utf-8")
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
index 89dc5e01d2dd..7e6e1c03ccd2 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
@@ -60,9 +60,9 @@ def _prepare_cobranca(self, line):
vals['numero_documento']), "utf-8")
# TODO: campo 27.3P CEF. Código do juros de mora
vals['juros_cod_mora'] = 3
- vals['carteira_numero'] = int(carteira)
- vals['nosso_numero'] = int(nosso_numero)
- vals['nosso_numero_dv'] = int(digito)
+ vals['carteira_numero'] = self.convert_int(carteira)
+ vals['nosso_numero'] = self.convert_int(nosso_numero)
+ vals['nosso_numero_dv'] = self.convert_int(digito)
vals['prazo_baixa'] = unicode(str(
vals['prazo_baixa']), "utf-8")
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
index 537fe22d9007..0ebb6a40e564 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
@@ -32,9 +32,9 @@ def _prepare_header(self):
:return:
"""
vals = super(Itau240, self)._prepare_header()
- # vals['cedente_dv_ag_cc'] = int(
+ # vals['cedente_dv_ag_cc'] = self.convert_int(
# vals['cedente_dv_ag_cc'])
- # vals['cedente_agencia_dv'] = int(
+ # vals['cedente_agencia_dv'] = self.convert_int(
# vals['cedente_agencia_dv']),
return vals
@@ -49,11 +49,11 @@ def _prepare_cobranca(self, line):
carteira, nosso_numero, digito = self.nosso_numero(
line.move_line_id.transaction_ref)
- vals['cedente_dv_ag_cc'] = int(
+ vals['cedente_dv_ag_cc'] = self.convert_int(
vals['cedente_dv_ag_cc'])
- vals['carteira_numero'] = int(carteira)
- vals['nosso_numero'] = int(nosso_numero)
- vals['nosso_numero_dv'] = int(digito)
+ vals['carteira_numero'] = self.convert_int(carteira)
+ vals['nosso_numero'] = self.convert_int(nosso_numero)
+ vals['nosso_numero_dv'] = self.convert_int(digito)
return vals
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
index 4d60a336d0d0..f38a96645d15 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
@@ -75,7 +75,7 @@ def _prepare_header(self):
header_arquivo = {
# CONTROLE
# 01.0
- 'controle_banco': int(
+ 'controle_banco': self.convert_int(
self.order.company_partner_bank_id.bank_id.code_bc
),
# 02.0 # Sequencia para o Arquivo
@@ -91,18 +91,18 @@ def _prepare_header(self):
self.get_inscricao_tipo(self.order.company_id.partner_id),
# 06.0
'cedente_inscricao_numero':
- int(punctuation_rm(self.order.company_id.cnpj_cpf)),
+ self.convert_int(punctuation_rm(self.order.company_id.cnpj_cpf)),
# 07.0
'cedente_convenio': '0001222130126',
# 08.0
'cedente_agencia':
- int(self.order.company_partner_bank_id.bra_number),
+ self.convert_int(self.order.company_partner_bank_id.bra_number),
# 09.0
'cedente_agencia_dv':
self.order.company_partner_bank_id.bra_number_dig,
# 10.0
'cedente_conta':
- int(punctuation_rm(
+ self.convert_int(punctuation_rm(
self.order.company_partner_bank_id.acc_number)),
# 11.0
'cedente_conta_dv':
@@ -131,7 +131,7 @@ def _prepare_header(self):
# 18.0
'arquivo_hora_de_geracao': self.hora_agora(),
# 19.0 TODO: Número sequencial de arquivo
- 'arquivo_sequencia': int(self.get_file_numeration()),
+ 'arquivo_sequencia': self.convert_int(self.get_file_numeration()),
# 20.0
'arquivo_layout': 103,
# 21.0
@@ -157,7 +157,7 @@ def _prepare_header_lote(self):
# CONTROLE
# 01.1
- 'controle_banco': int(self.order.company_partner_bank_id.code_bc),
+ 'controle_banco': self.convert_int(self.order.company_partner_bank_id.code_bc),
# 02.1 Sequencia para o Arquivo
'controle_lote': 1,
# 03.1 0- Header do Arquivo
@@ -185,13 +185,13 @@ def _prepare_header_lote(self):
'cedente_convenio': self.order.codigo_convenio,
# 12.1
'cedente_agencia':
- int(self.order.company_partner_bank_id.bra_number),
+ self.convert_int(self.order.company_partner_bank_id.bra_number),
# 13.1
'cedente_agencia_dv':
self.order.company_partner_bank_id.bra_number_dig,
# 14.1
'cedente_conta':
- int(punctuation_rm(
+ self.convert_int(punctuation_rm(
self.order.company_partner_bank_id.acc_number)),
# 15.1
'cedente_conta_dv':
@@ -267,11 +267,11 @@ def _prepare_cobranca(self, line):
# Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
return {
- 'controle_banco': int(
+ 'controle_banco': self.convert_int(
self.order.company_partner_bank_id.code_bc),
- 'cedente_agencia': int(
+ 'cedente_agencia': self.convert_int(
self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(
+ 'cedente_conta': self.convert_int(
self.order.company_partner_bank_id.acc_number),
'cedente_conta_dv':
self.order.company_partner_bank_id.acc_number_dig,
@@ -288,7 +288,7 @@ def _prepare_cobranca(self, line):
# TODO: fépefwfwe
# TODO: Código adotado para identificar o título de cobrança.
# 8 é Nota de cŕedito comercial
- 'especie_titulo': int(self.order.payment_mode_id.boleto_especie),
+ 'especie_titulo': self.convert_int(self.order.payment_mode_id.boleto_especie),
'aceite_titulo': aceite,
'data_emissao_titulo': self.format_date(
line.ml_date_created),
@@ -298,9 +298,9 @@ def _prepare_cobranca(self, line):
line.ml_maturity_date),
'juros_mora_taxa_dia': Decimal('0.00'),
'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': int(
+ 'sacado_inscricao_tipo': self.convert_int(
self.get_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': (
@@ -313,14 +313,14 @@ def _prepare_cobranca(self, line):
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
'codigo_protesto':
- int(self.order.payment_mode_id.boleto_protesto),
+ self.convert_int(self.order.payment_mode_id.boleto_protesto),
'prazo_protesto':
- int(self.order.payment_mode_id.boleto_protesto_prazo),
+ self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
'cobranca_carteira':
- int(self.order.payment_mode_id.boleto_carteira),
+ self.convert_int(self.order.payment_mode_id.boleto_carteira),
}
def _prepare_pagamento(self, line):
@@ -337,7 +337,7 @@ def _prepare_pagamento(self, line):
# CONTROLE
# 01.3A
'controle_banco':
- int(self.order.company_partner_bank_id.code_bc),
+ self.convert_int(self.order.company_partner_bank_id.code_bc),
# 02.3A
'controle_lote': 1,
# 03.3A - 3-Registros Iniciais do Lote
@@ -358,9 +358,9 @@ def _prepare_pagamento(self, line):
# 08.3A - 018-TED 700-DOC
'favorecido_camara': 0,
# 09.3A
- 'favorecido_banco': int(line.bank_id.code_bc),
+ 'favorecido_banco': self.convert_int(line.bank_id.code_bc),
# 10.3A
- 'favorecido_agencia': int(line.bank_id.bra_number),
+ 'favorecido_agencia': self.convert_int(line.bank_id.bra_number),
# 11.3A
'favorecido_agencia_dv': line.bank_id.bra_number_dig,
# 12.3A
@@ -426,11 +426,11 @@ def _prepare_pagamento(self, line):
self.get_inscricao_tipo(line.partner_id),
# 08.3B
'favorecido_num_inscricao': line.partner_id.cnpj_cpf and
- int(punctuation_rm(line.partner_id.cnpj_cpf)) or '',
+ self.convert_int(punctuation_rm(line.partner_id.cnpj_cpf)) or '',
# 09.3B
'favorecido_endereco_rua': line.partner_id.street or '',
# 10.3B
- 'favorecido_endereco_num': int(line.partner_id.number) or 0,
+ 'favorecido_endereco_num': self.convert_int(line.partner_id.number) or 0,
# 11.3B
'favorecido_endereco_complemento': line.partner_id.street2 or '',
# 12.3B
@@ -439,7 +439,7 @@ def _prepare_pagamento(self, line):
'favorecido_endereco_cidade':
line.partner_id.l10n_br_city_id.name or '',
# 14.3B
- # 'favorecido_cep': int(line.partner_id.zip[:5]) or 0,
+ # 'favorecido_cep': self.convert_int(line.partner_id.zip[:5]) or 0,
'favorecido_cep': self.get_cep('prefixo', line.partner_id.zip),
# 15.3B
'favorecido_cep_complemento':
@@ -556,14 +556,14 @@ def get_cep(self, tipo, value):
def format_date(self, srt_date):
if not srt_date:
return 0
- return int(datetime.datetime.strptime(
+ return self.convert_int(datetime.datetime.strptime(
srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
def data_hoje(self):
- return (int(time.strftime("%d%m%Y")))
+ return (self.convert_int(time.strftime("%d%m%Y")))
def hora_agora(self):
- return (int(time.strftime("%H%M%S")))
+ return (self.convert_int(time.strftime("%H%M%S")))
def nosso_numero(self, format):
"""
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
index 19d143b2910a..373af4681665 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
@@ -44,7 +44,7 @@ def _prepare_cobranca(self, line):
vals['desconto1_percentual'] = Decimal('0.00')
vals['valor_iof'] = Decimal('0.00')
# vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- vals['identificacao_titulo_banco'] = int(
+ vals['identificacao_titulo_banco'] = self.convert_int(
vals['identificacao_titulo_banco'])
vals['cedente_conta_dv'] = unicode(str(
vals['cedente_conta_dv']), "utf-8")
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 004b04e25666..6b057cd4b7b7 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -44,11 +44,11 @@ def _prepare_header(self):
:return:
"""
vals = {
- 'cedente_agencia': int(
+ 'cedente_agencia': self.convert_int(
self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(
+ 'cedente_conta': self.convert_int(
self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': int(
+ 'cedente_conta_dv': self.convert_int(
self.order.company_partner_bank_id.acc_number_dig),
'cedente_nome': unicode(self.order.company_id.legal_name),
'arquivo_data_de_geracao': self.data_hoje(),
@@ -68,22 +68,22 @@ def _prepare_cobranca(self, line):
vals = {
'identificacao_titulo_empresa': line.identificacao_titulo_empresa,
- 'nosso_numero': int(line.nosso_numero),
+ 'nosso_numero': self.convert_int(line.nosso_numero),
'numero_documento': self.adiciona_digitos_num_doc(
line.numero_documento),
'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cedente_inscricao_numero': int(punctuation_rm(
+ 'cedente_inscricao_numero': self.convert_int(punctuation_rm(
self.order.company_id.cnpj_cpf)),
- 'cedente_agencia': int(
+ 'cedente_agencia': self.convert_int(
self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(
+ 'cedente_conta': self.convert_int(
self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': int(
+ 'cedente_conta_dv': self.convert_int(
self.order.company_partner_bank_id.acc_number_dig
),
'instrucao': 0, # TODO VERIFICAR
'quantidade_moeda': 0,
- 'carteira_numero': int(
+ 'carteira_numero': self.convert_int(
self.order.payment_mode_id.boleto_carteira
),
'carteira_cod': self.order.payment_mode_id.boleto_modalidade,
@@ -97,10 +97,10 @@ def _prepare_cobranca(self, line):
'aceite_titulo': self.order.payment_mode_id.boleto_aceite,
'data_emissao_titulo': self.format_date(
line.date), # FIXME
- 'primeira_instrucao': int(
+ 'primeira_instrucao': self.convert_int(
self.order.payment_mode_id.boleto_protesto
),
- 'segunda_instrucao': int(
+ 'segunda_instrucao': self.convert_int(
self.order.payment_mode_id.boleto_protesto_prazo
),
@@ -112,14 +112,14 @@ def _prepare_cobranca(self, line):
'valor_desconto': Decimal('0.00'),
'valor_iof': Decimal('0.00'),
'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': int(
+ 'sacado_inscricao_tipo': self.convert_int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': sacado_endereco,
'sacado_bairro': line.partner_id.district or '',
- 'sacado_cep': int(line.partner_id.zip.replace('-', '')),
+ 'sacado_cep': self.convert_int(line.partner_id.zip.replace('-', '')),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index d54df3872bfc..277c0c968ca8 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -110,20 +110,20 @@ def _prepare_header(self):
:return:
"""
return {
- 'controle_banco': int(
+ 'controle_banco': self.convert_int(
self.order.company_partner_bank_id.bank_id.code_bc
),
'arquivo_data_de_geracao': self.data_hoje(),
'arquivo_hora_de_geracao': self.hora_agora(),
# TODO: Número sequencial de arquivo
- 'arquivo_sequencia': int(self.get_file_numeration()),
+ 'arquivo_sequencia': self.convert_int(self.get_file_numeration()),
'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cedente_inscricao_numero': int(punctuation_rm(
+ 'cedente_inscricao_numero': self.convert_int(punctuation_rm(
self.order.company_id.cnpj_cpf)),
- 'cedente_agencia': int(
+ 'cedente_agencia': self.convert_int(
self.order.company_partner_bank_id.bra_number),
'cedente_conta':
- int(self.order.company_partner_bank_id.acc_number),
+ self.convert_int(self.order.company_partner_bank_id.acc_number),
'cedente_conta_dv':
self.order.company_partner_bank_id.acc_number_dig,
'cedente_agencia_dv':
@@ -135,7 +135,7 @@ def _prepare_header(self):
'nome_banco':
unicode(self.order.company_partner_bank_id.bank_name),
'codigo_empresa':
- int(self.order.payment_mode_id.boleto_convenio),
+ self.convert_int(self.order.payment_mode_id.boleto_convenio),
}
def get_file_numeration(self):
@@ -146,7 +146,7 @@ def get_file_numeration(self):
return numero
def format_date(self, srt_date):
- return int(datetime.datetime.strptime(
+ return self.convert_int(datetime.datetime.strptime(
srt_date, '%Y-%m-%d').strftime('%d%m%y'))
def nosso_numero(self, format):
@@ -187,10 +187,10 @@ def _prepare_cobranca(self, line):
elif self.order.payment_mode_id.boleto_protesto == '1' \
or self.order.payment_mode_id.boleto_protesto == '2':
codigo_protesto = 6
- if (int(self.order.payment_mode_id.boleto_protesto_prazo)) < 5:
+ if (self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo)) < 5:
dias_protestar = 5
else:
- dias_protestar = int(
+ dias_protestar = self.convert_int(
self.order.payment_mode_id.boleto_protesto_prazo)
sacado_endereco = self.retorna_endereco(line.partner_id.id)
@@ -217,20 +217,20 @@ def _prepare_cobranca(self, line):
'valor_abatimento_concedido_cancelado': Decimal('0.00'),
'primeira_instrucao': codigo_protesto,
'segunda_instrucao': dias_protestar,
- 'sacado_cep': int(prefixo),
- 'sacado_cep_sufixo': int(sulfixo),
+ 'sacado_cep': self.convert_int(prefixo),
+ 'sacado_cep_sufixo': self.convert_int(sulfixo),
'sacador_avalista':
self.order.payment_mode_id.comunicacao_2,
# 'sacador_avalista': u'Protestar após 5 dias',
'num_seq_registro':
self.controle_linha,
- 'controle_banco': int(
+ 'controle_banco': self.convert_int(
self.order.company_partner_bank_id.bank_id.code_bc
),
- 'cedente_agencia': int(
+ 'cedente_agencia': self.convert_int(
self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': int(
+ 'cedente_conta': self.convert_int(
self.order.company_partner_bank_id.acc_number),
'cedente_conta_dv':
self.order.company_partner_bank_id.acc_number_dig,
@@ -246,7 +246,7 @@ def _prepare_cobranca(self, line):
Decimal('1.00')),
# TODO: Código adotado para identificar o título de cobrança.
# 8 é Nota de cŕedito comercial
- 'especie_titulo': int(self.order.payment_mode_id.boleto_especie),
+ 'especie_titulo': self.convert_int(self.order.payment_mode_id.boleto_especie),
'aceite_titulo': aceite,
'data_emissao_titulo': self.format_date(
line.date), # FIXME
@@ -260,9 +260,9 @@ def _prepare_cobranca(self, line):
line.amount_currency, 0), # line.percent_interest
'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': int(
+ 'sacado_inscricao_tipo': self.convert_int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and int(
+ 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)) or '',
'sacado_nome': line.partner_id.legal_name,
@@ -279,7 +279,7 @@ def _prepare_cobranca(self, line):
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': int(
+ 'cobranca_carteira': self.convert_int(
self.order.payment_mode_id.boleto_carteira
),
'primeira_mensagem': u'',
@@ -333,10 +333,10 @@ def remessa(self, order):
'NFKD', remessa).encode('ascii', 'ignore')
def data_hoje(self):
- return (int(time.strftime("%d%m%y")))
+ return (self.convert_int(time.strftime("%d%m%y")))
def hora_agora(self):
- return (int(time.strftime("%H%M%S")))
+ return (self.convert_int(time.strftime("%H%M%S")))
def calcula_valor_juros_dia(self, total_titulo, percent_juros):
valor_juros = 0
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
index a428ecb96f5e..de45b9a00459 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
@@ -26,7 +26,7 @@ def _prepare_header(self):
:return:
"""
vals = super(BradescoPagFor, self)._prepare_header()
- vals['codigo_comunicacao'] = int(
+ vals['codigo_comunicacao'] = self.convert_int(
self.order.payment_mode_id.boleto_convenio)
return vals
@@ -57,4 +57,4 @@ def nosso_numero(self, format):
def muda_campos_data(self, campo):
campo = str(campo)
campo = campo[-4:] + campo[2:4] + campo[:2]
- return int(campo)
+ return self.convert_int(campo)
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
index 6ba0bc5be1fd..e84aa22f1503 100644
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
@@ -176,18 +176,18 @@ def _prepare_header(self):
'arquivo_data_de_geracao': self.data_hoje_pag_for(),
'arquivo_hora_de_geracao': self.hora_agora(),
# TODO: Número sequencial de arquivo
- 'numero_remessa': int(self.get_file_numeration()),
+ 'numero_remessa': self.convert_int(self.get_file_numeration()),
'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cnpj_cpf_base': int(punctuation_rm(
+ 'cnpj_cpf_base': self.convert_int(punctuation_rm(
self.order.company_id.cnpj_cpf)[0:8]),
- 'cnpj_cpf_filial': int(punctuation_rm(
+ 'cnpj_cpf_filial': self.convert_int(punctuation_rm(
self.order.company_id.cnpj_cpf)[9:12]),
- 'sufixo_cnpj': int(punctuation_rm(
+ 'sufixo_cnpj': self.convert_int(punctuation_rm(
self.order.company_id.cnpj_cpf)[12:14]),
'cedente_agencia':
- int(self.order.company_partner_bank_id.bra_number),
+ self.convert_int(self.order.company_partner_bank_id.bra_number),
'cedente_conta':
- int(self.order.company_partner_bank_id.acc_number),
+ self.convert_int(self.order.company_partner_bank_id.acc_number),
'cedente_agencia_conta_dv':
self.order.company_partner_bank_id.bra_number_dig,
'nome_empresa_pagadora': self.order.company_id.legal_name,
@@ -197,7 +197,7 @@ def _prepare_header(self):
'servico_operacao': u'R',
'reservado_empresa': u'BRADESCO PAG FOR',
# Sequencial crescente e nunca pode ser repetido
- 'numero_lista_debito': int(self.get_file_numeration()),
+ 'numero_lista_debito': self.convert_int(self.get_file_numeration()),
# TODO: Sequencial crescente de
# 1 a 1 no arquivo. O primeiro header
# será sempre 000001
@@ -211,11 +211,11 @@ def get_file_numeration(self):
return numero
def format_date(self, srt_date):
- return int(datetime.datetime.strptime(
+ return self.convert_int(datetime.datetime.strptime(
srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
def format_date_ano_mes_dia(self, srt_date):
- return int(datetime.datetime.strptime(
+ return self.convert_int(datetime.datetime.strptime(
srt_date, '%Y-%m-%d').strftime('%Y%m%d'))
def nosso_numero(self, format):
@@ -248,22 +248,22 @@ def _prepare_cobranca(self, line, vals):
segmento = {
'conta_complementar':
- int(self.order.company_partner_bank_id.acc_number),
+ self.convert_int(self.order.company_partner_bank_id.acc_number),
# 'especie_titulo': 8,
- 'tipo_inscricao': int(
+ 'tipo_inscricao': self.convert_int(
self.sacado_inscricao_tipo(line.partner_id)),
- 'cnpj_cpf_base_forn': line.partner_id.cnpj_cpf and int(
+ 'cnpj_cpf_base_forn': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)[0:8]) or '',
- 'cnpj_cpf_filial_forn': line.partner_id.cnpj_cpf and int(
+ 'cnpj_cpf_filial_forn': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)[9:12]) or '',
- 'cnpj_cpf_forn_sufixo': line.partner_id.cnpj_cpf and int(
+ 'cnpj_cpf_forn_sufixo': line.partner_id.cnpj_cpf and self.convert_int(
punctuation_rm(line.partner_id.cnpj_cpf)[12:14]) or '',
'nome_forn': line.partner_id.legal_name,
'endereco_forn': (
line.partner_id.street + ' ' + line.partner_id.number),
- 'cep_forn': int(prefixo),
- 'cep_complemento_forn': int(sulfixo),
+ 'cep_forn': self.convert_int(prefixo),
+ 'cep_complemento_forn': self.convert_int(sulfixo),
# TODO quando banco é 237, deve-se extrair da linha
# digitável. Do contrário, zeros.
@@ -292,9 +292,9 @@ def _prepare_cobranca(self, line, vals):
# FIXME
'tipo_documento': 2, # NF, Fatura, Duplicata...
# NF_Fatura_01/Fatura_02/NF_03/Duplicata_04/Outros_05
- 'numero_nf': int(line.ml_inv_ref.internal_number),
+ 'numero_nf': self.convert_int(line.ml_inv_ref.internal_number),
- 'modalidade_pagamento': int(
+ 'modalidade_pagamento': self.convert_int(
line.order_id.mode.type_purchase_payment),
# Quando não informada o sistema assume a data constante do campo
@@ -326,12 +326,12 @@ def _prepare_cobranca(self, line, vals):
'totais_quantidade_registros': 0,
'total_valor_arq': Decimal('0.00'),
# FIXME: lib nao reconhece campo
- 'sequencial_trailer': int(self.get_file_numeration()),
+ 'sequencial_trailer': self.convert_int(self.get_file_numeration()),
'sequencial_transacao': self.controle_linha,
'codigo_protesto':
- int(self.order.payment_mode_id.boleto_protesto),
+ self.convert_int(self.order.payment_mode_id.boleto_protesto),
'prazo_protesto':
- int(self.order.payment_mode_id.boleto_protesto_prazo),
+ self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo),
'codigo_baixa': 2,
'prazo_baixa': 0, # De 5 a 120 dias.
'controlecob_data_gravacao': self.data_hoje(),
@@ -367,13 +367,13 @@ def remessa(self, order):
'NFKD', remessa).encode('ascii', 'ignore')
def data_hoje(self):
- return (int(time.strftime("%d%m%Y")))
+ return (self.convert_int(time.strftime("%d%m%Y")))
def data_hoje_pag_for(self):
- return (int(time.strftime("%Y%m%d")))
+ return (self.convert_int(time.strftime("%Y%m%d")))
def hora_agora(self):
- return (int(time.strftime("%H%M%S")))
+ return (self.convert_int(time.strftime("%H%M%S")))
@staticmethod
def modulo11(num, base, r):
@@ -406,15 +406,15 @@ def lancamento_credito_bradesco(self, line):
'especie_titulo': line.order_id.mode.type_purchase_payment,
'codigo_banco_forn': 237,
- 'codigo_agencia_forn': int(line.bank_id.bra_number),
+ 'codigo_agencia_forn': self.convert_int(line.bank_id.bra_number),
'digito_agencia_forn_transacao': line.bank_id.bra_number_dig,
- 'conta_corrente_forn': int(line.bank_id.acc_number),
+ 'conta_corrente_forn': self.convert_int(line.bank_id.acc_number),
'digito_conta_forn_transacao': line.bank_id.acc_number_dig,
'numero_pagamento': self.adiciona_digitos_num_pag(
line.communication),
- 'carteira': int(self.order.payment_mode_id.boleto_carteira),
+ 'carteira': self.convert_int(self.order.payment_mode_id.boleto_carteira),
'nosso_numero': 0,
@@ -432,20 +432,20 @@ def lancamento_ted(self, line):
vals = {
'conta_complementar':
- int(self.order.company_partner_bank_id.acc_number),
+ self.convert_int(self.order.company_partner_bank_id.acc_number),
'especie_titulo':
line.order_id.mode.type_purchase_payment,
# TODO: código do banco. Para a Modalidade de Pagamento valor
# pode variar
'codigo_banco_forn':
- int(line.bank_id.bank.bic),
+ self.convert_int(line.bank_id.bank.bic),
'codigo_agencia_forn':
- int(line.bank_id.bra_number),
+ self.convert_int(line.bank_id.bra_number),
'digito_agencia_forn_transacao':
line.bank_id.bra_number_dig,
'conta_corrente_forn':
- int(line.bank_id.acc_number),
+ self.convert_int(line.bank_id.acc_number),
'digito_conta_forn_transacao':
line.bank_id.acc_number_dig,
# TODO Gerado pelo cliente pagador quando do agendamento de
@@ -466,7 +466,7 @@ def lancamento_ted(self, line):
'fator_vencimento': 0, # FIXME
# 'modalidade_pagamento':
- # int(self.order.payment_mode_id.boleto_especie),
+ # self.convert_int(self.order.payment_mode_id.boleto_especie),
'tipo_movimento': 0,
# TODO Tipo de Movimento.
@@ -501,7 +501,7 @@ def lancamento_titulos_terceiros(self, line):
vals = {
'conta_complementar':
- int(self.order.company_partner_bank_id.acc_number),
+ self.convert_int(self.order.company_partner_bank_id.acc_number),
'especie_titulo':
line.order_id.mode.type_purchase_payment,
@@ -545,22 +545,22 @@ def ler_linha_digitavel_codigos_ag_cc(self, linha_digitavel):
# para banco = 237, bradesco
if (codigo_banco_fornecedor == '237'):
res = {
- 'codigo_banco_forn': int(codigo_banco_fornecedor),
- 'codigo_agencia_forn': int(linha_digitavel[4:8]),
+ 'codigo_banco_forn': self.convert_int(codigo_banco_fornecedor),
+ 'codigo_agencia_forn': self.convert_int(linha_digitavel[4:8]),
# Calcular usando modulo 11 base 7
'digito_agencia_forn_transacao': u'',
- 'conta_corrente_forn': int(linha_digitavel[23:30]),
+ 'conta_corrente_forn': self.convert_int(linha_digitavel[23:30]),
# Calcular usando modulo 11 base 7
'digito_conta_forn_transacao': u'',
- 'carteira': int(linha_digitavel[8:10]),
+ 'carteira': self.convert_int(linha_digitavel[8:10]),
- 'nosso_numero': int(linha_digitavel[11:21])
+ 'nosso_numero': self.convert_int(linha_digitavel[11:21])
}
# para outros bancos
else:
res = {
- 'codigo_banco_forn': int(codigo_banco_fornecedor),
+ 'codigo_banco_forn': self.convert_int(codigo_banco_fornecedor),
'codigo_agencia_forn': 0,
'digito_agencia_forn_transacao': u'',
'conta_corrente_forn': 0,
From 47f000aaf34d6d9348723359b38a0cf6720c8d4a Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Sat, 1 Jun 2019 16:24:39 -0300
Subject: [PATCH 081/612] =?UTF-8?q?[FIX]=20Valida=C3=A7=C3=A3o=20quando=20?=
=?UTF-8?q?o=20cep=20esta=20em=20branco?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_400/bancos/itau.py | 5 ++++-
.../febraban/cnab_400/cnab_400.py | 3 ++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 6b057cd4b7b7..851a9b016b25 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -119,7 +119,10 @@ def _prepare_cobranca(self, line):
'sacado_nome': line.partner_id.legal_name,
'sacado_endereco': sacado_endereco,
'sacado_bairro': line.partner_id.district or '',
- 'sacado_cep': self.convert_int(line.partner_id.zip.replace('-', '')),
+ 'sacado_cep': (
+ line.partner_id.zip and
+ self.convert_int(line.partner_id.zip.replace('-', '')) or ''
+ ),
'sacado_cidade': line.partner_id.l10n_br_city_id.name,
'sacado_uf': line.partner_id.state_id.code,
'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 277c0c968ca8..f4344f93c172 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -369,7 +369,8 @@ def retorna_endereco(self, id_parceiro):
# unicode(str_endereco.encode("ascii", errors="replace"))
# Substitui sinal de grau por espaço
- str_endereco = str_endereco.replace(u"\xb0", u" ")
+ if str_endereco:
+ str_endereco = str_endereco.replace(u"\xb0", u" ")
return str_endereco
From cf9f625b1c69cbd3bf0e2599844edac8bbdb0872 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Tue, 4 Jun 2019 14:57:02 -0300
Subject: [PATCH 082/612] =?UTF-8?q?[FIX]=20N=C3=A3o=20pular=20linha=20quan?=
=?UTF-8?q?do=20n=C3=A3o=20conseguir=20exportar?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../febraban/cnab_400/bancos/itau.py | 1 -
l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 851a9b016b25..e67e8b6f6435 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -133,7 +133,6 @@ def _prepare_cobranca(self, line):
# 'sacador_avalista': u'Protestar após 5 dias',
'num_seq_registro': self.controle_linha,
}
- self.controle_linha += 1
return vals
def nosso_numero(self, format):
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index f4344f93c172..90c7a2cdcbd3 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -306,6 +306,7 @@ def remessa(self, order):
try:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
self.arquivo.trailer.num_seq_registro = self.controle_linha
+ self.controle_linha += 1
line.is_erro_exportacao = False
line.mensagem_erro_exportacao = ''
From e316e6768ba173244d1163208e1cfa0c08612ff8 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Tue, 4 Jun 2019 14:58:29 -0300
Subject: [PATCH 083/612] =?UTF-8?q?[ADD]=20op=C3=A7=C3=B5es=20no=20wizard?=
=?UTF-8?q?=20para=20permitir=20a=20importa=C3=A7=C3=A3o?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_cobranca/__manifest__.py | 1 +
.../wizard/payment_order_create.py | 10 +++++++++-
.../wizard/payment_order_create_wizard.xml | 16 ++++++++++++++++
3 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 9a51f9c41714..a56f2a557d23 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -41,6 +41,7 @@
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
+ 'wizard/payment_order_create_wizard.xml',
'reports/report_print_button_view.xml',
'security/ir.model.access.csv',
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index a324fa19f97a..7cbb8d88fb63 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -6,12 +6,20 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, api
+from odoo import models, api, fields
class PaymentOrderCreate(models.TransientModel):
_inherit = 'account.payment.line.create'
+ allow_error = fields.Boolean(
+ string=u"Permitir linhas com erro na exportação, "
+ u"já incluidas em outras ordens"
+ )
+ allow_rejected = fields.Boolean(
+ string="Permitir linhas com retorno rejeitado"
+ )
+
@api.multi
def _prepare_move_line_domain(self):
""" Nenhuma linha deve ser adicionada novamente a nao ser que o
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml b/l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml
new file mode 100644
index 000000000000..244c6e3d2775
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml
@@ -0,0 +1,16 @@
+
+
+
+ l10n_br_account_payment_boleto.res.company.form
+
+ account.payment.line.create
+
+
+
+
+
+
+
+
+
From 4d6c591f543aa27a2ffd56f189cc869aa1e8a923 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Tue, 4 Jun 2019 15:34:08 -0300
Subject: [PATCH 084/612] =?UTF-8?q?[REF]=20Filtro=20para=20permitir=20a=20?=
=?UTF-8?q?importa=C3=A7=C3=A3o=20de=20registros=20com=20problema?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Luis Felipe Mileo
---
.../wizard/payment_order_create.py | 83 +++++++++++++++++--
1 file changed, 76 insertions(+), 7 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 7cbb8d88fb63..b124adc6c847 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -27,17 +27,86 @@ def _prepare_move_line_domain(self):
:return:
"""
- domain = super(PaymentOrderCreate, self)._prepare_move_line_domain()
+ # TODO: Refactory this to call super!
+ self.ensure_one()
+ domain = [('reconciled', '=', False),
+ ('company_id', '=', self.order_id.company_id.id)]
+ if self.journal_ids:
+ domain += [('journal_id', 'in', self.journal_ids.ids)]
+ if self.partner_ids:
+ domain += [('partner_id', 'in', self.partner_ids.ids)]
+ if self.target_move == 'posted':
+ domain += [('move_id.state', '=', 'posted')]
+ if not self.allow_blocked:
+ domain += [('blocked', '!=', True)]
+ if self.date_type == 'due':
+ domain += [
+ '|',
+ ('date_maturity', '<=', self.due_date),
+ ('date_maturity', '=', False)]
+ elif self.date_type == 'move':
+ domain.append(('date', '<=', self.move_date))
+ if self.invoice:
+ domain.append(('invoice_id', '!=', False))
+ if self.payment_mode:
+ if self.payment_mode == 'same':
+ domain.append(
+ ('payment_mode_id', '=', self.order_id.payment_mode_id.id))
+ elif self.payment_mode == 'same_or_null':
+ domain += [
+ '|',
+ ('payment_mode_id', '=', False),
+ ('payment_mode_id', '=', self.order_id.payment_mode_id.id)]
+
+ if self.order_id.payment_type == 'outbound':
+ # For payables, propose all unreconciled credit lines,
+ # including partially reconciled ones.
+ # If they are partially reconciled with a supplier refund,
+ # the residual will be added to the payment order.
+ #
+ # For receivables, propose all unreconciled credit lines.
+ # (ie customer refunds): they can be refunded with a payment.
+ # Do not propose partially reconciled credit lines,
+ # as they are deducted from a customer invoice, and
+ # will not be refunded with a payment.
+ domain += [
+ ('credit', '>', 0),
+ # '|',
+ ('account_id.internal_type', '=', 'payable'),
+ # '&',
+ # ('account_id.internal_type', '=', 'receivable'),
+ # ('reconcile_partial_id', '=', False), # TODO uncomment
+ ]
+ elif self.order_id.payment_type == 'inbound':
+ domain += [
+ ('debit', '>', 0),
+ ('account_id.internal_type', '=', 'receivable'),
+ ]
+ # Exclude lines that are already in a non-cancelled
+ # and non-uploaded payment order; lines that are in a
+ # uploaded payment order are proposed if they are not reconciled,
paylines = self.env['account.payment.line'].search([
('state', 'in', ('draft', 'open', 'generated', 'uploaded')),
('move_line_id', '!=', False)])
- if paylines:
- move_lines_ids = [
- payline.move_line_id.id for payline in paylines
- if payline.move_line_id.state_cnab == 'not_accepted'
- ]
- domain += [('id', 'not in', move_lines_ids)]
+ move_line_domain = ['draft']
+ if self.allow_error:
+ move_line_domain.append('exporting_error')
+ if self.allow_rejected:
+ move_line_domain.append('not_accepted')
+
+ domain += [
+ ('bank_payment_line_id', '=', False),
+ ]
+
+ domain += [
+ ('state_cnab', 'in', move_line_domain),
+ ]
+ # if paylines:
+ # move_lines_ids = [
+ # payline.move_line_id.id for payline in paylines
+ # ]
+ # domain += [('id', 'not in', move_lines_ids)]
return domain
From 1577ccd714fcdc44a240a288cc29a007aa748fe5 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Tue, 4 Jun 2019 17:23:13 -0300
Subject: [PATCH 085/612] [FIX] Atualiza nosso numero ao importar o retorno
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index d2f028f74897..212a1ca33339 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -308,6 +308,9 @@ def _lote_400(self, evento, lote_id):
if cnab_state:
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
pay_order_line_id.move_line_id.state_cnab = cnab_state
+ pay_order_line_id.move_line_id.nosso_numero = str(
+ evento.nosso_numero
+ )
# TODO: Processar liquidacão e baixa de pagamento.
From 6f2cb68383f1490ea01ad147a659aec3dc124a66 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 5 Jun 2019 22:40:13 -0300
Subject: [PATCH 086/612] [NEW]reconciliacao com retorno cnab
---
.../models/l10n_br_cnab.py | 27 ++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 212a1ca33339..21a24dd8b8c0 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -312,7 +312,32 @@ def _lote_400(self, evento, lote_id):
evento.nosso_numero
)
- # TODO: Processar liquidacão e baixa de pagamento.
+ if bank_state == 'paid':
+ ap_obj = self.env['account.payment']
+ inv = pay_order_line_id.move_line_id.invoice_id
+ # self.env['account.invoice'].search([
+ # ('name', '=', pay_order_line_id.numero_documento)
+ # ])
+
+ payment_values = {
+ 'invoice_ids': [6, 0, [inv.id]],
+ 'payment_type': 'inbound',
+ 'partner_type': 'customer',
+ 'payment_method_id':
+ bank_payment_line_id.order_id.payment_method_id.id,
+ 'partner_id': bank_payment_line_id.partner_id.id,
+ 'journal_id': bank_payment_line_id.order_id.journal_id.id,
+ 'amount': evento.valor_principal,
+ 'payment_date': evento.data_credito,
+ 'communication': evento.nosso_numero
+ }
+ payment = ap_obj.create(payment_values)
+ payment.post()
+ inv_move_lines = inv.move_line_receivable_id
+ pay_move_lines = payment.move_line_ids.filtered(
+ lambda x: x.account_id == inv_move_lines.account_id)
+ move_lines = pay_move_lines | inv_move_lines
+ move_lines.reconcile()
def _lote_240(self, evento, lote_id):
data_evento = str(
From eb1b2a7c8b92b4e30854b1b24c4f405b2bb1b6b9 Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Fri, 7 Jun 2019 16:32:48 -0300
Subject: [PATCH 087/612] =?UTF-8?q?[ADD]=20Identifica=C3=A7=C3=A3o=20T?=
=?UTF-8?q?=C3=ADtulo=20Empresa?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 ++
.../models/l10n_br_cnab_evento.py | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 21a24dd8b8c0..40b1bd70afa0 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -289,6 +289,8 @@ def _lote_400(self, evento, lote_id):
# 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
# ocorrencias[4] else '',
'valor_pagamento': evento.valor_principal,
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
}
self.env['l10n_br.cnab.evento'].create(vals_evento)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 3643d66a4873..3fa201a63c5d 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -71,3 +71,7 @@ class L10nBrCnabEvento(models.Model):
valor_pagamento = fields.Float(
string="Valor do Pagamento"
)
+ identificacao_titulo_empresa = fields.Char(
+ string="Identificação do Título da Empresa",
+ required=False,
+ )
From e5f40ead7594205f16ee17d6b95857e6d9561025 Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Fri, 7 Jun 2019 18:01:35 -0300
Subject: [PATCH 088/612] [ADD] Evento tree view e menuitem
---
.../__manifest__.py | 1 +
.../views/l10n_br_cnab_evento_views.xml | 35 +++++++++++++++++++
2 files changed, 36 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index a56f2a557d23..88c65a4423ee 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -36,6 +36,7 @@
'views/account_move_line.xml',
'views/l10n_br_cnab_retorno_view.xml',
+ 'views/l10n_br_cnab_evento_views.xml',
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
new file mode 100644
index 000000000000..1fc0bf2b7b17
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ Lotes do arquivo de retorno
+ ir.actions.act_window
+ l10n_br.cnab.evento
+ tree,form
+ {'search_default_cnab_evento_date_search': 1}
+
+
+
+
+
+
+
+
+ view.l10n_br.cnab.evento.search
+ l10n_br.cnab.evento
+
+
+
+
+
+
+
+
+
From 659915db35d197b40a9cb4fab5b29c284bf766df Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Fri, 7 Jun 2019 18:02:11 -0300
Subject: [PATCH 089/612] [REF] Processar retorno submenu
---
.../views/l10n_br_cnab_retorno_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 8a7c3a7c9d99..fced2561269c 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -205,7 +205,7 @@
From 2821d5b99f738fce78448f59584c44e183cec2f8 Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Fri, 7 Jun 2019 18:55:35 -0300
Subject: [PATCH 090/612] [ADD] Move account payment cobranca menuitems to new
category
---
.../views/l10n_br_cnab_evento_views.xml | 2 +-
.../views/l10n_br_cnab_retorno_view.xml | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
index 1fc0bf2b7b17..cbd6512ec0a1 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
@@ -13,7 +13,7 @@
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index fced2561269c..c096011655c8 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -204,7 +204,8 @@
tree,form
-
From de7683ded195bc64302a69141572edfcaa0290a7 Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Fri, 7 Jun 2019 19:46:44 -0300
Subject: [PATCH 091/612] =?UTF-8?q?[ADD]=20state=5Fcnab=20e=20nosso=5Fnume?=
=?UTF-8?q?ro=20na=20vis=C3=A3o=20tree=20dos=20vencimentos?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../views/account_move_line.xml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index e52294bb1c62..a4606bb8defe 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -28,4 +28,19 @@
+
+
+
+ view.l10n_br_account.invoice.form.form.inherit
+
+ account.invoice
+
+
+
+
+
+
+
+
From 62c9d406df0f383817c5cef17615681742b8837b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Mon, 10 Jun 2019 14:34:23 -0300
Subject: [PATCH 092/612] [FIX] account.payment create parameters
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 40b1bd70afa0..d24a1d8bce36 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -322,7 +322,7 @@ def _lote_400(self, evento, lote_id):
# ])
payment_values = {
- 'invoice_ids': [6, 0, [inv.id]],
+ 'invoice_ids': [(6, 0, [inv.id])],
'payment_type': 'inbound',
'partner_type': 'customer',
'payment_method_id':
From f45071cfcfef35d3e03222867433f3c700a55ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Mon, 10 Jun 2019 17:03:51 -0300
Subject: [PATCH 093/612] [FIX] Reconcile only unreconciled lines
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index d24a1d8bce36..38936fbdb768 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -339,7 +339,8 @@ def _lote_400(self, evento, lote_id):
pay_move_lines = payment.move_line_ids.filtered(
lambda x: x.account_id == inv_move_lines.account_id)
move_lines = pay_move_lines | inv_move_lines
- move_lines.reconcile()
+ move_lines.filtered(
+ lambda l: l.reconciled is False).reconcile()
def _lote_240(self, evento, lote_id):
data_evento = str(
From 4fdbc92347117684954b4b1b0e9707fb6fb02fc5 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Tue, 11 Jun 2019 18:13:45 -0300
Subject: [PATCH 094/612] =?UTF-8?q?[REF]Criacao=20de=20lan=C3=A7amentos=20?=
=?UTF-8?q?contabeis=20de=20maneira=20correta=20para=20fazer=20a=20concili?=
=?UTF-8?q?acao=20com=20extrato=20posteriormente?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 102 +++++++++++++-----
1 file changed, 73 insertions(+), 29 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 38936fbdb768..61db950080ac 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -296,6 +296,7 @@ def _lote_400(self, evento, lote_id):
if evento.codigo_ocorrencia and bank_payment_line_id:
cnab_state = False
+ bank_state = False
if evento.codigo_ocorrencia in RETORNO_400_CONFIRMADA:
cnab_state = 'accepted'
elif evento.codigo_ocorrencia in RETORNO_400_REJEITADA:
@@ -308,39 +309,38 @@ def _lote_400(self, evento, lote_id):
# bank_state = ''
if cnab_state:
+ amount = 0.0
+ line_values = []
+ invoices = []
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
pay_order_line_id.move_line_id.state_cnab = cnab_state
pay_order_line_id.move_line_id.nosso_numero = str(
evento.nosso_numero
)
- if bank_state == 'paid':
- ap_obj = self.env['account.payment']
- inv = pay_order_line_id.move_line_id.invoice_id
- # self.env['account.invoice'].search([
- # ('name', '=', pay_order_line_id.numero_documento)
- # ])
-
- payment_values = {
- 'invoice_ids': [(6, 0, [inv.id])],
- 'payment_type': 'inbound',
- 'partner_type': 'customer',
- 'payment_method_id':
- bank_payment_line_id.order_id.payment_method_id.id,
- 'partner_id': bank_payment_line_id.partner_id.id,
- 'journal_id': bank_payment_line_id.order_id.journal_id.id,
- 'amount': evento.valor_principal,
- 'payment_date': evento.data_credito,
- 'communication': evento.nosso_numero
- }
- payment = ap_obj.create(payment_values)
- payment.post()
- inv_move_lines = inv.move_line_receivable_id
- pay_move_lines = payment.move_line_ids.filtered(
- lambda x: x.account_id == inv_move_lines.account_id)
- move_lines = pay_move_lines | inv_move_lines
- move_lines.filtered(
- lambda l: l.reconciled is False).reconcile()
+ if bank_state == 'paid':
+ invoice = pay_order_line_id.move_line_id.invoice_id
+ if invoice.state == 'open':
+ line_values.append(
+ (0, 0,
+ {
+ 'name' : evento.nosso_numero,
+ 'credit' : float(evento.valor_principal),
+ 'account_id' : invoice.account_id.id,
+ 'journal_id' :
+ bank_payment_line_id.order_id.\
+ journal_id.id,
+ 'date_maturity' : evento.data_ocorrencia,
+ 'partner_id' : bank_payment_line_id.\
+ partner_id.id
+ }
+ )
+ )
+ amount += float(evento.valor_principal)
+ invoices.append(invoice)
+
+ return line_values, amount, invoices
+ return False, False, []
def _lote_240(self, evento, lote_id):
data_evento = str(
@@ -437,7 +437,9 @@ def processar_arquivo_retorno(self):
trailer = lote.trailer or arquivo_parser.trailer
lote_id = False
-
+ total_amount = 0.0
+ lines = []
+ inv_list = []
for evento in lote.eventos:
if not lote_id:
lote_id, lote_bank_account_id = self._cria_lote(
@@ -446,7 +448,49 @@ def processar_arquivo_retorno(self):
if cnab_type == '240':
self._lote_240(evento, lote_id)
else:
- self._lote_400(evento, lote_id)
+ line_vals, line_amount, invoices = \
+ self._lote_400(evento, lote_id)
+ for inv in invoices:
+ inv_list.append(inv)
+ if line_vals and line_amount:
+ for line in line_vals:
+ lines.append(line)
+ total_amount += line_amount
+
+ if total_amount and lines:
+ counterpart_account_id = self.env['account.journal'].browse(
+ lines[0][2]['journal_id']).default_debit_account_id.id
+
+ lines.append(
+ (0, 0, {
+ 'name':'cobranca',
+ 'debit': total_amount,
+ 'account_id': counterpart_account_id,
+ 'journal_id':lines[0][2]['journal_id'],
+ 'date_maturity':False,
+ 'partner_id':False,
+ })
+ )
+ move = self.env['account.move'].create({
+ 'name': 'RetornoCnab_'+ str(datetime.now()),
+ 'ref': 'ref',
+ 'date': str(datetime.now()),
+ 'line_ids': lines,
+ 'journal_id': lines[0][2]['journal_id']
+ })
+ move.post()
+
+ for inv in inv_list:
+ if inv.state != 'open':
+ continue
+ inv_move_lines = inv.move_line_receivable_id
+ pay_move_lines = move.line_ids.filtered(
+ lambda x: x.account_id == inv_move_lines.account_id and
+ x.partner_id == inv_move_lines.partner_id
+ )
+ move_lines = pay_move_lines | inv_move_lines
+ move_lines.reconcile()
+
return self.write({'state': 'done'})
@api.multi
From 13e96d7ae473bcc3ce91ccc894017163691e6063 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 12 Jun 2019 14:37:51 -0300
Subject: [PATCH 095/612] =?UTF-8?q?[IMP]Campos=20de=20situa=C3=A7=C3=A3o?=
=?UTF-8?q?=20da=20baixa?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_move_line.py | 20 ++++++++++++++-----
.../views/account_move_line.xml | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 9a20a6e006e4..5b997b8d232f 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -13,12 +13,19 @@
ESTADOS_CNAB = [
- ('draft', u'Inicial'), # ok
- ('added', u'Adicionada à ordem de pagamento'), # ok
- ('exported', u'Exportada'), # ok
- ('exporting_error', u'Erro ao exportar'), # ok
+ ('draft', u'Inicial'),
+ ('added', u'Adicionada à ordem de pagamento'),
+ ('exported', u'Exportada'),
+ ('exporting_error', u'Erro ao exportar'),
('accepted', u'Aceita'),
- ('not_accepted', u'Não aceita pelo banco'), # importar novamente
+ ('not_accepted', u'Não aceita pelo banco'),
+ ('done', u'Concluído'),
+]
+
+SITUACAO_PAGAMENTO = [
+ ('aberta', 'Aberta'),
+ ('paga', 'Paga'),
+ ('liquidada', 'Liquidada'),
]
@@ -38,6 +45,9 @@ class AccounMoveLine(models.Model):
identificacao_titulo_empresa = fields.Char(
string=u'Identificação Titulo Empresa',
)
+ situacao_pagamento = fields.Selection(
+ SITUACAO_PAGAMENTO, u'Situação da baixa', default='aberta'
+ )
@api.multi
def _prepare_payment_line_vals(self, payment_order):
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index a4606bb8defe..b8ac3fdc6b56 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -8,6 +8,7 @@
+
From 5011b1e34fadff51955a4cff08a0359211659eb5 Mon Sep 17 00:00:00 2001
From: Diego Paradeda
Date: Wed, 12 Jun 2019 15:12:31 -0300
Subject: [PATCH 096/612] [ADD] Codigos de registros rejeitados itau cnab400
---
.../models/l10n_br_cnab.py | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 61db950080ac..31657b58e822 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -92,6 +92,65 @@
10,
]
+# CODIGO_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
+CODIGO_REGISTROS_REJEITADOS_CNAB400 = {
+ '03': 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
+ '04': 'ESTADO - SIGLA DO ESTADO INVÁLIDA',
+ '05': 'DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO',
+ '07': 'VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00',
+ '08': 'NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO',
+ '09': 'AGENCIA/CONTA - AGÊNCIA ENCERRADA',
+ '10': 'LOGRADOURO - NÃO INFORMADO OU DESLOCADO',
+ '11': 'CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO',
+ '12': 'SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)',
+ '13': 'ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO',
+ '14': 'NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA',
+ '15': 'NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO',
+ '18': 'DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA',
+ '19': 'OCORRÊNCIA - OCORRÊNCIA INVÁLIDA',
+ '21': 'AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO',
+ '22': 'CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)',
+ '26': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA',
+ '27': 'CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA',
+ '29': 'CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA',
+ '30': 'ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA',
+ '31': 'AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)',
+ '35': 'VALOR DO IOF - IOF MAIOR QUE 5%',
+ '36': 'QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO',
+ '37': 'CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS',
+ '42': 'NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA',
+ '52': 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE',
+ '53': 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM',
+ '54': 'DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS',
+ '55': 'DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA',
+ '56': 'DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA',
+ '57': 'DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS',
+ '60': 'ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO',
+ '61': 'JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO',
+ '62': 'DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO',
+ '63': 'DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO',
+ '64': 'DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA',
+ '65': 'TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)',
+ '66': 'DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)',
+ '67': 'VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO',
+ '68': 'CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA',
+ '69': 'CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ '70': 'AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO',
+ '78': 'AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO',
+ '80': 'AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)',
+ '81': 'AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ',
+ '82': 'DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ '83': 'VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO',
+ '84': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO',
+ '85': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO',
+ '86': 'TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ '87': 'AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO',
+ '90': 'NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS',
+ '97': 'SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8',
+ '98': 'FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO',
+ '99': 'FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE',
+}
+
CODIGO_OCORRENCIAS_CNAB200 = {
From 043138e31b8c88b92d41441436bf455a4b4cf824 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 12 Jun 2019 16:11:56 -0300
Subject: [PATCH 097/612] =?UTF-8?q?[IMP]Diferencia=C3=A7=C3=A3o=20de=20bai?=
=?UTF-8?q?xa=20e=20liquidacao?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 28 ++++++++++++-------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 31657b58e822..68ab36ab472e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -353,6 +353,9 @@ def _lote_400(self, evento, lote_id):
}
self.env['l10n_br.cnab.evento'].create(vals_evento)
+ amount = 0.0
+ line_values = []
+ invoices = []
if evento.codigo_ocorrencia and bank_payment_line_id:
cnab_state = False
bank_state = False
@@ -362,23 +365,26 @@ def _lote_400(self, evento, lote_id):
cnab_state = 'not_accepted'
elif evento.codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
cnab_state = 'accepted'
- bank_state = 'paid'
+ bank_state = 'settled'
elif evento.codigo_ocorrencia in RETORNO_400_BAIXA:
cnab_state = 'accepted'
- # bank_state = ''
+ if evento.codigo_ocorrencia == 9:
+ bank_state = 'writed_off'
+ else:
+ bank_state = 'settled'
if cnab_state:
- amount = 0.0
- line_values = []
- invoices = []
+
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
pay_order_line_id.move_line_id.state_cnab = cnab_state
pay_order_line_id.move_line_id.nosso_numero = str(
evento.nosso_numero
)
-
- if bank_state == 'paid':
- invoice = pay_order_line_id.move_line_id.invoice_id
+ move_line = pay_order_line_id.move_line_id
+ invoice = move_line.invoice_id
+ if bank_state == 'settled':
+ move_line.situacao_pagamento = 'liquidado'
+ move_line.state_cnab = 'done'
if invoice.state == 'open':
line_values.append(
(0, 0,
@@ -397,9 +403,11 @@ def _lote_400(self, evento, lote_id):
)
amount += float(evento.valor_principal)
invoices.append(invoice)
+ elif bank_state == 'writed_off':
+ move_line.situacao_pagamento = 'baixa'
+ move_line.state_cnab = 'done'
- return line_values, amount, invoices
- return False, False, []
+ return line_values, amount, invoices
def _lote_240(self, evento, lote_id):
data_evento = str(
From 29249c1fc38cc509e8ceda21ab4ea8e03bedf265 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Wed, 12 Jun 2019 16:35:03 -0300
Subject: [PATCH 098/612] =?UTF-8?q?[FIX]Campo=20"Seu=20Numero"=20sendo=20c?=
=?UTF-8?q?ortado=20na=20comunica=C3=A7=C3=A3o=20CNAB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index ec58bb977277..85476dd9017c 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -35,10 +35,9 @@ def action_move_create(self):
# inv.transaction_id = sequence
for index, interval in enumerate(inv.move_line_receivable_id):
+ inv_number = inv.get_invoice_fiscal_number().split('/')[-1]
numero_documento = (
- inv.get_invoice_fiscal_number() +
- '/' +
- str(index + 1).zfill(2)
+ inv_number + '/' + str(index + 1).zfill(2)
)
# Verificar se é boleto para criar o numero
From 524b83d7d98da4e862d2670dc3b53a3038382054 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 12 Jun 2019 17:50:42 -0300
Subject: [PATCH 099/612] [REF] account.payment.line.create class Name
---
l10n_br_account_payment_cobranca/wizard/payment_order_create.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index b124adc6c847..7b02dcf6fce7 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -9,7 +9,7 @@
from odoo import models, api, fields
-class PaymentOrderCreate(models.TransientModel):
+class AccountPaymentLineCreate(models.TransientModel):
_inherit = 'account.payment.line.create'
allow_error = fields.Boolean(
From bc39ef20e242eb71834a0f11734807d38b085b31 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 12 Jun 2019 17:52:13 -0300
Subject: [PATCH 100/612] =?UTF-8?q?[ADD]=20C=C3=B3digos=20de=20registros?=
=?UTF-8?q?=20rejeitados=20nos=20Eventos=20do=20CNAB400?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 20 +++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 68ab36ab472e..cdc5bd59e73d 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -339,14 +339,18 @@ def _lote_400(self, evento, lote_id):
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
- # 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
- # ocorrencias[1] else '',
- # 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
- # ocorrencias[2] else '',
- # 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
- # ocorrencias[3] else '',
- # 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
- # ocorrencias[4] else '',
+ 'str_motiv_b':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[0:1]]
+ if evento.erros[0:1] else '',
+ 'str_motiv_c':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[2:3]]
+ if evento.erros[2:3] else '',
+ 'str_motiv_d':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[4:5]]
+ if evento.erros[4:5] else '',
+ 'str_motiv_e':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[6:7]]
+ if evento.erros[6:7] else '',
'valor_pagamento': evento.valor_principal,
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
From 56377f983f48db7a12f47c1ed0313a214b9d1d20 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 12 Jun 2019 17:53:48 -0300
Subject: [PATCH 101/612] [ADD] Tratamento de Estados situacao_pagamento e
state_cnab
---
.../models/account_move_line.py | 6 +-
.../models/l10n_br_cnab.py | 77 ++++++++++---------
2 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 5b997b8d232f..14bbd48991f4 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -23,9 +23,11 @@
]
SITUACAO_PAGAMENTO = [
+ ('inicial', 'Inicial'),
('aberta', 'Aberta'),
('paga', 'Paga'),
('liquidada', 'Liquidada'),
+ ('baixa_liquidacao', 'Baixa por Liquidação em Dinheiro'),
]
@@ -46,7 +48,9 @@ class AccounMoveLine(models.Model):
string=u'Identificação Titulo Empresa',
)
situacao_pagamento = fields.Selection(
- SITUACAO_PAGAMENTO, u'Situação da baixa', default='aberta'
+ selection=SITUACAO_PAGAMENTO,
+ string=u'Situação do Pagamento',
+ default='inicial'
)
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index cdc5bd59e73d..48b2cad6bc4b 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -335,8 +335,8 @@ def _lote_400(self, evento, lote_id):
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
'seu_numero': evento.numero_documento,
# 'tipo_moeda': evento.credito_moeda_tipo,
- 'str_motiv_a':
- CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ # 'str_motiv_a':
+ # CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
'str_motiv_b':
@@ -355,27 +355,33 @@ def _lote_400(self, evento, lote_id):
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
}
- self.env['l10n_br.cnab.evento'].create(vals_evento)
+ cnab_event_id = self.env['l10n_br.cnab.evento'].create(vals_evento)
amount = 0.0
line_values = []
invoices = []
- if evento.codigo_ocorrencia and bank_payment_line_id:
+ codigo_ocorrencia = evento.codigo_ocorrencia
+ if codigo_ocorrencia and bank_payment_line_id:
cnab_state = False
bank_state = False
- if evento.codigo_ocorrencia in RETORNO_400_CONFIRMADA:
+ if codigo_ocorrencia in RETORNO_400_CONFIRMADA:
cnab_state = 'accepted'
- elif evento.codigo_ocorrencia in RETORNO_400_REJEITADA:
+ bank_state = 'aberta'
+ elif codigo_ocorrencia in RETORNO_400_REJEITADA:
cnab_state = 'not_accepted'
- elif evento.codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
+ bank_state = 'inicial'
+ elif codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
cnab_state = 'accepted'
- bank_state = 'settled'
- elif evento.codigo_ocorrencia in RETORNO_400_BAIXA:
+ bank_state = 'liquidada'
+ elif codigo_ocorrencia in RETORNO_400_BAIXA:
cnab_state = 'accepted'
- if evento.codigo_ocorrencia == 9:
- bank_state = 'writed_off'
+ if codigo_ocorrencia == 9:
+ bank_state = 'baixa'
else:
- bank_state = 'settled'
+ bank_state = 'baixa_liquidacao'
+ else:
+ cnab_event_id.str_motiv_a = codigo_ocorrencia + \
+ ': Ocorrência não tratada'
if cnab_state:
@@ -386,30 +392,29 @@ def _lote_400(self, evento, lote_id):
)
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
- if bank_state == 'settled':
- move_line.situacao_pagamento = 'liquidado'
- move_line.state_cnab = 'done'
- if invoice.state == 'open':
- line_values.append(
- (0, 0,
- {
- 'name' : evento.nosso_numero,
- 'credit' : float(evento.valor_principal),
- 'account_id' : invoice.account_id.id,
- 'journal_id' :
- bank_payment_line_id.order_id.\
- journal_id.id,
- 'date_maturity' : evento.data_ocorrencia,
- 'partner_id' : bank_payment_line_id.\
- partner_id.id
- }
- )
- )
- amount += float(evento.valor_principal)
- invoices.append(invoice)
- elif bank_state == 'writed_off':
- move_line.situacao_pagamento = 'baixa'
- move_line.state_cnab = 'done'
+ if bank_state == 'liquidado' and invoice.state == 'open':
+ line_values.append(
+ (0, 0,
+ {
+ 'name' : evento.nosso_numero,
+ 'credit' : float(evento.valor_principal),
+ 'account_id' : invoice.account_id.id,
+ 'journal_id' :
+ bank_payment_line_id.order_id.\
+ journal_id.id,
+ 'date_maturity' : evento.data_ocorrencia,
+ 'partner_id' : bank_payment_line_id.\
+ partner_id.id
+ }
+ )
+ )
+ amount += float(evento.valor_principal)
+ invoices.append(invoice)
+
+ if bank_state:
+ move_line.situacao_pagamento = bank_state
+ if cnab_state:
+ move_line.state_cnab = cnab_state
return line_values, amount, invoices
From 0db23daf1579ebd309cf2376bcbc8eefec4a967e Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 12 Jun 2019 18:20:09 -0300
Subject: [PATCH 102/612] [FIX] Dict Erros CNAB400
---
.../models/l10n_br_cnab.py | 126 +++++++++---------
1 file changed, 63 insertions(+), 63 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 48b2cad6bc4b..c654b2bf321b 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -94,61 +94,61 @@
# CODIGO_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
CODIGO_REGISTROS_REJEITADOS_CNAB400 = {
- '03': 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
- '04': 'ESTADO - SIGLA DO ESTADO INVÁLIDA',
- '05': 'DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO',
- '07': 'VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00',
- '08': 'NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO',
- '09': 'AGENCIA/CONTA - AGÊNCIA ENCERRADA',
- '10': 'LOGRADOURO - NÃO INFORMADO OU DESLOCADO',
- '11': 'CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO',
- '12': 'SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)',
- '13': 'ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO',
- '14': 'NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA',
- '15': 'NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO',
- '18': 'DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA',
- '19': 'OCORRÊNCIA - OCORRÊNCIA INVÁLIDA',
- '21': 'AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO',
- '22': 'CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)',
- '26': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA',
- '27': 'CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA',
- '29': 'CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA',
- '30': 'ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA',
- '31': 'AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)',
- '35': 'VALOR DO IOF - IOF MAIOR QUE 5%',
- '36': 'QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO',
- '37': 'CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS',
- '42': 'NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA',
- '52': 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE',
- '53': 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM',
- '54': 'DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS',
- '55': 'DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA',
- '56': 'DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA',
- '57': 'DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS',
- '60': 'ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO',
- '61': 'JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO',
- '62': 'DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO',
- '63': 'DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO',
- '64': 'DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA',
- '65': 'TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)',
- '66': 'DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)',
- '67': 'VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO',
- '68': 'CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA',
- '69': 'CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO',
- '70': 'AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO',
- '78': 'AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO',
- '80': 'AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)',
- '81': 'AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ',
- '82': 'DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO',
- '83': 'VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO',
- '84': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO',
- '85': 'AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO',
- '86': 'TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO',
- '87': 'AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO',
- '90': 'NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS',
- '97': 'SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8',
- '98': 'FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO',
- '99': 'FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE',
+ 3: 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
+ 4: 'ESTADO - SIGLA DO ESTADO INVÁLIDA',
+ 5: 'DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO',
+ 7: 'VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00',
+ 8: 'NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO',
+ 9: 'AGENCIA/CONTA - AGÊNCIA ENCERRADA',
+ 10: 'LOGRADOURO - NÃO INFORMADO OU DESLOCADO',
+ 11: 'CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO',
+ 12: 'SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)',
+ 13: 'ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO',
+ 14: 'NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA',
+ 15: 'NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO',
+ 18: 'DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA',
+ 19: 'OCORRÊNCIA - OCORRÊNCIA INVÁLIDA',
+ 21: 'AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO',
+ 22: 'CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)',
+ 26: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA',
+ 27: 'CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA',
+ 29: 'CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA',
+ 30: 'ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA',
+ 31: 'AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)',
+ 35: 'VALOR DO IOF - IOF MAIOR QUE 5%',
+ 36: 'QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO',
+ 37: 'CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS',
+ 42: 'NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA',
+ 52: 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE',
+ 53: 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM',
+ 54: 'DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS',
+ 55: 'DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA',
+ 56: 'DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA',
+ 57: 'DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS',
+ 60: 'ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO',
+ 61: 'JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO',
+ 62: 'DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO',
+ 63: 'DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO',
+ 64: 'DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA',
+ 65: 'TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)',
+ 66: 'DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)',
+ 67: 'VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO',
+ 68: 'CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA',
+ 69: 'CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ 70: 'AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO',
+ 78: 'AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO',
+ 80: 'AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)',
+ 81: 'AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ',
+ 82: 'DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ 83: 'VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO',
+ 84: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO',
+ 85: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO',
+ 86: 'TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO',
+ 87: 'AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO',
+ 90: 'NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS',
+ 97: 'SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8',
+ 98: 'FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO',
+ 99: 'FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE',
}
@@ -340,17 +340,17 @@ def _lote_400(self, evento, lote_id):
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
'str_motiv_b':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[0:1]]
- if evento.erros[0:1] else '',
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[0:2])]
+ if evento.erros[0:2] else '',
'str_motiv_c':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[2:3]]
- if evento.erros[2:3] else '',
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[2:4])]
+ if evento.erros[2:4] else '',
'str_motiv_d':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[4:5]]
- if evento.erros[4:5] else '',
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[4:6])]
+ if evento.erros[4:6] else '',
'str_motiv_e':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[evento.erros[6:7]]
- if evento.erros[6:7] else '',
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[6:8])]
+ if evento.erros[6:8] else '',
'valor_pagamento': evento.valor_principal,
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
From bc576680201e8b6726dc7e4d10a598b94551a613 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Thu, 13 Jun 2019 17:17:08 -0300
Subject: [PATCH 103/612] =?UTF-8?q?[ADD]=20Restaurando=20=C3=BAltimo=20est?=
=?UTF-8?q?ado=20do=20CNAB=20ap=C3=B3s=20cancelamento=20da=20Ordem=20de=20?=
=?UTF-8?q?Pagamento?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_payment_order.py | 1 +
.../models/bank_payment_line.py | 24 +++++++++++++++++++
.../views/bank_payment_line.xml | 1 +
3 files changed, 26 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index a8f30ef51d2f..8dd8bd724cf4 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -86,6 +86,7 @@ def _prepare_bank_payment_line(self, paylines):
result['numero_documento'] = paylines.numero_documento
result['identificacao_titulo_empresa'] = \
paylines.identificacao_titulo_empresa
+ result['ultimo_estado_cnab'] = paylines.move_line_id.state_cnab
return result
def _generate_payment_file(self):
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 9b1fa7f04b25..6586f0721838 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -6,6 +6,8 @@
from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \
AVISO_FAVORECIDO
+from .account_move_line import ESTADOS_CNAB
+
class BankPaymentLine(models.Model):
_inherit = 'bank.payment.line'
@@ -104,6 +106,28 @@ def default_get(self, fields_list):
mensagem_erro_exportacao = fields.Char(
string=u'Mensagem de erro',
)
+ ultimo_estado_cnab = fields.Selection(
+ selection=ESTADOS_CNAB,
+ string=u'Último Estado do CNAB',
+ help=u'Último Estado do CNAB antes da confirmação de '
+ u'pagamento nas Ordens de Pagamento',
+ )
+
+ @api.multi
+ def unlink(self):
+ for record in self:
+ if not record.ultimo_estado_cnab:
+ continue
+
+ move_line_id = \
+ self.env['account.move.line'].search(
+ [('identificacao_titulo_empresa',
+ '=',
+ record.identificacao_titulo_empresa)]
+ )
+ move_line_id.state_cnab = record.ultimo_estado_cnab
+
+ return super(BankPaymentLine, self).unlink()
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index 413930550a0a..9f1a612dace7 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -11,6 +11,7 @@
+
From fb8eab668955103ee70a227f36ce5d5e3d33fec9 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Thu, 13 Jun 2019 17:19:53 -0300
Subject: [PATCH 104/612] [ADD] Novo estado CNAB -> Adicionada para Baixa
---
.../models/account_move_line.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 14bbd48991f4..6d5773530ad4 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -15,6 +15,7 @@
ESTADOS_CNAB = [
('draft', u'Inicial'),
('added', u'Adicionada à ordem de pagamento'),
+ ('added_paid', u'Adicionada para Baixa'),
('exported', u'Exportada'),
('exporting_error', u'Erro ao exportar'),
('accepted', u'Aceita'),
@@ -31,7 +32,7 @@
]
-class AccounMoveLine(models.Model):
+class AccountMoveLine(models.Model):
_inherit = "account.move.line"
state_cnab = fields.Selection(
@@ -55,7 +56,7 @@ class AccounMoveLine(models.Model):
@api.multi
def _prepare_payment_line_vals(self, payment_order):
- vals = super(AccounMoveLine, self)._prepare_payment_line_vals(
+ vals = super(AccountMoveLine, self)._prepare_payment_line_vals(
payment_order
)
vals['nosso_numero'] = self.nosso_numero
@@ -71,8 +72,13 @@ def create_payment_line_from_move_line(self, payment_order):
:param payment_order:
:return:
"""
- self.write({'state_cnab': 'added'})
- return super(AccounMoveLine, self).create_payment_line_from_move_line(
+ state_cnab = 'added'
+ if self.invoice_id.state == 'paid':
+ state_cnab = 'added_paid'
+
+ self.state_cnab = state_cnab
+
+ return super(AccountMoveLine, self).create_payment_line_from_move_line(
payment_order
)
From 47c53e8c5232f087d0c4661bfd74c45765951cd9 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Thu, 13 Jun 2019 17:43:56 -0300
Subject: [PATCH 105/612] =?UTF-8?q?[ADD]=20Emiss=C3=A3o=20de=20arquivo=20R?=
=?UTF-8?q?emessa=20com=20C=C3=B3d.Ocorr=C3=AAncia=2034=20BAIXA=20POR=20TE?=
=?UTF-8?q?R=20SIDO=20PAGO=20DIRETAMENTE=20AO=20BENEFICI=C3=81RIO?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../febraban/cnab_400/bancos/itau.py | 13 ++++-
.../models/__init__.py | 1 +
.../models/account_invoice.py | 57 +++++++++++++++++++
.../models/account_move_line.py | 4 ++
.../models/account_payment.py | 17 ++++++
5 files changed, 91 insertions(+), 1 deletion(-)
create mode 100644 l10n_br_account_payment_cobranca/models/account_payment.py
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index e67e8b6f6435..582a2d96ed68 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -66,6 +66,17 @@ def _prepare_cobranca(self, line):
"""
sacado_endereco = self.retorna_endereco(line.partner_id.id)
+ move_line_id = \
+ line.env['account.move.line'].search([
+ ('identificacao_titulo_empresa', '=',
+ line.identificacao_titulo_empresa)
+ ])
+
+ # TODO: Guardar estrutura com códigos de ocorrências
+ identificacao_ocorrencia = 1
+ if move_line_id and move_line_id.state_cnab == 'added_paid':
+ identificacao_ocorrencia = 34
+
vals = {
'identificacao_titulo_empresa': line.identificacao_titulo_empresa,
'nosso_numero': self.convert_int(line.nosso_numero),
@@ -87,7 +98,7 @@ def _prepare_cobranca(self, line):
self.order.payment_mode_id.boleto_carteira
),
'carteira_cod': self.order.payment_mode_id.boleto_modalidade,
- 'identificacao_ocorrencia': 1,
+ 'identificacao_ocorrencia': identificacao_ocorrencia,
'vencimento_titulo': self.format_date(
line.date),
'valor_titulo': Decimal(str(line.amount_currency)).quantize(
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index 671b81dd8565..96d0ae1de531 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -3,6 +3,7 @@
from . import account_invoice
from . import account_move_line
+from . import account_payment
from . import account_payment_line
from . import account_payment_mode
from . import account_payment_order
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 85476dd9017c..64c322e40128 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -65,6 +65,63 @@ def action_move_create(self):
return result
+
+ @api.multi
+ def create_account_payment_line_baixa(self):
+
+ for inv in self:
+
+ applicable_lines = inv.move_id.line_ids.filtered(
+ lambda x: (
+ x.payment_mode_id.payment_order_ok and
+ x.account_id.internal_type in ('receivable', 'payable')
+ )
+ )
+
+ if not applicable_lines:
+ raise UserError(_(
+ 'No Payment Line created for invoice %s because '
+ 'it\'s internal type isn\'t receivable or payable.') %
+ inv.number)
+
+ payment_modes = applicable_lines.mapped('payment_mode_id')
+ if not payment_modes:
+ raise UserError(_(
+ "No Payment Mode on invoice %s") % inv.number)
+
+ result_payorder_ids = []
+ apoo = self.env['account.payment.order']
+ for payment_mode in payment_modes:
+ payorder = apoo.search([
+ ('payment_mode_id', '=', payment_mode.id),
+ ('state', '=', 'draft')
+ ], limit=1)
+
+ new_payorder = False
+ if not payorder:
+ payorder = apoo.create(inv._prepare_new_payment_order(
+ payment_mode
+ ))
+ new_payorder = True
+ result_payorder_ids.append(payorder.id)
+ action_payment_type = payorder.payment_type
+ count = 0
+ for line in applicable_lines.filtered(
+ lambda x: x.payment_mode_id == payment_mode
+ ):
+ line.create_payment_line_from_move_line(payorder)
+ count += 1
+ if new_payorder:
+ inv.message_post(_(
+ '%d payment lines added to the new draft payment '
+ 'order %s which has been automatically created.')
+ % (count, payorder.name))
+ else:
+ inv.message_post(_(
+ '%d payment lines added to the existing draft '
+ 'payment order %s.')
+ % (count, payorder.name))
+
@api.multi
def invoice_validate(self):
result = super(AccountInvoice, self).invoice_validate()
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 6d5773530ad4..f0ff5ce022ba 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -63,6 +63,10 @@ def _prepare_payment_line_vals(self, payment_order):
vals['numero_documento'] = self.numero_documento
vals['identificacao_titulo_empresa'] = \
self.identificacao_titulo_empresa
+
+ if self.invoice_id.state == 'paid':
+ vals['amount_currency'] = self.credit or self.debit
+
return vals
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/account_payment.py b/l10n_br_account_payment_cobranca/models/account_payment.py
new file mode 100644
index 000000000000..bef93bfccffd
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_payment.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# © 2012 KMEE INFORMATICA LTDA
+# @author Daniel Sadamo Hirayama
+# @author Hugo Uchôas Borges
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, models
+
+
+class AccountPayment(models.Model):
+ _inherit = 'account.payment'
+
+ @api.multi
+ def post(self):
+ super(AccountPayment, self).post()
+ for record in self:
+ record.invoice_ids.create_account_payment_line_baixa()
From 21cf864b18bb00b9a251f93cb31b858d293de36d Mon Sep 17 00:00:00 2001
From: Daniel Sadamo Hirayama
Date: Fri, 14 Jun 2019 11:08:56 -0300
Subject: [PATCH 106/612] [FIX]Preenche com 0 o campo numero documento (seu
numero, no arquivo cnab)
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 64c322e40128..250a1ef5753b 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -35,7 +35,8 @@ def action_move_create(self):
# inv.transaction_id = sequence
for index, interval in enumerate(inv.move_line_receivable_id):
- inv_number = inv.get_invoice_fiscal_number().split('/')[-1]
+ inv_number = inv.get_invoice_fiscal_number().split(
+ '/')[-1].zfill(8)
numero_documento = (
inv_number + '/' + str(index + 1).zfill(2)
)
From 1f1a08bd1b38cb518463f598516e159e6930352d Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 14 Jun 2019 17:38:04 -0300
Subject: [PATCH 107/612] =?UTF-8?q?[ADD]=20Data=20da=20Ocorr=C3=AAncia=20E?=
=?UTF-8?q?vento=20do=20CNAB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab_evento.py | 7 +++++--
.../views/l10n_br_cnab_retorno_view.xml | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 3fa201a63c5d..fa5b6678bc38 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -17,8 +17,11 @@ class L10nBrCnabEvento(models.Model):
string="Bank Payment Line",
comodel_name="bank.payment.line",
)
- data_real_pagamento = fields.Datetime(
- string="Data Real do Pagamento"
+ data_real_pagamento = fields.Date(
+ string="Data do Crédito"
+ )
+ data_ocorrencia = fields.Date(
+ string="Data da Ocorrência"
)
favorecido_conta_bancaria_id = fields.Many2one(
string=u"Conta Bancária",
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index c096011655c8..22be0a37fbee 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -45,6 +45,7 @@
+
@@ -69,6 +70,8 @@
+
Date: Fri, 14 Jun 2019 17:42:49 -0300
Subject: [PATCH 108/612] [IMP] Melhorias no processamento do arquivo de
retorno
---
.../models/l10n_br_cnab.py | 61 +++++++++++++------
1 file changed, 42 insertions(+), 19 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index c654b2bf321b..3ff002240cfe 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -325,7 +325,14 @@ def _lote_400(self, evento, lote_id):
vals_evento = {
'bank_payment_line_id': bank_payment_line_id.id,
- 'data_ocorrencia': evento.data_ocorrencia,
+ 'data_ocorrencia':
+ datetime.strptime(
+ str(evento.data_ocorrencia), STR_EVENTO_FORMAT)
+ if evento.data_ocorrencia else '',
+ 'data_real_pagamento':
+ datetime.strptime(
+ str(evento.data_credito), STR_EVENTO_FORMAT)
+ if evento.data_credito else '',
# 'segmento': evento.servico_segmento,
# 'favorecido_nome': evento.nome_pagador,
# 'favorecido_conta_bancaria': lote_bank_account_id,
@@ -339,16 +346,16 @@ def _lote_400(self, evento, lote_id):
# CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
- 'str_motiv_b':
+ 'str_motiv_a':
CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[0:2])]
if evento.erros[0:2] else '',
- 'str_motiv_c':
+ 'str_motiv_b':
CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[2:4])]
if evento.erros[2:4] else '',
- 'str_motiv_d':
+ 'str_motiv_c':
CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[4:6])]
if evento.erros[4:6] else '',
- 'str_motiv_e':
+ 'str_motiv_d':
CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[6:8])]
if evento.erros[6:8] else '',
'valor_pagamento': evento.valor_principal,
@@ -380,7 +387,7 @@ def _lote_400(self, evento, lote_id):
else:
bank_state = 'baixa_liquidacao'
else:
- cnab_event_id.str_motiv_a = codigo_ocorrencia + \
+ cnab_event_id.str_motiv_e = codigo_ocorrencia + \
': Ocorrência não tratada'
if cnab_state:
@@ -392,18 +399,31 @@ def _lote_400(self, evento, lote_id):
)
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
- if bank_state == 'liquidado' and invoice.state == 'open':
+ if bank_state == 'liquidada' and invoice.state == 'open':
line_values.append(
(0, 0,
{
- 'name' : evento.nosso_numero,
- 'credit' : float(evento.valor_principal),
- 'account_id' : invoice.account_id.id,
- 'journal_id' :
+ 'name': evento.nosso_numero,
+ 'nosso_numero': evento.nosso_numero,
+ 'numero_documento': evento.numero_documento,
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
+ 'credit': float(evento.valor_principal),
+ 'account_id': invoice.account_id.id,
+ 'journal_id':
bank_payment_line_id.order_id.\
journal_id.id,
- 'date_maturity' : evento.data_ocorrencia,
- 'partner_id' : bank_payment_line_id.\
+ 'date_maturity':
+ datetime.strptime(
+ str(evento.vencimento),
+ STR_EVENTO_FORMAT)
+ if evento.vencimento else '',
+ 'date':
+ datetime.strptime(
+ str(evento.data_ocorrencia),
+ STR_EVENTO_FORMAT)
+ if evento.data_ocorrencia else '',
+ 'partner_id': bank_payment_line_id.\
partner_id.id
}
)
@@ -539,17 +559,20 @@ def processar_arquivo_retorno(self):
lines.append(
(0, 0, {
- 'name':'cobranca',
+ 'name': 'cobranca',
'debit': total_amount,
'account_id': counterpart_account_id,
- 'journal_id':lines[0][2]['journal_id'],
- 'date_maturity':False,
- 'partner_id':False,
+ 'journal_id': lines[0][2]['journal_id'],
+ 'date_maturity': False,
+ 'partner_id': False,
})
)
move = self.env['account.move'].create({
- 'name': 'RetornoCnab_'+ str(datetime.now()),
- 'ref': 'ref',
+ 'name': 'RetornoCnab_' + fields.Datetime.now(),
+ 'ref':
+ 'Retorno Gerado em %s' %
+ datetime.strftime(datetime.strptime(
+ data_arquivo, "%d%m%y"), "%d/%m/%Y"),
'date': str(datetime.now()),
'line_ids': lines,
'journal_id': lines[0][2]['journal_id']
From 973edbed9e54aa26ff1930f631f58f0990c41613 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 14 Jun 2019 17:43:08 -0300
Subject: [PATCH 109/612] [ADD] Reprocessamento do arquivo de retorno
---
.../models/account_move_line.py | 8 ++
.../models/l10n_br_cnab.py | 135 ++++++++++++++++++
.../views/l10n_br_cnab_retorno_view.xml | 3 +
3 files changed, 146 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index f0ff5ce022ba..967bdd81e2ea 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -109,3 +109,11 @@ def generate_boleto(self):
)
boleto_list.append(boleto.boleto)
return boleto_list
+
+ @api.multi
+ def _update_check(self):
+
+ if self._context.get("reprocessing"):
+ return True
+
+ return super(AccountMoveLine, self)._update_check()
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 3ff002240cfe..60fb290e7984 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -8,6 +8,7 @@
from datetime import datetime
from ..constantes import CODIGO_OCORRENCIAS
from ..febraban.cnab import Cnab
+from odoo.exceptions import UserError
from odoo import api, models, fields
@@ -92,6 +93,9 @@
10,
]
+RETORNOS_TRATADOS = \
+ [RETORNO_400_CONFIRMADA, RETORNO_400_REJEITADA, RETORNO_400_LIQUIDACAO, RETORNO_400_BAIXA]
+
# CODIGO_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
CODIGO_REGISTROS_REJEITADOS_CNAB400 = {
3: 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
@@ -237,6 +241,8 @@
93: 'TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO',
}
+STR_EVENTO_FORMAT = "%d%m%y"
+
class L10nBrHrCnab(models.Model):
_name = "l10n_br.cnab"
@@ -509,6 +515,135 @@ def _lote_240(self, evento, lote_id):
for payment_line in bank_payment_line_id.payment_line_ids:
payment_line.move_line_id.state_cnab = cnab_state
+ def _reprocessa_lote_240(self, evento, lote_id):
+ raise NotImplementedError("FALTA FAZER")
+
+ def _reprocessa_lote_400(self, evento, lote_id):
+ bank_payment_line_id = self.env['bank.payment.line'].search([(
+ 'identificacao_titulo_empresa', '=',
+ evento.identificacao_titulo_empresa
+ )], limit=1)
+
+ cnab_event_id = self.env['l10n_br.cnab.evento'].search([
+ ('nosso_numero', '=', evento.nosso_numero),
+ ])
+
+ vals_evento = {
+ 'data_real_pagamento':
+ datetime.strptime(
+ str(evento.data_ocorrencia), STR_EVENTO_FORMAT)
+ if evento.data_ocorrencia else '',
+ 'nosso_numero': str(evento.nosso_numero),
+ 'ocorrencias':
+ CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'seu_numero': evento.numero_documento,
+ 'str_motiv_a':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[0:2])]
+ if evento.erros[0:2] else '',
+ 'str_motiv_b':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[2:4])]
+ if evento.erros[2:4] else '',
+ 'str_motiv_c':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[4:6])]
+ if evento.erros[4:6] else '',
+ 'str_motiv_d':
+ CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[6:8])]
+ if evento.erros[6:8] else '',
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
+ }
+
+ if not cnab_event_id:
+ raise UserError("A linha de 'nosso_numero' %s não possui evento "
+ "criado. Esse lote não foi processado "
+ "corretamente." % evento.nosso_numero)
+ cnab_event_id.write(vals_evento)
+
+ amount = 0.0
+ codigo_ocorrencia = evento.codigo_ocorrencia
+ if codigo_ocorrencia and bank_payment_line_id:
+
+ if not any(codigo_ocorrencia in x for x in RETORNOS_TRATADOS):
+ cnab_event_id.str_motiv_e = codigo_ocorrencia + \
+ ': Ocorrência não tratada'
+
+ for pay_order_line_id in bank_payment_line_id.payment_line_ids:
+ pay_order_line_id.move_line_id.nosso_numero = str(
+ evento.nosso_numero
+ )
+ debit_move_line = pay_order_line_id.move_line_id
+ credit_move_line = self.env['account.move.line'].search([
+ '|',
+ ('nosso_numero', '=', evento.nosso_numero),
+ ('name', '=', evento.nosso_numero),
+ ('credit', '>', 0),
+ ])
+
+ if not credit_move_line and debit_move_line.full_reconcile_id:
+ credit_move_line = \
+ debit_move_line.full_reconcile_id.\
+ reconciled_line_ids - debit_move_line
+
+ if not credit_move_line:
+ raise UserError(
+ "Não foi encontrada uma linha correspondente para a "
+ "linha de nosso_numero: %s" % evento.nosso_numero)
+
+ line_values = {
+ 'name': evento.nosso_numero,
+ 'nosso_numero': evento.nosso_numero,
+ 'numero_documento': evento.numero_documento,
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
+ 'date_maturity':
+ datetime.strptime(
+ str(evento.vencimento),
+ STR_EVENTO_FORMAT)
+ if evento.vencimento else '',
+ 'date':
+ datetime.strptime(
+ str(evento.data_ocorrencia),
+ STR_EVENTO_FORMAT)
+ if evento.data_ocorrencia else '',
+ }
+
+ credit_move_line.with_context(
+ reprocessing=True).write(line_values)
+
+ @api.multi
+ def reprocessar_arquivo_retorno(self):
+ cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
+ data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
+ self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
+
+ self.bank_account_id = self._busca_conta(
+ arquivo_parser.header.codigo_do_banco,
+ arquivo_parser.header.cedente_agencia,
+ arquivo_parser.header.cedente_conta,
+ )
+
+ self.num_lotes = len(arquivo_parser.lotes)
+ self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
+ for lote in arquivo_parser.lotes:
+
+ header = lote.header or arquivo_parser.header
+ trailer = lote.trailer or arquivo_parser.trailer
+
+ # TODO: Pesquisar lote
+ lote_id = self.lote_id and self.lote_id[0]
+ for evento in lote.eventos:
+ if not lote_id:
+ lote_id, lote_bank_account_id = self._cria_lote(
+ header, lote, evento, trailer)
+
+ if cnab_type == '240':
+ self._reprocessa_lote_240(evento, lote_id)
+ else:
+ self._reprocessa_lote_400(evento, lote_id)
+
+ #TODO: Verificar necessidade de atualizar dados do Account.Move
+ return self.write({'state': 'done'})
+
@api.multi
def processar_arquivo_retorno(self):
cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 22be0a37fbee..5a55a6972359 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -159,6 +159,9 @@
string="Processar Retorno" type="object"
class="oe_highlight"
attrs="{'invisible': [('state', '=', 'done')]}"/>
+
From 9884717082f447c692ab8ee9a6541ad774c14260 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 14 Jun 2019 21:16:55 -0300
Subject: [PATCH 110/612] [IMP] Melhorias no processamento de retorno e
reprocessamento
---
.../models/l10n_br_cnab.py | 75 ++++++++++++-------
1 file changed, 48 insertions(+), 27 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 60fb290e7984..63a6c9c1ac1b 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -96,8 +96,8 @@
RETORNOS_TRATADOS = \
[RETORNO_400_CONFIRMADA, RETORNO_400_REJEITADA, RETORNO_400_LIQUIDACAO, RETORNO_400_BAIXA]
-# CODIGO_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
-CODIGO_REGISTROS_REJEITADOS_CNAB400 = {
+# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
+COD_REGISTROS_REJEITADOS_CNAB400 = {
3: 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
4: 'ESTADO - SIGLA DO ESTADO INVÁLIDA',
5: 'DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO',
@@ -333,11 +333,11 @@ def _lote_400(self, evento, lote_id):
'bank_payment_line_id': bank_payment_line_id.id,
'data_ocorrencia':
datetime.strptime(
- str(evento.data_ocorrencia), STR_EVENTO_FORMAT)
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT)
if evento.data_ocorrencia else '',
'data_real_pagamento':
datetime.strptime(
- str(evento.data_credito), STR_EVENTO_FORMAT)
+ str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
if evento.data_credito else '',
# 'segmento': evento.servico_segmento,
# 'favorecido_nome': evento.nome_pagador,
@@ -353,16 +353,16 @@ def _lote_400(self, evento, lote_id):
# 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
# ocorrencias[0] else '',
'str_motiv_a':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[0:2])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
if evento.erros[0:2] else '',
'str_motiv_b':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[2:4])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
if evento.erros[2:4] else '',
'str_motiv_c':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[4:6])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
if evento.erros[4:6] else '',
'str_motiv_d':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[6:8])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
'valor_pagamento': evento.valor_principal,
'identificacao_titulo_empresa':
@@ -421,12 +421,12 @@ def _lote_400(self, evento, lote_id):
journal_id.id,
'date_maturity':
datetime.strptime(
- str(evento.vencimento),
+ str(evento.vencimento).zfill(6),
STR_EVENTO_FORMAT)
if evento.vencimento else '',
'date':
datetime.strptime(
- str(evento.data_ocorrencia),
+ str(evento.data_ocorrencia).zfill(6),
STR_EVENTO_FORMAT)
if evento.data_ocorrencia else '',
'partner_id': bank_payment_line_id.\
@@ -524,40 +524,54 @@ def _reprocessa_lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa
)], limit=1)
+
cnab_event_id = self.env['l10n_br.cnab.evento'].search([
- ('nosso_numero', '=', evento.nosso_numero),
+ ('lote_id', '=', lote_id.id),
+ ('bank_payment_line_id', '!=', False),
+ ('bank_payment_line_id', '=', bank_payment_line_id.id),
])
vals_evento = {
- 'data_real_pagamento':
+ 'data_ocorrencia':
datetime.strptime(
- str(evento.data_ocorrencia), STR_EVENTO_FORMAT)
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT)
if evento.data_ocorrencia else '',
+ 'data_real_pagamento':
+ datetime.strptime(
+ str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
+ if evento.data_credito else '',
'nosso_numero': str(evento.nosso_numero),
'ocorrencias':
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
'seu_numero': evento.numero_documento,
'str_motiv_a':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[0:2])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
if evento.erros[0:2] else '',
'str_motiv_b':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[2:4])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
if evento.erros[2:4] else '',
'str_motiv_c':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[4:6])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
if evento.erros[4:6] else '',
'str_motiv_d':
- CODIGO_REGISTROS_REJEITADOS_CNAB400[int(evento.erros[6:8])]
+ COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
}
if not cnab_event_id:
- raise UserError("A linha de 'nosso_numero' %s não possui evento "
- "criado. Esse lote não foi processado "
- "corretamente." % evento.nosso_numero)
- cnab_event_id.write(vals_evento)
+ # raise UserError("A linha de 'nosso_numero' %s não possui evento "
+ # "criado. Esse lote não foi processado "
+ # "corretamente." % evento.nosso_numero)
+ vals_evento.update({
+ 'bank_payment_line_id': bank_payment_line_id.id,
+ 'lote_id': lote_id.id,
+ 'valor_pagamento': evento.valor_principal,
+ })
+ cnab_event_id = cnab_event_id.create(vals_evento)
+ else:
+ cnab_event_id.write(vals_evento)
amount = 0.0
codigo_ocorrencia = evento.codigo_ocorrencia
@@ -567,10 +581,12 @@ def _reprocessa_lote_400(self, evento, lote_id):
cnab_event_id.str_motiv_e = codigo_ocorrencia + \
': Ocorrência não tratada'
+ bank_payment_line_id.nosso_numero = str(evento.nosso_numero)
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
pay_order_line_id.move_line_id.nosso_numero = str(
evento.nosso_numero
)
+ pay_order_line_id.nosso_numero = str(evento.nosso_numero)
debit_move_line = pay_order_line_id.move_line_id
credit_move_line = self.env['account.move.line'].search([
'|',
@@ -585,9 +601,10 @@ def _reprocessa_lote_400(self, evento, lote_id):
reconciled_line_ids - debit_move_line
if not credit_move_line:
- raise UserError(
- "Não foi encontrada uma linha correspondente para a "
- "linha de nosso_numero: %s" % evento.nosso_numero)
+ return
+ # raise UserError(
+ # "Não foi encontrada uma linha correspondente para a "
+ # "linha de nosso_numero: %s" % evento.nosso_numero)
line_values = {
'name': evento.nosso_numero,
@@ -597,12 +614,12 @@ def _reprocessa_lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa,
'date_maturity':
datetime.strptime(
- str(evento.vencimento),
+ str(evento.vencimento).zfill(6),
STR_EVENTO_FORMAT)
if evento.vencimento else '',
'date':
datetime.strptime(
- str(evento.data_ocorrencia),
+ str(evento.data_ocorrencia).zfill(6),
STR_EVENTO_FORMAT)
if evento.data_ocorrencia else '',
}
@@ -629,8 +646,12 @@ def reprocessar_arquivo_retorno(self):
header = lote.header or arquivo_parser.header
trailer = lote.trailer or arquivo_parser.trailer
- # TODO: Pesquisar lote
lote_id = self.lote_id and self.lote_id[0]
+ bankless_line_id = \
+ lote_id.evento_id.filtered(
+ lambda e: not e.bank_payment_line_id)
+ bankless_line_id.unlink()
+
for evento in lote.eventos:
if not lote_id:
lote_id, lote_bank_account_id = self._cria_lote(
From 26a33cb5b8d44ac527587062c9c0d63c6de5dbef Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 14 Jun 2019 21:17:25 -0300
Subject: [PATCH 111/612] =?UTF-8?q?[ADD]=20Bot=C3=A3o=20na=20Tree=20para?=
=?UTF-8?q?=20reprocessar=20v=C3=A1rios=20arquivos=20de=20retorno?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 8 ++++++++
.../views/l10n_br_cnab_retorno_view.xml | 14 ++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 63a6c9c1ac1b..fd188fc44bae 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -627,6 +627,14 @@ def _reprocessa_lote_400(self, evento, lote_id):
credit_move_line.with_context(
reprocessing=True).write(line_values)
+ @api.model
+ def reprocessar_retorno_multi(self):
+ active_ids = self._context.get("active_ids")
+
+ for cnab_id in self.browse(active_ids):
+ if cnab_id.state in ['done']:
+ cnab_id.reprocessar_arquivo_retorno()
+
@api.multi
def reprocessar_arquivo_retorno(self):
cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 5a55a6972359..0bb2adbe5289 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -202,6 +202,20 @@
+
+ Reprocessar Retorno
+
+ code
+ action = env.get('l10n_br.cnab').reprocessar_retorno_multi()
+
+
+
+ Reprocessar Retorno
+ client_action_multi
+ l10n_br.cnab
+
+
+
Importar Retorno Bancário CNAB
ir.actions.act_window
From 320d2123665e89c847124ca474f09fa5e9756bd0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 26 Jul 2019 14:01:53 -0300
Subject: [PATCH 112/612] [ADD] l10n_br_cnab - display_name
---
.../models/l10n_br_cnab.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index fd188fc44bae..e6449ed08206 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -248,6 +248,12 @@ class L10nBrHrCnab(models.Model):
_name = "l10n_br.cnab"
_rec_name = "display_name"
+ display_name = fields.Char(
+ compute='_compute_display_name',
+ store=True,
+ index=True
+ )
+
arquivo_retorno = fields.Binary(
string='Arquivo Retorno'
)
@@ -283,6 +289,11 @@ class L10nBrHrCnab(models.Model):
default="draft",
)
+ @api.one
+ @api.depends('name')
+ def _compute_display_name(self):
+ self.display_name = self.name
+
def _busca_conta(self, banco, agencia, conta):
return self.env['res.partner.bank'].search([
# ('acc_number', '=', str(banco)),
From f1bf12ce90e213cb1955e8b0377c31562e0aaafe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 26 Jul 2019 14:02:53 -0300
Subject: [PATCH 113/612] [ADD] l10n_br_cnab - Campo name sendo calculado a
partir do nome do arquivo de retorno
---
.../models/l10n_br_cnab.py | 34 +++++++++++++++----
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index e6449ed08206..f83cb7c25a0e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -5,6 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
+import re
from datetime import datetime
from ..constantes import CODIGO_OCORRENCIAS
from ..febraban.cnab import Cnab
@@ -767,15 +768,36 @@ def processar_arquivo_retorno(self):
return self.write({'state': 'done'})
+ def _get_name(self, data, filename):
+ cnab_ids = self.search([('data', '=', data)], order='id desc')
+ cnab_idx = 1
+ if cnab_ids:
+ search_result = \
+ filter(lambda x: x is not None,
+ [re.search(r'\((\d)\)', name) for name in self.search(
+ [('data', '=', data), ('id', '!=', self.id)],
+ order='id desc'
+ ).mapped('name')])
+ if search_result:
+ cnab_idx = max(int(result.group(1))
+ for result in search_result) + 1
+
+ cnab_name = "{}({}){}".format(
+ data, cnab_idx, ' - ' + filename if filename else '')
+ return cnab_name
+
@api.multi
- def _get_name(self, data):
- cnab_ids = self.search([('data', '=', data)])
- return data + " - " + (
- str(len(cnab_ids) + 1) if cnab_ids else '1'
- )
+ def write(self, vals):
+ if any(v in vals for v in ['data', 'filename']):
+ data = vals.get('data') or self.data
+ filename = vals.get('filename') or self.filename
+
+ name = self._get_name(data, filename)
+ vals.update({'name': name})
+ return super(L10nBrHrCnab, self).write(vals)
@api.model
def create(self, vals):
- name = self._get_name(vals['data'])
+ name = self._get_name(vals.get('data'), vals.get('filename'))
vals.update({'name': name})
return super(L10nBrHrCnab, self).create(vals)
From 50ae9b4bc9dbeaebd85674521d6cdba38aa143e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 26 Jul 2019 14:19:15 -0300
Subject: [PATCH 114/612] [ADD] Campo filename para manter nome do arquivo de
retorno
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 +++
.../views/l10n_br_cnab_retorno_view.xml | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index f83cb7c25a0e..dafa0b9d285f 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -258,6 +258,9 @@ class L10nBrHrCnab(models.Model):
arquivo_retorno = fields.Binary(
string='Arquivo Retorno'
)
+ filename = fields.Char(
+ string="Filename"
+ )
bank_account_id = fields.Many2one(
string="Conta cedente",
comodel_name="res.partner.bank",
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 0bb2adbe5289..cd8f386be9de 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -172,8 +172,9 @@
-
+
From 7860ec5bc8283aa1eacc1b4a9573b62bc0245a83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 26 Jul 2019 15:01:17 -0300
Subject: [PATCH 115/612] =?UTF-8?q?[FIX]=20Importa=C3=A7=C3=A3o=20de=20cna?=
=?UTF-8?q?b-retorno=20com=20ocorr=C3=AAncia=20n=C3=A3o=20tratada?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index dafa0b9d285f..fb5dd6c4b835 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -408,7 +408,7 @@ def _lote_400(self, evento, lote_id):
else:
bank_state = 'baixa_liquidacao'
else:
- cnab_event_id.str_motiv_e = codigo_ocorrencia + \
+ cnab_event_id.str_motiv_e = str(codigo_ocorrencia) + \
': Ocorrência não tratada'
if cnab_state:
From 02494c5c59c72ab304e2a4feb4b7c5238c0bdb88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 26 Jul 2019 15:01:44 -0300
Subject: [PATCH 116/612] [ADD] Baixa Simples no selection situacao_pagamento
---
l10n_br_account_payment_cobranca/models/account_move_line.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 967bdd81e2ea..6818da2fc704 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -28,6 +28,7 @@
('aberta', 'Aberta'),
('paga', 'Paga'),
('liquidada', 'Liquidada'),
+ ('baixa', 'Baixa Simples'),
('baixa_liquidacao', 'Baixa por Liquidação em Dinheiro'),
]
From 18ba4c78e78900dc695c19b8017358d390e76457 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 14 Aug 2019 18:13:03 -0300
Subject: [PATCH 117/612] =?UTF-8?q?[FIX]=20Campo=20instru=C3=A7=C3=B5es=20?=
=?UTF-8?q?no=20Boleto?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../febraban/boleto/document.py | 1 +
.../models/account_move_line.py | 25 ++++++++++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
index dd78233d7734..2c3052041800 100644
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
@@ -86,6 +86,7 @@ def _payment_mode(self, payment_mode_id):
self.boleto.especie_documento = payment_mode_id.boleto_modalidade
self.boleto.aceite = payment_mode_id.boleto_aceite
self.boleto.carteira = str(payment_mode_id.boleto_carteira)
+ self.boleto.instrucoes.append(payment_mode_id.instrucoes)
def _cedente(self, company):
"""
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 6818da2fc704..5eeab4ac8c43 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -93,18 +93,19 @@ def generate_boleto(self):
for move_line in self:
- if move_line.state_cnab != 'accepted':
- if move_line.state_cnab == 'not_accepted':
- raise UserError(_(
- u'O arquivo CNAB relacionado a essa nota foi '
- u'transmitido com erro, é necessário corrigi-lo '
- u'e reenviá-lo'
- ))
- raise UserError(_(
- u'É necessário transmitir e processar o retorno do CNAB'
- u' referente a essa nota para garantir que o '
- u'boleto está registrado no banco'
- ))
+ # if move_line.state_cnab != 'accepted':
+ # if move_line.state_cnab == 'not_accepted':
+ # raise UserError(_(
+ # u'O arquivo CNAB relacionado a essa nota foi '
+ # u'transmitido com erro, é necessário corrigi-lo '
+ # u'e reenviá-lo'
+ # ))
+ # raise UserError(_(
+ # u'É necessário transmitir e processar o retorno do CNAB'
+ # u' referente a essa nota para garantir que o '
+ # u'boleto está registrado no banco'
+ # ))
+
boleto = Boleto.getBoleto(
move_line, move_line.nosso_numero
)
From 2e3189a4bb8b24275f4c0e3f03d5ae13fb25f218 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 16 Aug 2019 10:27:03 -0300
Subject: [PATCH 118/612] [FIX] Num Sequencial de Registro do Trailer da
Remessa CNAB 400
---
l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
index 90c7a2cdcbd3..92ace1c8071d 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
@@ -305,8 +305,8 @@ def remessa(self, order):
for line in order.bank_line_ids:
try:
self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
- self.arquivo.trailer.num_seq_registro = self.controle_linha
self.controle_linha += 1
+ self.arquivo.trailer.num_seq_registro = self.controle_linha
line.is_erro_exportacao = False
line.mensagem_erro_exportacao = ''
From ea2cf573b37a5592bf607649867cc68f60a540e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 16 Aug 2019 15:41:18 -0300
Subject: [PATCH 119/612] [ADD] Valor da Linha - CNAB400
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 ++
l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py | 3 +++
.../views/l10n_br_cnab_retorno_view.xml | 3 +++
3 files changed, 8 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index fb5dd6c4b835..6919b2e1cf55 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -380,6 +380,7 @@ def _lote_400(self, evento, lote_id):
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
'valor_pagamento': evento.valor_principal,
+ 'valor': float(evento.valor / 100),
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
}
@@ -583,6 +584,7 @@ def _reprocessa_lote_400(self, evento, lote_id):
'bank_payment_line_id': bank_payment_line_id.id,
'lote_id': lote_id.id,
'valor_pagamento': evento.valor_principal,
+ 'valor': float(evento.valor / 100),
})
cnab_event_id = cnab_event_id.create(vals_evento)
else:
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index fa5b6678bc38..acd00a68171e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -71,6 +71,9 @@ class L10nBrCnabEvento(models.Model):
tipo_moeda = fields.Char(
string=u"Tipo de Moeda"
)
+ valor = fields.Float(
+ string="Valor da Linha"
+ )
valor_pagamento = fields.Float(
string="Valor do Pagamento"
)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index cd8f386be9de..9846927c249b 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -53,6 +53,7 @@
+
@@ -84,6 +85,8 @@
attrs="{'readonly': [('state', '=', 'done')]}"/>
+
Date: Fri, 16 Aug 2019 15:44:51 -0300
Subject: [PATCH 120/612] =?UTF-8?q?[FIX]=20Convers=C3=A3o=20para=20Float?=
=?UTF-8?q?=20-=20Valores=20das=20linhas=20CNAB400?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 6919b2e1cf55..b8a7562cfb2c 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -329,7 +329,7 @@ def _cria_lote(self, header, lote, evento, trailer):
'servico_operacao': header.literal_retorno,
'tipo_servico': header.literal_servico,
'qtd_registros': trailer.totais_quantidade_registros,
- 'total_valores': float(trailer.valor_total_titulos / 100),
+ 'total_valores': float(trailer.valor_total_titulos) / 100,
'cnab_id': self.id,
}
@@ -380,7 +380,7 @@ def _lote_400(self, evento, lote_id):
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
'valor_pagamento': evento.valor_principal,
- 'valor': float(evento.valor / 100),
+ 'valor': float(evento.valor) / 100,
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
}
@@ -584,7 +584,7 @@ def _reprocessa_lote_400(self, evento, lote_id):
'bank_payment_line_id': bank_payment_line_id.id,
'lote_id': lote_id.id,
'valor_pagamento': evento.valor_principal,
- 'valor': float(evento.valor / 100),
+ 'valor': float(evento.valor) / 100,
})
cnab_event_id = cnab_event_id.create(vals_evento)
else:
From aef6f0498455d71dfd5eaf68abe8a43468819a00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 21 Aug 2019 16:50:06 -0300
Subject: [PATCH 121/612] [FIX] codigo_ocorrencia
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index b8a7562cfb2c..3c41e52da8af 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -595,7 +595,7 @@ def _reprocessa_lote_400(self, evento, lote_id):
if codigo_ocorrencia and bank_payment_line_id:
if not any(codigo_ocorrencia in x for x in RETORNOS_TRATADOS):
- cnab_event_id.str_motiv_e = codigo_ocorrencia + \
+ cnab_event_id.str_motiv_e = str(codigo_ocorrencia) + \
': Ocorrência não tratada'
bank_payment_line_id.nosso_numero = str(evento.nosso_numero)
From 60c5ad3864331c57cc463e095b64cee66061bf48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 21 Aug 2019 16:50:22 -0300
Subject: [PATCH 122/612] [ADD] Partner + Invoice CNAB Evento
---
.../models/l10n_br_cnab.py | 23 +++++++++++--------
.../models/l10n_br_cnab_evento.py | 16 +++++++++----
.../views/l10n_br_cnab_retorno_view.xml | 6 +++++
3 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 3c41e52da8af..1f18c6d9d5e8 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -540,7 +540,6 @@ def _reprocessa_lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa
)], limit=1)
-
cnab_event_id = self.env['l10n_br.cnab.evento'].search([
('lote_id', '=', lote_id.id),
('bank_payment_line_id', '!=', False),
@@ -576,16 +575,20 @@ def _reprocessa_lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa,
}
+ vals_evento.update({
+ 'bank_payment_line_id': cnab_event_id.bank_payment_line_id.id or
+ bank_payment_line_id.id,
+ 'invoice_id': cnab_event_id.invoice_id.id or
+ bank_payment_line_id.
+ payment_line_ids[:1].move_line_id.invoice_id.id,
+ 'lote_id': cnab_event_id.lote_id.id or lote_id.id,
+ 'partner_id': bank_payment_line_id.partner_id.id,
+ 'valor_pagamento': cnab_event_id.valor_pagamento or
+ evento.valor_principal,
+ 'valor': cnab_event_id.valor or float(evento.valor) / 100,
+ })
+
if not cnab_event_id:
- # raise UserError("A linha de 'nosso_numero' %s não possui evento "
- # "criado. Esse lote não foi processado "
- # "corretamente." % evento.nosso_numero)
- vals_evento.update({
- 'bank_payment_line_id': bank_payment_line_id.id,
- 'lote_id': lote_id.id,
- 'valor_pagamento': evento.valor_principal,
- 'valor': float(evento.valor) / 100,
- })
cnab_event_id = cnab_event_id.create(vals_evento)
else:
cnab_event_id.write(vals_evento)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index acd00a68171e..85a28225df25 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -31,6 +31,14 @@ class L10nBrCnabEvento(models.Model):
string="Favorecido",
comodel_name="res.partner"
)
+ identificacao_titulo_empresa = fields.Char(
+ string="Identificação do Título da Empresa",
+ required=False,
+ )
+ invoice_id = fields.Many2one(
+ comodel_name='account.invoice',
+ string='Fatura',
+ )
lote_id = fields.Many2one(
string="Lote",
comodel_name="l10n_br.cnab.lote",
@@ -41,6 +49,10 @@ class L10nBrCnabEvento(models.Model):
ocorrencias = fields.Char(
string=u"Ocorrências"
)
+ partner_id = fields.Many2one(
+ comodel_name='res.partner',
+ string='Associado',
+ )
segmento = fields.Char(
string="Segmento"
)
@@ -77,7 +89,3 @@ class L10nBrCnabEvento(models.Model):
valor_pagamento = fields.Float(
string="Valor do Pagamento"
)
- identificacao_titulo_empresa = fields.Char(
- string="Identificação do Título da Empresa",
- required=False,
- )
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 9846927c249b..4156d7aeb32f 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -45,6 +45,8 @@
+
+
@@ -71,6 +73,10 @@
+
+
Date: Thu, 22 Aug 2019 15:32:35 -0300
Subject: [PATCH 123/612] [ADD] account.invoice + res.partner no processamento
do retorno do CNAB
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 1f18c6d9d5e8..c1c3d25670f2 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -357,10 +357,13 @@ def _lote_400(self, evento, lote_id):
# 'segmento': evento.servico_segmento,
# 'favorecido_nome': evento.nome_pagador,
# 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'invoice_id': bank_payment_line_id.
+ payment_line_ids[:1].move_line_id.invoice_id.id,
'lote_id': lote_id.id,
'nosso_numero': str(evento.nosso_numero),
'ocorrencias':
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'partner_id': bank_payment_line_id.partner_id.id,
'seu_numero': evento.numero_documento,
# 'tipo_moeda': evento.credito_moeda_tipo,
# 'str_motiv_a':
From 6eea1600ac99edad20e950c47dc9a3850e6ba7a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 23 Aug 2019 18:54:27 -0300
Subject: [PATCH 124/612] [ADD] Mais campos informativos sobre o arquivo de
retorno
---
.../models/l10n_br_cnab.py | 50 ++++++++++-----
.../models/l10n_br_cnab_evento.py | 34 ++++++++++
.../views/l10n_br_cnab_retorno_view.xml | 63 ++++++++-----------
3 files changed, 93 insertions(+), 54 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index c1c3d25670f2..52611a36fe9a 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -357,12 +357,16 @@ def _lote_400(self, evento, lote_id):
# 'segmento': evento.servico_segmento,
# 'favorecido_nome': evento.nome_pagador,
# 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
'invoice_id': bank_payment_line_id.
payment_line_ids[:1].move_line_id.invoice_id.id,
+ 'juros_mora_multa': float(evento.juros_mora_multa) / 100,
'lote_id': lote_id.id,
'nosso_numero': str(evento.nosso_numero),
'ocorrencias':
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'outros_creditos': float(evento.outros_creditos) / 100,
'partner_id': bank_payment_line_id.partner_id.id,
'seu_numero': evento.numero_documento,
# 'tipo_moeda': evento.credito_moeda_tipo,
@@ -382,10 +386,12 @@ def _lote_400(self, evento, lote_id):
'str_motiv_d':
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
- 'valor_pagamento': evento.valor_principal,
+ 'tarifa_cobranca': float(evento.tarifa_cobranca),
'valor': float(evento.valor) / 100,
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
+ 'valor_abatimento': float(evento.valor_abatimento) / 100,
+ 'valor_desconto': float(evento.valor_desconto) / 100,
+ 'valor_iof': float(evento.valor_iof) / 100,
+ 'valor_pagamento': evento.valor_principal,
}
cnab_event_id = self.env['l10n_br.cnab.evento'].create(vals_evento)
@@ -550,6 +556,9 @@ def _reprocessa_lote_400(self, evento, lote_id):
])
vals_evento = {
+ 'bank_payment_line_id':
+ cnab_event_id.bank_payment_line_id.id or
+ bank_payment_line_id.id,
'data_ocorrencia':
datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT)
@@ -558,9 +567,20 @@ def _reprocessa_lote_400(self, evento, lote_id):
datetime.strptime(
str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
if evento.data_credito else '',
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
+ 'invoice_id': cnab_event_id.invoice_id.id or
+ bank_payment_line_id.payment_line_ids[:1].
+ move_line_id.invoice_id.id,
+ 'juros_mora_multa': cnab_event_id.juros_mora_multa or
+ float(evento.juros_mora_multa) / 100,
+ 'lote_id': cnab_event_id.lote_id.id or lote_id.id,
'nosso_numero': str(evento.nosso_numero),
'ocorrencias':
CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'outros_creditos': cnab_event_id.outros_creditos or
+ float(evento.outros_creditos) / 100,
+ 'partner_id': bank_payment_line_id.partner_id.id,
'seu_numero': evento.numero_documento,
'str_motiv_a':
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
@@ -574,22 +594,18 @@ def _reprocessa_lote_400(self, evento, lote_id):
'str_motiv_d':
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8] else '',
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- }
-
- vals_evento.update({
- 'bank_payment_line_id': cnab_event_id.bank_payment_line_id.id or
- bank_payment_line_id.id,
- 'invoice_id': cnab_event_id.invoice_id.id or
- bank_payment_line_id.
- payment_line_ids[:1].move_line_id.invoice_id.id,
- 'lote_id': cnab_event_id.lote_id.id or lote_id.id,
- 'partner_id': bank_payment_line_id.partner_id.id,
+ 'tarifa_cobranca': cnab_event_id.tarifa_cobranca or
+ float(evento.tarifa_cobranca),
+ 'valor': cnab_event_id.valor or float(evento.valor) / 100,
+ 'valor_abatimento': cnab_event_id.valor_abatimento or
+ float(evento.valor_abatimento) / 100,
+ 'valor_desconto': cnab_event_id.valor_desconto or
+ float(evento.valor_desconto) / 100,
+ 'valor_iof': cnab_event_id.valor_iof or
+ float(evento.valor_iof) / 100,
'valor_pagamento': cnab_event_id.valor_pagamento or
evento.valor_principal,
- 'valor': cnab_event_id.valor or float(evento.valor) / 100,
- })
+ }
if not cnab_event_id:
cnab_event_id = cnab_event_id.create(vals_evento)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 85a28225df25..1b98900913dc 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -39,6 +39,9 @@ class L10nBrCnabEvento(models.Model):
comodel_name='account.invoice',
string='Fatura',
)
+ juros_mora_multa = fields.Float(
+ string=u"Juros de Mora/Multa"
+ )
lote_id = fields.Many2one(
string="Lote",
comodel_name="l10n_br.cnab.lote",
@@ -49,6 +52,9 @@ class L10nBrCnabEvento(models.Model):
ocorrencias = fields.Char(
string=u"Ocorrências"
)
+ outros_creditos = fields.Float(
+ string=u"Outros Créditos"
+ )
partner_id = fields.Many2one(
comodel_name='res.partner',
string='Associado',
@@ -83,9 +89,37 @@ class L10nBrCnabEvento(models.Model):
tipo_moeda = fields.Char(
string=u"Tipo de Moeda"
)
+ tarifa_cobranca = fields.Float(
+ string=u'Tarifa',
+ )
valor = fields.Float(
string="Valor da Linha"
)
+ valor_abatimento = fields.Float(
+ string="Valor do Abatimento",
+ help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ estes campos são retornados zerados(apesar de corretamente registrados
+ no Itaú). Se concedidos após a entrada, retornam com os valores
+ do desconto ou abatimento.
+ Na liquidação, desconto e abatimento retornam somados no campo
+ desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
+ estes valores poderão retornar separados, conforme mostra o
+ indicador 36.4 do Item 5 - Condições Personalizadas."""
+ )
+ valor_desconto = fields.Float(
+ string="Valor do Desconto",
+ help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ estes campos são retornados zerados(apesar de corretamente registrados
+ no Itaú). Se concedidos após a entrada, retornam com os valores
+ do desconto ou abatimento.
+ Na liquidação, desconto e abatimento retornam somados no campo
+ desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
+ estes valores poderão retornar separados, conforme mostra o
+ indicador 36.4 do Item 5 - Condições Personalizadas."""
+ )
+ valor_iof = fields.Float(
+ string="Valor do IOF"
+ )
valor_pagamento = fields.Float(
string="Valor do Pagamento"
)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 4156d7aeb32f..04a9e331488d 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -57,6 +57,7 @@
+
@@ -71,46 +72,34 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
From 3687c0fdc7a34534d25e5d15ad1a4f095bcc7e13 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Mon, 26 Aug 2019 17:21:56 -0300
Subject: [PATCH 125/612] =?UTF-8?q?[FIX]=20Reconcilia=C3=A7=C3=A3o=20de=20?=
=?UTF-8?q?faturas=20com=20taxa=20banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 101 ++++++++++--------
1 file changed, 56 insertions(+), 45 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 52611a36fe9a..1ae6029be5e1 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -318,14 +318,6 @@ def _cria_lote(self, header, lote, evento, trailer):
vals = {
'account_bank_id': lote_bank_account_id.id,
- # 'empresa_inscricao_numero':
- # str(header.empresa_inscricao_numero),
- # 'empresa_inscricao_tipo':
- # TIPO_INSCRICAO_EMPRESA[header.empresa_inscricao_tipo],
- # 'servico_operacao': TIPO_OPERACAO[header.servico_operacao],
- # 'tipo_servico': TIPO_SERVICO[str(header.servico_servico)],
- # 'mensagem': header.mensagem1,
- # 'total_valores': float(trailer.somatoria_valores),
'servico_operacao': header.literal_retorno,
'tipo_servico': header.literal_servico,
'qtd_registros': trailer.totais_quantidade_registros,
@@ -354,9 +346,6 @@ def _lote_400(self, evento, lote_id):
datetime.strptime(
str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
if evento.data_credito else '',
- # 'segmento': evento.servico_segmento,
- # 'favorecido_nome': evento.nome_pagador,
- # 'favorecido_conta_bancaria': lote_bank_account_id,
'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
'invoice_id': bank_payment_line_id.
@@ -369,11 +358,6 @@ def _lote_400(self, evento, lote_id):
'outros_creditos': float(evento.outros_creditos) / 100,
'partner_id': bank_payment_line_id.partner_id.id,
'seu_numero': evento.numero_documento,
- # 'tipo_moeda': evento.credito_moeda_tipo,
- # 'str_motiv_a':
- # CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
- # 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
- # ocorrencias[0] else '',
'str_motiv_a':
COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
if evento.erros[0:2] else '',
@@ -431,37 +415,63 @@ def _lote_400(self, evento, lote_id):
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
if bank_state == 'liquidada' and invoice.state == 'open':
- line_values.append(
- (0, 0,
- {
- 'name': evento.nosso_numero,
- 'nosso_numero': evento.nosso_numero,
- 'numero_documento': evento.numero_documento,
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- 'credit': float(evento.valor_principal),
- 'account_id': invoice.account_id.id,
- 'journal_id':
- bank_payment_line_id.order_id.\
- journal_id.id,
- 'date_maturity':
- datetime.strptime(
- str(evento.vencimento).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.vencimento else '',
- 'date':
- datetime.strptime(
- str(evento.data_ocorrencia).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.data_ocorrencia else '',
- 'partner_id': bank_payment_line_id.\
- partner_id.id
- }
- )
- )
+ line_dict = {
+ 'name': evento.nosso_numero,
+ 'nosso_numero': evento.nosso_numero,
+ 'numero_documento': evento.numero_documento,
+ 'identificacao_titulo_empresa':
+ evento.identificacao_titulo_empresa,
+ 'credit': float(evento.valor_principal) +
+ float(evento.tarifa_cobranca),
+ 'account_id': invoice.account_id.id,
+ 'journal_id':
+ bank_payment_line_id.order_id.\
+ journal_id.id,
+ 'date_maturity':
+ datetime.strptime(
+ str(evento.vencimento).zfill(6),
+ STR_EVENTO_FORMAT)
+ if evento.vencimento else '',
+ 'date':
+ datetime.strptime(
+ str(evento.data_ocorrencia).zfill(6),
+ STR_EVENTO_FORMAT)
+ if evento.data_ocorrencia else '',
+ 'partner_id': bank_payment_line_id.\
+ partner_id.id
+ }
+
+ line_values.append((0, 0, line_dict))
amount += float(evento.valor_principal)
invoices.append(invoice)
+ invoice_line_tax_id = \
+ invoice.invoice_line_ids.filtered(
+ lambda i: i.price_subtotal == float(
+ evento.tarifa_cobranca))
+ if invoice_line_tax_id:
+ # amount += float(evento.tarifa_cobranca)
+
+ line_dict_tarifa = dict(line_dict)
+ line_dict_tarifa.update({
+ 'name': str(evento.nosso_numero) + ' - Tarifa',
+ 'credit': 0,
+ 'debit': float(evento.tarifa_cobranca),
+ })
+ line_values.append((0, 0, line_dict_tarifa))
+
+ # TODO: Juros / iof / Desconto / Abatimento /
+ # Outros Créditos
+ # if evento.juros_mora_multa:
+ # amount += float(evento.juros_mora_multa)
+ # line_dict_multa = dict(line_dict)
+ # line_dict_multa.update({
+ # 'name': str(evento.nosso_numero) + ' - Juros',
+ # 'credit': float(evento.juros_mora_multa),
+ # 'account_id': invoice.account_id.id,
+ # })
+ # line_values.append((0, 0, line_dict_multa))
+
if bank_state:
move_line.situacao_pagamento = bank_state
if cnab_state:
@@ -788,7 +798,8 @@ def processar_arquivo_retorno(self):
inv_move_lines = inv.move_line_receivable_id
pay_move_lines = move.line_ids.filtered(
lambda x: x.account_id == inv_move_lines.account_id and
- x.partner_id == inv_move_lines.partner_id
+ x.partner_id == inv_move_lines.partner_id and
+ x.name == inv_move_lines.transaction_ref
)
move_lines = pay_move_lines | inv_move_lines
move_lines.reconcile()
From 2012fdd71228c70df22613a4b4b5d078fd67c9ce Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 27 Aug 2019 10:02:42 -0300
Subject: [PATCH 126/612] =?UTF-8?q?[ADD]=20Contas=20padr=C3=A3o=20no=20mod?=
=?UTF-8?q?o=20de=20pagamento?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_payment_mode.py | 10 ++++++++++
.../models/l10n_br_cnab.py | 7 ++++++-
.../views/account_payment_mode.xml | 6 ++++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 84e15268420c..3827674a1fa7 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -105,6 +105,16 @@ class PaymentMode(models.Model):
u'O nosso número pode ser gerado pelo banco.',
default=True
)
+ default_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string=u'Conta Padrão',
+ help=u'Conta padrão para recebimentos'
+ )
+ default_tax_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string=u'Conta Padrão para Taxas Bancárias',
+ help=u'Conta padrão para recebimentos de Taxas Bancárias'
+ )
@api.constrains('boleto_type', 'boleto_carteira',
'boleto_modalidade', 'boleto_convenio',
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 1ae6029be5e1..f366e593c58c 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -423,7 +423,9 @@ def _lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa,
'credit': float(evento.valor_principal) +
float(evento.tarifa_cobranca),
- 'account_id': invoice.account_id.id,
+ 'account_id': invoice.payment_mode_id.
+ default_account_id.id or
+ invoice.account_id.id,
'journal_id':
bank_payment_line_id.order_id.\
journal_id.id,
@@ -457,6 +459,9 @@ def _lote_400(self, evento, lote_id):
'name': str(evento.nosso_numero) + ' - Tarifa',
'credit': 0,
'debit': float(evento.tarifa_cobranca),
+ 'account_id': invoice.payment_mode_id.
+ default_tax_account_id.id or
+ invoice.account_id.id,
})
line_values.append((0, 0, line_dict_tarifa))
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 2c31b05ca854..c5d9fb82619f 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -41,6 +41,12 @@
+
+
+
+
+
+
From dbc088bb8d76885c4fd9d623a418998a254017ee Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 27 Aug 2019 13:17:56 -0300
Subject: [PATCH 127/612] =?UTF-8?q?[ADD]=20Valida=C3=A7=C3=A3o=20para=20n?=
=?UTF-8?q?=C3=A3o=20importa=C3=A7=C3=A3o=20de=20retornos=20Cnab=20repetid?=
=?UTF-8?q?os?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/l10n_br_cnab.py | 22 +++++++++++++++++++
.../views/l10n_br_cnab_retorno_view.xml | 8 ++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index f366e593c58c..ad27f248858a 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -18,6 +18,7 @@
STATE = [
('draft', 'Novo'),
('done', 'Processado'),
+ ('error', 'Erro no Processamento')
]
TIPO_OPERACAO = {
@@ -273,6 +274,12 @@ class L10nBrHrCnab(models.Model):
data_arquivo = fields.Datetime(
string="Data Criação no Banco",
)
+ sequencial_arquivo = fields.Char(
+ string="Sequencial do Arquivo",
+ )
+ motivo_erro = fields.Char(
+ string="Motivo do Erro",
+ )
lote_id = fields.One2many(
string="Lotes",
comodel_name="l10n_br.cnab.lote",
@@ -693,6 +700,7 @@ def reprocessar_retorno_multi(self):
def reprocessar_arquivo_retorno(self):
cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
+ self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
self.bank_account_id = self._busca_conta(
@@ -735,8 +743,22 @@ def processar_arquivo_retorno(self):
# u"Este não é um arquivo de retorno!"
# )
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
+ self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
+ if self.search([
+ ('data_arquivo', '=', self.data_arquivo),
+ ('sequencial_arquivo', '=', self.sequencial_arquivo),
+ ('id', '!=', self.id)]):
+ self.state = 'error'
+ self.motivo_erro = u"O arquivo %s, de %s - sequencial %s, " \
+ u"ja se encontra importado." % \
+ (self.filename,
+ datetime.strftime(fields.Datetime.from_string(
+ self.data_arquivo), "%d/%m/%Y"),
+ self.sequencial_arquivo)
+ return
+
self.bank_account_id = self._busca_conta(
arquivo_parser.header.codigo_do_banco,
arquivo_parser.header.cedente_agencia,
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 04a9e331488d..46f98ec0aa6e 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -13,9 +13,11 @@
+
+
@@ -173,13 +175,17 @@
+
+ attrs="{'readonly': [('state', 'in', ('done', 'error'))]}"/>
+
From b061a9cb1b478a7ae8f36c5dab2f9b4d7f073934 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 27 Aug 2019 13:33:01 -0300
Subject: [PATCH 128/612] [REF] data_arquivo Datetime -> Date
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index ad27f248858a..8f6fb70ec81e 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -271,7 +271,7 @@ class L10nBrHrCnab(models.Model):
required=True,
default=datetime.now()
)
- data_arquivo = fields.Datetime(
+ data_arquivo = fields.Date(
string="Data Criação no Banco",
)
sequencial_arquivo = fields.Char(
From 9a8b3c4f6a0cc2945b8dca041c1f18ceecf3dab8 Mon Sep 17 00:00:00 2001
From: Luis Malta
Date: Fri, 13 Sep 2019 13:53:58 -0300
Subject: [PATCH 129/612] [ADD] Filtros no modelo l10n_br.cnab.evento
---
.../views/l10n_br_cnab_evento_views.xml | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
index cbd6512ec0a1..d3fa950f8ee6 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
@@ -24,6 +24,36 @@
l10n_br.cnab.evento
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Date: Sat, 14 Sep 2019 00:11:20 -0300
Subject: [PATCH 130/612] =?UTF-8?q?[ADD]=20Campos=20na=20empresa=20para=20?=
=?UTF-8?q?configura=C3=A7=C3=A3o=20da=20API=20do=20Banco?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/res_company.py | 39 +++++++++++++++++++
.../views/res_company.xml | 12 ++++++
2 files changed, 51 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index 5191b28467b8..24c776888918 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -27,6 +27,45 @@ class ResCompany(models.Model):
string=u'Sequência do Nosso Número'
)
+ environment = fields.Selection(
+ string=u'Ambiente',
+ selection=[
+ ('1', 'HOMOLOGAÇÃO'),
+ ('2', 'PRODUÇÃO'),
+ ],
+ default='1',
+ )
+
+ client_id = fields.Char(
+ string=u'ID do Cliente',
+ )
+
+ client_secret = fields.Char(
+ string=u'Segredo',
+ )
+
+ itau_key = fields.Char(
+ string=u'Chave',
+ )
+
+ api_endpoint = fields.Char(
+ string=u'API ENDPOINT',
+ )
+
+ raiz_endpoint = fields.Char(
+ string=u'RAIZ ENDPOINT',
+ )
+
+ api_itau_token = fields.Char(
+ string=u'Itaú API Token',
+ readonly=True,
+ )
+
+ api_itau_token_due_datetime = fields.Datetime(
+ string=u'Validade do Token',
+ readonly=True,
+ )
+
@api.multi
def get_own_number_sequence(self):
self.ensure_one()
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index 871306304b01..c5221cf69746 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -15,6 +15,18 @@
'required': [('own_number_type', '==', '0')]}"/>
+
+
+
+
+
+
+
+
+
+
+
+
From e906c2435b7897127fa371346230feb8f28499a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Sat, 14 Sep 2019 00:12:31 -0300
Subject: [PATCH 131/612] =?UTF-8?q?[FIX]=20Valida=C3=A7=C3=A3o=20na=20impr?=
=?UTF-8?q?ess=C3=A3o=20de=20boletos?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_move_line.py | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 5eeab4ac8c43..c7773e54b6de 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -88,23 +88,22 @@ def create_payment_line_from_move_line(self, payment_order):
)
@api.multi
- def generate_boleto(self):
+ def generate_boleto(self, validate=True):
boleto_list = []
for move_line in self:
- # if move_line.state_cnab != 'accepted':
- # if move_line.state_cnab == 'not_accepted':
- # raise UserError(_(
- # u'O arquivo CNAB relacionado a essa nota foi '
- # u'transmitido com erro, é necessário corrigi-lo '
- # u'e reenviá-lo'
- # ))
- # raise UserError(_(
- # u'É necessário transmitir e processar o retorno do CNAB'
- # u' referente a essa nota para garantir que o '
- # u'boleto está registrado no banco'
- # ))
+ if validate and move_line.state_cnab not in \
+ ['accepted', 'accepted_hml']:
+ if move_line.state_cnab == 'not_accepted':
+ raise UserError(_(
+ u'Essa fatura foi transmitida com erro ao banco, '
+ u'é necessário corrigí-la e reenviá-la.'
+ ))
+ raise UserError(_(
+ u'Antes de imprimir o boleto é necessário transmitir a '
+ u'fatura para registro no banco.'
+ ))
boleto = Boleto.getBoleto(
move_line, move_line.nosso_numero
From aa85d9807214dd500b798ab9562b7caef5adb245 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Sat, 14 Sep 2019 00:14:38 -0300
Subject: [PATCH 132/612] [ADD] Estrutura para registro de faturas no banco via
API
---
.../models/account_invoice.py | 81 ++++++++++++++++++-
.../models/account_move_line.py | 1 +
.../views/account_move_line.xml | 13 +++
3 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 250a1ef5753b..e7aa15a5cfca 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -5,8 +5,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
+import json
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
-from odoo import models, api, _
+from pyboleto.bank_api.itau import ApiItau
+
+from odoo import models, fields, api, _
from odoo.exceptions import UserError
from ..constantes import (
SEQUENCIAL_EMPRESA, SEQUENCIAL_FATURA, SEQUENCIAL_CARTEIRA
@@ -18,6 +23,80 @@
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
+ eval_state_cnab = fields.Selection(
+ string=u'Estado CNAB',
+ related='move_line_receivable_id.state_cnab',
+ readonly=True,
+ )
+
+ @api.multi
+ def register_invoice_api(self):
+ for record in self:
+ receivable_ids = record.mapped('move_line_receivable_id')
+ if not receivable_ids:
+ return False
+
+ boleto_list = receivable_ids.generate_boleto(validate=False)
+ if not boleto_list:
+ raise UserError(_(
+ u"Não foi possível registrar as faturas pela API"
+ ))
+
+ company_id = record.partner_id.company_id
+
+ client_id = company_id.client_id
+ client_secret = company_id.client_secret
+ itau_key = company_id.itau_key
+ endpoint = company_id.api_endpoint
+ barcode_endpoint = company_id.raiz_endpoint
+ environment = company_id.environment
+
+ token = company_id.api_itau_token
+ if not token or company_id.api_itau_token_due_datetime > \
+ fields.Datetime.now():
+ try:
+ token_request = ApiItau.generate_api_key(
+ client_id, client_secret, endpoint)
+ token_request_dict = json.loads(token_request.content)
+ token = token_request_dict.get('access_token')
+ company_id.api_itau_token_due_datetime = \
+ fields.Datetime.context_timestamp(
+ record, datetime.now()) + relativedelta(
+ seconds=token_request_dict.get('expires_in'))
+
+ except Exception as e:
+ raise UserError(_(
+ u"Erro na obtenção do Token de acesso à Api. %s"
+ ) % str(e))
+ finally:
+ # TODO: Criar modelo para guardar registros no banco
+ # Se basear no modelo da NFE para registro de atividades
+ # TODO: Registrar o POST + resposta no banco
+ pass
+
+ for boleto in boleto_list:
+ ApiItau.convert_to(boleto, tipo_ambiente=environment)
+ response = boleto.post(token, itau_key, barcode_endpoint)
+ try:
+ if response.ok:
+ # ambiente = 1 --> HML
+ if boleto.tipo_ambiente == '1':
+ receivable_ids.state_cnab = 'accepted_hml'
+ # PROD
+ else:
+ receivable_ids.state_cnab = 'accepted'
+ receivable_ids.situacao_pagamento = 'aberta'
+ else:
+ receivable_ids.state_cnab = 'not_accepted'
+ response_dict = json.loads(response.content)
+
+ # TODO: No caso de erro durante o processamento
+ # Listar quais campos deram problema o melhor
+ # descrito possível
+ finally:
+ # TODO: Registrar o POST + resposta no banco
+ pass
+
@api.multi
def get_invoice_fiscal_number(self):
""" Como neste modulo nao temos o numero do documento fiscal,
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index c7773e54b6de..8577533a01a4 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -19,6 +19,7 @@
('exported', u'Exportada'),
('exporting_error', u'Erro ao exportar'),
('accepted', u'Aceita'),
+ ('accepted_hml', u'Aceita em Homologação'),
('not_accepted', u'Não aceita pelo banco'),
('done', u'Concluído'),
]
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index b8ac3fdc6b56..508400f754fd 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -42,6 +42,19 @@
+
From bdca9c087b0a299fae127846383a0c6df603744b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 17 Sep 2019 13:57:06 -0300
Subject: [PATCH 133/612] [REF] XML account_invoice movido para novo arquivo
---
.../__manifest__.py | 1 +
.../views/account_invoice.xml | 31 +++++++++++++++++++
.../views/account_move_line.xml | 28 -----------------
3 files changed, 32 insertions(+), 28 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/views/account_invoice.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 88c65a4423ee..00eb9abab3a2 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -33,6 +33,7 @@
'views/account_payment_order.xml',
'views/account_payment_line.xml',
'views/bank_payment_line.xml',
+ 'views/account_invoice.xml',
'views/account_move_line.xml',
'views/l10n_br_cnab_retorno_view.xml',
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
new file mode 100644
index 000000000000..a854afc93df8
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ view.l10n_br_account.invoice.form.form.inherit
+
+ account.invoice
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index 508400f754fd..2bd69e99bc28 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -29,32 +29,4 @@
-
-
-
- view.l10n_br_account.invoice.form.form.inherit
-
- account.invoice
-
-
-
-
-
-
-
-
-
From 8b3bc25b71dd8f3856f246ad05d05ec505e38b72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 17 Sep 2019 13:57:55 -0300
Subject: [PATCH 134/612] =?UTF-8?q?[ADD]=20Novo=20modelo=20para=20salvar?=
=?UTF-8?q?=20opera=C3=A7=C3=B5es=20banc=C3=A1rias=20via=20API?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../__manifest__.py | 1 +
.../models/__init__.py | 1 +
.../models/bank_api_operation.py | 156 ++++++++++++++++++
.../views/account_invoice.xml | 5 +
.../views/bank_api_operation_views.xml | 75 +++++++++
5 files changed, 238 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/models/bank_api_operation.py
create mode 100644 l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 00eb9abab3a2..9fc63ad725f4 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -34,6 +34,7 @@
'views/account_payment_line.xml',
'views/bank_payment_line.xml',
'views/account_invoice.xml',
+ 'views/bank_api_operation_views.xml',
'views/account_move_line.xml',
'views/l10n_br_cnab_retorno_view.xml',
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index 96d0ae1de531..fba73552a3b8 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -7,6 +7,7 @@
from . import account_payment_line
from . import account_payment_mode
from . import account_payment_order
+from . import bank_api_operation
from . import bank_payment_line
from . import l10n_br_cnab
from . import l10n_br_cnab_evento
diff --git a/l10n_br_account_payment_cobranca/models/bank_api_operation.py b/l10n_br_account_payment_cobranca/models/bank_api_operation.py
new file mode 100644
index 000000000000..dfa6ebe1a60a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/bank_api_operation.py
@@ -0,0 +1,156 @@
+# -*- coding: utf-8 -*-
+
+import json
+
+from odoo import api, fields, models
+
+SELECTION_OPERATION_TYPE = [
+ ('post', 'Post'),
+ ('token_request', 'Requisição de Token'),
+ ('invoice_register', 'Registro de Fatura'),
+ ('invoice_query', 'Consulta de Fatura'),
+ ('invoice_update', 'Atualização de Fatura'),
+ ('invoice_cancellation', 'Baixa de Fatura'),
+]
+
+
+class BankAPIOperation(models.Model):
+ _name = 'bank.api.operation'
+ _rec_name = 'name'
+
+ name = fields.Char(
+ string='Nome',
+ compute='_compute_name',
+ readonly=True,
+ store=True,
+ )
+
+ environment = fields.Selection(
+ string='Ambiente',
+ selection=[
+ ('1', 'Homologação'),
+ ('2', 'Produção'),
+ ],
+ readonly=True,
+ required=True,
+ )
+
+ @api.multi
+ @api.depends('operation_datetime', 'operation_type')
+ def _compute_name(self):
+ for record in self:
+ name = record.operation_datetime
+ if record.operation_type:
+ name += ' - ' + dict(
+ self._fields['operation_type'].selection).get(
+ record.operation_type)
+ record.name = name
+
+ invoice_id = fields.Many2one(
+ comodel_name='account.invoice',
+ string='Fatura',
+ readonly=True,
+ )
+
+ operation_datetime = fields.Datetime(
+ string='Data da Operação',
+ default=fields.Datetime.now,
+ readonly=True,
+ )
+
+ user_id = fields.Many2one(
+ comodel_name='res.users',
+ string='Usuário',
+ default=lambda self: self.env.uid,
+ readonly=True,
+ )
+
+ operation_type = fields.Selection(
+ string='Tipo da Operação',
+ selection=SELECTION_OPERATION_TYPE,
+ required=True,
+ readonly=True,
+ )
+
+ message_sent = fields.Text(
+ string="Mensagem Enviada",
+ readonly=True,
+ )
+
+ message_received = fields.Text(
+ string="Mensagem Recebida",
+ readonly=True,
+ )
+
+ status = fields.Char(
+ string="Estado",
+ readonly=True,
+ )
+
+ endpoint = fields.Char(
+ string="Endpoint",
+ readonly=True,
+ )
+
+ operation_error_line_ids = fields.One2many(
+ string='Linhas de Erro',
+ comodel_name='bank.api.operation.error.line',
+ inverse_name='operation_id',
+ readonly=True,
+ )
+
+ error_400 = fields.Boolean(
+ string='Erro 400',
+ default=False,
+ readonly=True,
+ )
+
+ def register_post(self, request):
+ self.endpoint = request.request.url
+ self.status = '[%s] - %s' % (request.status_code, request.reason)
+
+ self.message_sent = request.request.body
+ self.message_received = request.content
+
+ if request.status_code == 400:
+ self.error_400 = True
+ content_json = json.loads(request.content)
+ operation_line_model = self.env['bank.api.operation.error.line']
+ for campo in content_json.get('campos'):
+
+ data = {
+ 'operation_id': self.id,
+ 'field_name': campo.get('campo'),
+ 'field_value': '%s (%s)' % (
+ campo.get('valor'), type(campo.get('valor')).__name__),
+ 'error_message': campo.get('mensagem'),
+ }
+ operation_line = operation_line_model.create(data)
+ self.operation_error_line_ids += operation_line
+
+
+class BankAPIOperationErrorLine(models.Model):
+ _name = 'bank.api.operation.error.line'
+ _rec_name = 'field_name'
+
+ operation_id = fields.Many2one(
+ string='Operação Bancária',
+ comodel_name='bank.api.operation',
+ required=True,
+ readonly=True,
+ )
+
+ field_name = fields.Char(
+ string='Nome do Campo',
+ readonly=True,
+ )
+
+ field_value = fields.Char(
+ string='Valor do Campo',
+ readonly=True,
+ )
+
+ error_message = fields.Char(
+ string='Mensagem de Erro',
+ readonly=True,
+ )
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index a854afc93df8..81b872e7527b 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -26,6 +26,11 @@
/>
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
new file mode 100644
index 000000000000..91f49e69f905
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
@@ -0,0 +1,75 @@
+
+
+
+
+ bank.api.operation.tree.view
+ bank.api.operation
+
+
+
+
+
+
+
+
+
+
+
+
+
+ bank.api.operation.form.view
+ bank.api.operation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ action.bank.api.operation
+ ir.actions.act_window
+ bank.api.operation
+ form
+ tree,form
+
+
+
+
+
From c778f319febaadff052dc67eb5be5a167a9abfa9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 17 Sep 2019 13:58:49 -0300
Subject: [PATCH 135/612] =?UTF-8?q?[ADD]=20Cria=C3=A7=C3=A3o=20de=20hist?=
=?UTF-8?q?=C3=B3rico=20das=20opera=C3=A7=C3=B5es=20banc=C3=A1rias=20reali?=
=?UTF-8?q?zadas?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 69 +++++++++++++++----
1 file changed, 57 insertions(+), 12 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index e7aa15a5cfca..fdf0408790ec 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -29,6 +29,34 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ bank_api_operation_ids = fields.One2many(
+ string='Operações Realizadas',
+ comodel_name='bank.api.operation',
+ inverse_name='invoice_id',
+ readonly=True,
+ )
+
+ def create_bank_api_operation(self, request, operation_type=False,
+ environment=False):
+ # 'not request' não é válido para o propósito
+ if request == False:
+ return
+
+ operation_model = self.env['bank.api.operation']
+
+ if not operation_type:
+ operation_type = 'post'
+
+ data = {
+ 'operation_type': operation_type,
+ 'invoice_id': self.id,
+ 'environment': environment,
+ }
+
+ operation_id = operation_model.create(data)
+ operation_id.register_post(request)
+ self.bank_api_operation_ids += operation_id
+
@api.multi
def register_invoice_api(self):
for record in self:
@@ -52,32 +80,40 @@ def register_invoice_api(self):
environment = company_id.environment
token = company_id.api_itau_token
- if not token or company_id.api_itau_token_due_datetime > \
+ if not token or company_id.api_itau_token_due_datetime <= \
fields.Datetime.now():
+ token_request = False
try:
token_request = ApiItau.generate_api_key(
client_id, client_secret, endpoint)
token_request_dict = json.loads(token_request.content)
token = token_request_dict.get('access_token')
+ company_id.api_itau_token = token
company_id.api_itau_token_due_datetime = \
fields.Datetime.context_timestamp(
record, datetime.now()) + relativedelta(
seconds=token_request_dict.get('expires_in'))
except Exception as e:
+ company_id.api_itau_token = ''
+ company_id.api_itau_token_due_datetime = \
+ fields.Datetime.now()
raise UserError(_(
u"Erro na obtenção do Token de acesso à Api. %s"
) % str(e))
finally:
- # TODO: Criar modelo para guardar registros no banco
- # Se basear no modelo da NFE para registro de atividades
- # TODO: Registrar o POST + resposta no banco
- pass
+ record.create_bank_api_operation(
+ token_request,
+ operation_type='token_request',
+ environment=environment,
+ )
+ self._cr.commit()
for boleto in boleto_list:
ApiItau.convert_to(boleto, tipo_ambiente=environment)
- response = boleto.post(token, itau_key, barcode_endpoint)
+ response = False
try:
+ response = boleto.post(token, itau_key, barcode_endpoint)
if response.ok:
# ambiente = 1 --> HML
if boleto.tipo_ambiente == '1':
@@ -88,14 +124,23 @@ def register_invoice_api(self):
receivable_ids.situacao_pagamento = 'aberta'
else:
receivable_ids.state_cnab = 'not_accepted'
- response_dict = json.loads(response.content)
- # TODO: No caso de erro durante o processamento
- # Listar quais campos deram problema o melhor
- # descrito possível
+ except Exception as e:
+ raise UserError(_(
+ u"Erro ao registrar a fatura boleto. Verifique se as "
+ u"configurações da API estão corretas. %s"
+ ) % str(e))
+
finally:
- # TODO: Registrar o POST + resposta no banco
- pass
+ record.create_bank_api_operation(
+ response,
+ operation_type='invoice_register',
+ environment=environment,
+ )
+ self.message_post(_(
+ "Comunicação com o banco via API concluída. Verifique a Aba "
+ "'Operações Bancárias' consultar o resultado do processamento."
+ ))
@api.multi
def get_invoice_fiscal_number(self):
From 708c6b9eb9481ed1c40fef123453b884ad296d7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 17 Sep 2019 14:18:53 -0300
Subject: [PATCH 136/612] =?UTF-8?q?[ADD]=20Permiss=C3=B5es=20de=20acesso?=
=?UTF-8?q?=20=C3=A0=20Api=20Banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/security/ir.model.access.csv | 3 +++
1 file changed, 3 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/security/ir.model.access.csv b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
index 78218cfacd8a..b624831a7622 100644
--- a/l10n_br_account_payment_cobranca/security/ir.model.access.csv
+++ b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
@@ -2,3 +2,6 @@
access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,,1,0,0,0
access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,,1,0
access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,,1,0,0,0
+
+access_bank_api_operation,bank.api.operation,model_bank_api_operation,account.group_account_invoice,1,1,1,1
+access_bank_api_operation_error_line,bank.api.operation,model_bank_api_operation_error_line,account.group_account_invoice,1,1,1,1
From 65afd9667960df0dd91bf2976e723866af9ae05f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 18 Sep 2019 16:08:43 -0300
Subject: [PATCH 137/612] =?UTF-8?q?[ADD]=20Instru=C3=A7=C3=B5es=20de=20cob?=
=?UTF-8?q?ran=C3=A7a=20adicionais=20na=20Fatura?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../febraban/boleto/document.py | 3 ++-
.../models/account_invoice.py | 12 ++++++++++++
.../models/account_move_line.py | 4 ++++
.../views/account_invoice.xml | 10 ++++++++++
.../views/account_move_line.xml | 1 +
5 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
index 2c3052041800..dff26291d506 100644
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
@@ -64,6 +64,8 @@ def getBranchNumber(self):
def _move_line(self, move_line):
self._payment_mode(move_line.payment_mode_id)
+ for instrucao in move_line.instrucoes.split('\n'):
+ self.boleto.instrucoes.append(instrucao)
self.boleto.data_vencimento = datetime.date(datetime.strptime(
move_line.date_maturity, '%Y-%m-%d'))
self.boleto.data_documento = datetime.date(datetime.strptime(
@@ -86,7 +88,6 @@ def _payment_mode(self, payment_mode_id):
self.boleto.especie_documento = payment_mode_id.boleto_modalidade
self.boleto.aceite = payment_mode_id.boleto_aceite
self.boleto.carteira = str(payment_mode_id.boleto_carteira)
- self.boleto.instrucoes.append(payment_mode_id.instrucoes)
def _cedente(self, company):
"""
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index fdf0408790ec..b67e6b59231c 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -29,6 +29,16 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ eval_payment_mode_instrucoes = fields.Text(
+ string=u'Instruções de Cobrança do Modo de Pagamento',
+ related='payment_mode_id.instrucoes',
+ readonly=True,
+ )
+
+ instrucoes = fields.Text(
+ string=u'Instruções de cobrança',
+ )
+
bank_api_operation_ids = fields.One2many(
string='Operações Realizadas',
comodel_name='bank.api.operation',
@@ -187,6 +197,8 @@ def action_move_create(self):
interval.identificacao_titulo_empresa = hex(
interval.id
).upper()
+ interval.instrucoes = '%s\n%s' % (
+ inv.eval_payment_mode_instrucoes, inv.instrucoes)
return result
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 8577533a01a4..bc424de2c381 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -55,6 +55,10 @@ class AccountMoveLine(models.Model):
string=u'Situação do Pagamento',
default='inicial'
)
+ instrucoes = fields.Text(
+ string=u'Instruções de cobrança',
+ readonly=True,
+ )
@api.multi
def _prepare_payment_line_vals(self, payment_order):
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 81b872e7527b..694bcf7affbb 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -27,6 +27,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index 2bd69e99bc28..9b030ab41b28 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -12,6 +12,7 @@
+
From 561c5db84243e7ff8d0282841b2b14e15ae178e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 18 Sep 2019 16:24:59 -0300
Subject: [PATCH 138/612] =?UTF-8?q?[ADD]=20Informa=C3=A7=C3=A3o=20de=20Cob?=
=?UTF-8?q?ran=C3=A7a=20-=20Boleto=20em=20homologa=C3=A7=C3=A3o.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_move_line.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index bc424de2c381..7268e07a9604 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -113,6 +113,12 @@ def generate_boleto(self, validate=True):
boleto = Boleto.getBoleto(
move_line, move_line.nosso_numero
)
+
+ # Se for ambiente de Homologação
+ if move_line.partner_id.company_id.environment == '1':
+ boleto.boleto.instrucoes.append(_(
+ u'Boleto emitido em homologacao! Sem valor fiscal!'))
+
boleto_list.append(boleto.boleto)
return boleto_list
From aa1167dd5043ab363b2e815408a5d3a557401da7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 18 Sep 2019 17:06:39 -0300
Subject: [PATCH 139/612] [ADD] Search View bank_api_operation
---
.../views/bank_api_operation_views.xml | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
index 91f49e69f905..179343166962 100644
--- a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
@@ -16,6 +16,46 @@
+
+ bank.api.operation.search.view
+ bank.api.operation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
bank.api.operation.form.view
bank.api.operation
From ce49dafa496cd79252806b47493c918e2f1d546b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 08:42:42 -0300
Subject: [PATCH 140/612] =?UTF-8?q?[FIX]=20Valida=C3=A7=C3=A3o=20das=20Ins?=
=?UTF-8?q?tru=C3=A7=C3=B5es=20de=20fatura?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../febraban/boleto/document.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
index dff26291d506..0c08218fe262 100644
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
@@ -64,8 +64,7 @@ def getBranchNumber(self):
def _move_line(self, move_line):
self._payment_mode(move_line.payment_mode_id)
- for instrucao in move_line.instrucoes.split('\n'):
- self.boleto.instrucoes.append(instrucao)
+ self._instructions(move_line.instrucoes)
self.boleto.data_vencimento = datetime.date(datetime.strptime(
move_line.date_maturity, '%Y-%m-%d'))
self.boleto.data_documento = datetime.date(datetime.strptime(
@@ -79,6 +78,15 @@ def _move_line(self, move_line):
self.boleto.quantidade = '' # str("%.2f" % move_line.amount_currency)
self.boleto.numero_documento = move_line.numero_documento
+ def _instructions(self, instrucoes):
+ """
+ :param instrucoes:
+ :return:
+ """
+ if instrucoes:
+ for instrucao in instrucoes.split('\n'):
+ self.boleto.instrucoes.append(instrucao)
+
def _payment_mode(self, payment_mode_id):
"""
:param payment_mode:
From cf94f7b406081e2e9ab4770dab336dd257b0b00e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 09:45:30 -0300
Subject: [PATCH 141/612] =?UTF-8?q?[IMP]=20Mensagem=20de=20confirma=C3=A7?=
=?UTF-8?q?=C3=A3o=20de=20utiliza=C3=A7=C3=A3o=20da=20API=20Banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/views/account_invoice.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 694bcf7affbb..7f4d893ec05a 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -18,7 +18,7 @@
string="Registrar Boleto via API" type="object"
groups="base.group_user"
class="oe_highlight" style="background-color:red; text-color:white;"
- confirm="Você está prestes a registrar um boleto diretamente no ITAU"
+ confirm="Você está prestes a registrar uma fatura bancária via API"
attrs="{'invisible': ['|',
('state', '!=', 'open'),
('eval_state_cnab', 'in', ('added_paid', 'accepted', 'done', 'accepted_hml'))
From f82d65c72fcf9179aa7c66c646341fcd39cb604d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 11:10:19 -0300
Subject: [PATCH 142/612] =?UTF-8?q?[ADD]=20situacao=5Fpagamento=20+=20stat?=
=?UTF-8?q?e=5Fcnab=20nas=20vis=C3=B5es=20da=20Fatura?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 8 ++
.../views/account_invoice.xml | 73 +++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index b67e6b59231c..d2ed5466c5c0 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -27,6 +27,14 @@ class AccountInvoice(models.Model):
string=u'Estado CNAB',
related='move_line_receivable_id.state_cnab',
readonly=True,
+ store=True,
+ )
+
+ eval_situacao_pagamento = fields.Selection(
+ string=u'Situação do Pagamento',
+ related='move_line_receivable_id.situacao_pagamento',
+ readonly=True,
+ store=True,
)
eval_payment_mode_instrucoes = fields.Text(
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 7f4d893ec05a..40bd0b887934 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -26,6 +26,11 @@
/>
+
+
+
+
+
@@ -43,4 +48,72 @@
+
+
+ invoice.tree.inherit
+ account.invoice
+
+
+
+
+
+
+
+
+
+
+ view.account.invoice.filter.inherit
+ account.invoice
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 5a05ca1806ad706e90710719a98d5005e0baa31b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 11:27:19 -0300
Subject: [PATCH 143/612] [ADD] Filtros no modelo bank_api_operation
---
.../views/bank_api_operation_views.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
index 179343166962..b3d91f5c0160 100644
--- a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
@@ -35,6 +35,20 @@
filter_domain="[('operation_datetime', '>', self)]"
/>
+
+
+
+
+
+
+
+
+
From d3845851b492336bcf9a71fc0d51bd4c16125c2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 14:48:27 -0300
Subject: [PATCH 144/612] =?UTF-8?q?[ADD]=20Valida=C3=A7=C3=B5es=20para=20c?=
=?UTF-8?q?ancelamento=20de=20faturas?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/__init__.py | 1 +
.../models/account_invoice.py | 38 +++++++++++++++++++
.../models/account_move.py | 25 ++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/models/account_move.py
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index fba73552a3b8..4cad780f6024 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice
+from . import account_move
from . import account_move_line
from . import account_payment
from . import account_payment_line
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index d2ed5466c5c0..29a634a67d68 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -54,6 +54,44 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ @api.multi
+ def action_invoice_cancel(self):
+ for record in self:
+ if record.eval_state_cnab == 'accepted':
+ raise UserError(_(
+ "A fatura não pode ser cancelada pois já foi aprovada "
+ "no Banco."
+ ))
+ if record.eval_state_cnab == 'done':
+ raise UserError(_(
+ "Não é possível cancelar uma fatura finalizada."
+ ))
+ if record.eval_state_cnab == 'exported':
+ raise UserError(_(
+ "A fatura não pode ser cancelada pois já foi exportada "
+ "em uma remessa."
+ ))
+
+ payment_order_ids = self.env['account.payment.order'].search([
+ ('payment_line_ids.move_line_id', 'in',
+ [record.move_line_receivable_id.id])
+ ])
+
+ if payment_order_ids:
+ if any(state in ['draft', 'cancel'] for state in
+ payment_order_ids.mapped('state')):
+ raise UserError(_(
+ "Para cancelar a fatura, você deve retirá-la das "
+ "ordens de pagamento em aberto em que a mesma "
+ "se encontra. Ordem de Débito %s"
+ ) % '.'.join(payment_order_ids.mapped('name')))
+ raise UserError(_(
+ "A fatura não pode ser cancelada pois a mesma já se "
+ "encontra exportada por uma ordem de pagamento."
+ ))
+
+ super(AccountInvoice, self).action_invoice_cancel()
+
def create_bank_api_operation(self, request, operation_type=False,
environment=False):
# 'not request' não é válido para o propósito
diff --git a/l10n_br_account_payment_cobranca/models/account_move.py b/l10n_br_account_payment_cobranca/models/account_move.py
new file mode 100644
index 000000000000..097faa762531
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_move.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# © 2019 KMEE INFORMATICA LTDA
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.exceptions import ValidationError
+
+from odoo import models, api, _
+
+
+class AccountMove(models.Model):
+ _inherit = "account.move"
+
+ @api.multi
+ def unlink(self):
+ for record in self:
+ payment_line_ids = record.line_ids.mapped('payment_line_ids')
+ if any(state not in ['draft', 'cancel'] for
+ state in payment_line_ids.mapped('state')):
+ raise ValidationError(_(
+ "Não foi possível cancelar a fatura, pois existem linhas "
+ "de pagamentos ativas vinculadas ao lançamento de diário"
+ "dela."
+ ))
+ payment_line_ids.unlink()
+ return super(AccountMove, self).unlink()
From 3cc2ee54eefca72529ed97fa26285c3ed611d9fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 17:30:11 -0300
Subject: [PATCH 145/612] =?UTF-8?q?[FIX]=20Instru=C3=A7=C3=A3o=20de=20cobr?=
=?UTF-8?q?an=C3=A7a=20vazia=20na=20fatura?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 29a634a67d68..bbbba9dce724 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -243,8 +243,12 @@ def action_move_create(self):
interval.identificacao_titulo_empresa = hex(
interval.id
).upper()
- interval.instrucoes = '%s\n%s' % (
- inv.eval_payment_mode_instrucoes, inv.instrucoes)
+ instrucoes = ''
+ if inv.eval_payment_mode_instrucoes:
+ instrucoes = inv.eval_payment_mode_instrucoes + '\n'
+ if inv.instrucoes:
+ instrucoes += inv.instrucoes + '\n'
+ interval.instrucoes = instrucoes
return result
From 8257a3ecf4e264f56d4f3c9e9a6286347ef6dde5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 19 Sep 2019 18:41:27 -0300
Subject: [PATCH 146/612] =?UTF-8?q?[FIX]=20API=20Banc=C3=A1ria=20registran?=
=?UTF-8?q?do=20fatura=20parcelada?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index bbbba9dce724..2ce66e240e0b 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -173,13 +173,19 @@ def register_invoice_api(self):
if response.ok:
# ambiente = 1 --> HML
if boleto.tipo_ambiente == '1':
- receivable_ids.state_cnab = 'accepted_hml'
+ receivable_ids.write({
+ 'state_cnab': 'accepted_hml'
+ })
# PROD
else:
- receivable_ids.state_cnab = 'accepted'
- receivable_ids.situacao_pagamento = 'aberta'
+ receivable_ids.write({
+ 'state_cnab': 'accepted',
+ 'situacao_pagamento': 'aberta'
+ })
else:
- receivable_ids.state_cnab = 'not_accepted'
+ receivable_ids.write({
+ 'state_cnab': 'not_accepted'
+ })
except Exception as e:
raise UserError(_(
From 4c792cea7a64d313f736fc37760adef9d9f15f4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 20 Sep 2019 08:35:42 -0300
Subject: [PATCH 147/612] =?UTF-8?q?[FIX]=20Verificando=20se=20uma=20fatura?=
=?UTF-8?q?=20foi=20emitida=20em=20homologa=C3=A7=C3=A3o?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_move_line.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 7268e07a9604..de9943691fac 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -114,8 +114,8 @@ def generate_boleto(self, validate=True):
move_line, move_line.nosso_numero
)
- # Se for ambiente de Homologação
- if move_line.partner_id.company_id.environment == '1':
+ # Se a cobrança tiver sido emitida em homologação
+ if move_line.state_cnab == 'accepted_hml':
boleto.boleto.instrucoes.append(_(
u'Boleto emitido em homologacao! Sem valor fiscal!'))
From 3cde65c4cc50b3784a761532b2d5ac73505684a0 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 25 Sep 2019 11:54:27 -0300
Subject: [PATCH 148/612] =?UTF-8?q?[FIX]=20Permiss=C3=B5es=20extras=20de?=
=?UTF-8?q?=20escrita\leitura=20no=20modelo=20res.company?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 2ce66e240e0b..06bbe214d3d2 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -126,7 +126,7 @@ def register_invoice_api(self):
u"Não foi possível registrar as faturas pela API"
))
- company_id = record.partner_id.company_id
+ company_id = record.partner_id.company_id.sudo()
client_id = company_id.client_id
client_secret = company_id.client_secret
From a7a55b12fe4733fe85ec1e61a9de720d64116d5d Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 25 Sep 2019 17:51:12 -0300
Subject: [PATCH 149/612] =?UTF-8?q?[ADD]=20Tela=20de=20confirma=C3=A7?=
=?UTF-8?q?=C3=A3o=20de=20fatura=20via=20API=20Banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/__init__.py | 1 +
.../models/account_invoice_api_confirm.py | 72 +++++++++++++++++++
.../views/account_invoice.xml | 48 ++++++++++++-
3 files changed, 118 insertions(+), 3 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index 4cad780f6024..ea553c006c84 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice
+from . import account_invoice_api_confirm
from . import account_move
from . import account_move_line
from . import account_payment
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
new file mode 100644
index 000000000000..4c8df07a48f5
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+
+import logging
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+_logger = logging.getLogger(__name__)
+
+
+class AccountInvoiceAPIConfirm(models.TransientModel):
+ """
+ Esse wizard é utilizado para seleção de faturas a serem registradas no
+ banco via API
+ """
+
+ _name = "account.invoice.api.confirm"
+ _description = "Registrar as faturas selecionadas via API"
+
+ environment = fields.Char(
+ string='Ambiente',
+ default=lambda self: self._default_environment(),
+ )
+
+ invoice_ids = fields.Many2many(
+ comodel_name='account.invoice',
+ string='Faturas',
+ default=lambda self: self._default_invoice_ids(),
+ )
+
+ @api.model
+ def _default_invoice_ids(self):
+ active_ids = self.env['account.invoice'].browse(
+ self._context.get('active_ids'))
+
+ return active_ids.search([
+ ('id', 'in', active_ids.ids),
+ ('state', '=', 'open'),
+ ('eval_state_cnab', 'not in', (
+ 'added_paid', 'accepted', 'done', 'accepted_hml'))
+ ]).ids
+
+ @api.model
+ def _default_environment(self):
+ active_ids = self.env['account.invoice'].browse(
+ self._context.get('active_ids'))
+ environment = active_ids[:1].partner_id.company_id.environment
+ if not environment:
+ message = "Nenhum ambiente está configurado no cadastro da " \
+ "empresa. Favor escolher entre Produção e Homologação."
+ _logger.error(message)
+ raise UserError(message)
+
+ try:
+ environment_text = self.env['res.company']._fields.get(
+ 'environment').selection[int(environment) - 1][-1]
+ except Exception as e:
+ message = 'Erro ao obter ambiente. %s' % str(e)
+ _logger.error(message)
+ raise UserError(message)
+
+ return environment_text
+
+ @api.multi
+ def api_register_confirm(self):
+ for record in self:
+ for invoice_id in record.invoice_ids:
+ try:
+ invoice_id.register_invoice_api()
+ except Exception as e:
+ _logger.debug('Erro ao processar fatura %s. %s' % (
+ invoice_id.number, str(e)))
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 40bd0b887934..40ee2ece2ba0 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -1,5 +1,48 @@
+
+
+ account.invoice.api.form
+ account.invoice.api.confirm
+
+
+
+
+
+
+
+
+
+ Você está prestes a registrar uma faturamente diretamente
+ com o Banco. Verifique se o ambiente selecionado está de
+ acordo com a operação que deseja realizar.
+
+
+
+
+
+
+
+
+
+
+
+ Registrar faturas via API
+ account.invoice.api.confirm
+ form
+
+ new
+
+
+
+
view.l10n_br_account.invoice.form.form.inherit
@@ -14,11 +57,10 @@
- 1:
for invoice_id in record.invoice_ids:
try:
+ invoice_id.obtain_token(
+ self.env.user.company_id.sudo())
invoice_id.with_delay().register_invoice_api()
except Exception as e:
_logger.debug('Erro ao processar fatura %s. %s' % (
From c9ab286962ebf4a44acd77bd9f8d0bf3215afea6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 4 Oct 2019 13:35:32 -0300
Subject: [PATCH 152/612] =?UTF-8?q?[IMP]=20Elemento=20removido=20da=20tela?=
=?UTF-8?q?=20para=20otimiza=C3=A7=C3=A3o?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice_api_confirm.py | 12 ++++++------
.../views/account_invoice.xml | 3 ---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
index 3eb0bc269b4e..c994cc1bbc39 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
@@ -33,15 +33,15 @@ def _default_invoice_ids(self):
active_ids = self.env['account.invoice'].browse(
self._context.get('active_ids'))
- return active_ids.search([
- ('id', 'in', active_ids.ids),
- ('state', '=', 'open'),
- ('eval_state_cnab', 'not in', (
- 'added_paid', 'accepted', 'done', 'accepted_hml'))
- ]).ids
+ valid_ids = active_ids.filtered(
+ lambda a: a.state == 'open' and a.eval_state_cnab not in [
+ 'added_paid', 'accepted', 'done', 'accepted_hml']).ids
+
+ return valid_ids
@api.model
def _default_environment(self):
+ # TODO: Multi-company approach
active_ids = self.env['account.invoice'].browse(
self._context.get('active_ids'))
environment = active_ids[:1].partner_id.company_id.environment
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 40ee2ece2ba0..1297fb81f06a 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -18,9 +18,6 @@
acordo com a operação que deseja realizar.
-
-
-
From 75188af397dc497b64e86a126589adbd98146fa6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Fri, 4 Oct 2019 13:35:51 -0300
Subject: [PATCH 153/612] [ADD] Recalculo do campo move_line_receivable_id
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 3051ed24f483..7eb85e948b4d 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -235,6 +235,7 @@ def action_move_create(self):
for inv in self:
# inv.transaction_id = sequence
+ inv._compute_receivables()
for index, interval in enumerate(inv.move_line_receivable_id):
inv_number = inv.get_invoice_fiscal_number().split(
'/')[-1].zfill(8)
From af3d20a2569015922a81b46fd2c89327eda5dc33 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 11 Oct 2019 16:44:43 -0300
Subject: [PATCH 154/612] =?UTF-8?q?[FIX]=20Gera=C3=A7=C3=A3o=20de=20arquiv?=
=?UTF-8?q?o=20CNAB=20remessa=20com=20baixa=20de=20pagamentos?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../febraban/cnab_400/bancos/itau.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
index 582a2d96ed68..cfcf6a55a7b0 100644
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
@@ -66,15 +66,12 @@ def _prepare_cobranca(self, line):
"""
sacado_endereco = self.retorna_endereco(line.partner_id.id)
- move_line_id = \
- line.env['account.move.line'].search([
- ('identificacao_titulo_empresa', '=',
- line.identificacao_titulo_empresa)
- ])
+ # TODO: Garantir que o account.move.line selecionado é o correto
+ move_line_id = line.payment_line_ids[:1].move_line_id
# TODO: Guardar estrutura com códigos de ocorrências
identificacao_ocorrencia = 1
- if move_line_id and move_line_id.state_cnab == 'added_paid':
+ if move_line_id.state_cnab == 'added_paid':
identificacao_ocorrencia = 34
vals = {
From 25919b5e20e88ed815e56a1209636ad7a744e37c Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Fri, 11 Oct 2019 17:20:30 -0300
Subject: [PATCH 155/612] =?UTF-8?q?[IMP]=20Bot=C3=A3o=20"Registrar=20fatur?=
=?UTF-8?q?a=20via=20API"=20invis=C3=ADvel=20quando=20pagamento=20est?=
=?UTF-8?q?=C3=A1=20em=20aberto?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/views/account_invoice.xml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 1297fb81f06a..7531d8d3aa90 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -58,9 +58,10 @@
string="Registrar Boleto via API" type="action"
groups="base.group_user"
class="oe_highlight" style="background-color:red; text-color:white;"
- attrs="{'invisible': ['|',
+ attrs="{'invisible': ['|','|',
('state', '!=', 'open'),
- ('eval_state_cnab', 'in', ('added_paid', 'accepted', 'done', 'accepted_hml'))
+ ('eval_state_cnab', 'in', ('added_paid', 'accepted', 'done', 'accepted_hml')),
+ ('eval_situacao_pagamento', 'in', ('aberta'))
]}"
/>
From ba535df8f66d2c5d72f2d8e417744623f40bfb0f Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Mon, 14 Oct 2019 12:21:52 -0300
Subject: [PATCH 156/612] =?UTF-8?q?[IMP]=20Removendo=20faturas=20das=20?=
=?UTF-8?q?=C3=B3rdens=20de=20d=C3=A9bito=20ap=C3=B3s=20confirma=C3=A7?=
=?UTF-8?q?=C3=A3o=20de=20registro=20banc=C3=A1rio=20via=20API?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 42 +++++++++++++------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 7eb85e948b4d..7e3c48954e97 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -55,6 +55,30 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ def _remove_payment_order_line(self, _raise=True):
+ move_line_receivable_id = self.move_line_receivable_id
+ payment_order_ids = self.env['account.payment.order'].search([
+ ('payment_line_ids.move_line_id', 'in',
+ [move_line_receivable_id.id])
+ ])
+
+ if payment_order_ids:
+ draft_cancel_payment_order_ids = payment_order_ids.filtered(
+ lambda p: p.state in ['draft', 'cancel'])
+ if payment_order_ids - draft_cancel_payment_order_ids:
+ if _raise:
+ raise UserError(_(
+ "A fatura não pode ser cancelada pois a mesma já se "
+ "encontra exportada por uma ordem de pagamento."
+ ))
+
+ for po_id in draft_cancel_payment_order_ids:
+ p_line_id = self.env['account.payment.line'].search([
+ ('order_id', '=', po_id.id),
+ ('move_line_id', '=', move_line_receivable_id.id)
+ ])
+ po_id.payment_line_ids -= p_line_id
+
@api.multi
def action_invoice_cancel(self):
for record in self:
@@ -73,23 +97,13 @@ def action_invoice_cancel(self):
"em uma remessa."
))
+ move_line_receivable_id = record.move_line_receivable_id
payment_order_ids = self.env['account.payment.order'].search([
('payment_line_ids.move_line_id', 'in',
- [record.move_line_receivable_id.id])
+ [move_line_receivable_id.id])
])
- if payment_order_ids:
- if any(state in ['draft', 'cancel'] for state in
- payment_order_ids.mapped('state')):
- raise UserError(_(
- "Para cancelar a fatura, você deve retirá-la das "
- "ordens de pagamento em aberto em que a mesma "
- "se encontra. Ordem de Débito %s"
- ) % '.'.join(payment_order_ids.mapped('name')))
- raise UserError(_(
- "A fatura não pode ser cancelada pois a mesma já se "
- "encontra exportada por uma ordem de pagamento."
- ))
+ record._remove_payment_order_line()
super(AccountInvoice, self).action_invoice_cancel()
@@ -197,6 +211,8 @@ def register_invoice_api(self):
'state_cnab': 'accepted',
'situacao_pagamento': 'aberta'
})
+ # Remove Invoice from debit.orders
+ record._remove_payment_order_line(_raise=False)
else:
receivable_ids.write({
'state_cnab': 'not_accepted'
From a42394c510278296a98d0004f450013c6da8efd1 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 15 Oct 2019 16:30:09 -0300
Subject: [PATCH 157/612] [FIX] Filtrando bank_payment_line por nosso_numero
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 8f6fb70ec81e..7836f3582b4d 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -339,8 +339,7 @@ def _cria_lote(self, header, lote, evento, trailer):
def _lote_400(self, evento, lote_id):
bank_payment_line_id = self.env['bank.payment.line'].search([(
- 'identificacao_titulo_empresa', '=',
- evento.identificacao_titulo_empresa
+ 'nosso_numero', '=', evento.nosso_numero
)], limit=1)
vals_evento = {
From 379ab46e776f2cc5f153a34ee66866d3f5034541 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 15 Oct 2019 16:32:35 -0300
Subject: [PATCH 158/612] =?UTF-8?q?[ADD]=20Criando=20=C3=93rdens=20de=20d?=
=?UTF-8?q?=C3=A9bito=20para=20faturas=20registradas=20via=20API?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 105 +++++++++++++++---
.../models/account_payment_order.py | 5 +
2 files changed, 92 insertions(+), 18 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 7e3c48954e97..3e30f5174738 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -97,12 +97,6 @@ def action_invoice_cancel(self):
"em uma remessa."
))
- move_line_receivable_id = record.move_line_receivable_id
- payment_order_ids = self.env['account.payment.order'].search([
- ('payment_line_ids.move_line_id', 'in',
- [move_line_receivable_id.id])
- ])
-
record._remove_payment_order_line()
super(AccountInvoice, self).action_invoice_cancel()
@@ -172,6 +166,72 @@ def obtain_token(self, company_id):
return token
+ @api.multi
+ def create_api_account_payment_line(self):
+ # TODO: Criar CRON para confirmar as account.payment.order no final de
+ # cada dia
+ apoo = self.env['account.payment.order']
+ result_payorder_ids = []
+ payorder = False
+ for inv in self:
+ if inv.state != 'open':
+ raise UserError(_(
+ "The invoice %s is not in Open state") % inv.number)
+ if not inv.move_id:
+ raise UserError(_(
+ "No Journal Entry on invoice %s") % inv.number)
+ applicable_lines = inv.move_id.line_ids.filtered(
+ lambda x: (
+ not x.reconciled and x.payment_mode_id.payment_order_ok and
+ x.account_id.internal_type in ('receivable', 'payable') and
+ not x.payment_line_ids
+ )
+ )
+ if not applicable_lines:
+ raise UserError(_(
+ 'No Payment Line created for invoice %s because '
+ 'it already exists or because this invoice is '
+ 'already paid.') % inv.number)
+ payment_modes = applicable_lines.mapped('payment_mode_id')
+ if not payment_modes:
+ raise UserError(_(
+ "No Payment Mode on invoice %s") % inv.number)
+ for payment_mode in payment_modes:
+ payorder = apoo.search([
+ ('payment_mode_id', '=', payment_mode.id),
+ ('state', '=', 'draft'),
+ ('active', '=', False),
+ ('name', 'ilike', 'api'),
+ ], limit=1)
+
+ new_payorder = False
+ if not payorder:
+ payorder = apoo.create(inv._prepare_new_payment_order(
+ payment_mode
+ ))
+ new_payorder = True
+ payorder.name += '_api'
+ payorder.active = False
+
+ result_payorder_ids.append(payorder.id)
+ count = 0
+ for line in applicable_lines.filtered(
+ lambda x: x.payment_mode_id == payment_mode
+ ):
+ line.create_payment_line_from_move_line(payorder)
+ count += 1
+ if new_payorder:
+ inv.message_post(_(
+ '%d payment lines added to the new draft payment '
+ 'order %s which has been automatically created.')
+ % (count, payorder.name))
+ else:
+ inv.message_post(_(
+ '%d payment lines added to the existing draft '
+ 'payment order %s.')
+ % (count, payorder.name))
+ return payorder
+
@job
@api.multi
def register_invoice_api(self):
@@ -199,20 +259,16 @@ def register_invoice_api(self):
response = False
try:
response = boleto.post(token, itau_key, barcode_endpoint)
- if response.ok:
- # ambiente = 1 --> HML
- if boleto.tipo_ambiente == '1':
- receivable_ids.write({
- 'state_cnab': 'accepted_hml'
- })
- # PROD
- else:
- receivable_ids.write({
- 'state_cnab': 'accepted',
- 'situacao_pagamento': 'aberta'
- })
+ if response and response.ok:
# Remove Invoice from debit.orders
record._remove_payment_order_line(_raise=False)
+
+ # Create new Debit Order for payment_order_line
+ try:
+ record.create_api_account_payment_line()
+
+ except Exception as e:
+ _logger.debug(str(e))
else:
receivable_ids.write({
'state_cnab': 'not_accepted'
@@ -225,6 +281,19 @@ def register_invoice_api(self):
) % str(e))
finally:
+ if response and response.ok:
+ # ambiente = 1 --> HML
+ if boleto.tipo_ambiente == '1':
+ receivable_ids.write({
+ 'state_cnab': 'accepted_hml'
+ })
+ # PROD
+ else:
+ receivable_ids.write({
+ 'state_cnab': 'accepted',
+ 'situacao_pagamento': 'aberta'
+ })
+
record.create_bank_api_operation(
response,
operation_type='invoice_register',
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 8dd8bd724cf4..5a1e1bbd3ee9 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -24,6 +24,11 @@
class PaymentOrder(models.Model):
_inherit = b'account.payment.order'
+ active = fields.Boolean(
+ string=u'Ativo',
+ default=True,
+ )
+
file_number = fields.Integer(
string=u'Número sequencial do arquivo',
)
From 71e9b62b9aa61f48e9a94d99eec7fe21cd5d7577 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 15 Oct 2019 20:07:50 -0300
Subject: [PATCH 159/612] [ADD] Processar retorno multi
---
.../models/l10n_br_cnab.py | 8 ++++++++
.../views/l10n_br_cnab_retorno_view.xml | 14 ++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 7836f3582b4d..52673188cb6b 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -687,6 +687,14 @@ def _reprocessa_lote_400(self, evento, lote_id):
credit_move_line.with_context(
reprocessing=True).write(line_values)
+ @api.model
+ def processar_retorno_multi(self):
+ active_ids = self._context.get("active_ids")
+
+ for cnab_id in self.browse(active_ids):
+ if cnab_id.state in ['draft']:
+ cnab_id.processar_arquivo_retorno()
+
@api.model
def reprocessar_retorno_multi(self):
active_ids = self._context.get("active_ids")
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 46f98ec0aa6e..ecec3453124d 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -207,6 +207,20 @@
+
+ Processar Retorno
+
+ code
+ action = env.get('l10n_br.cnab').processar_retorno_multi()
+
+
+
+ Processar Retorno
+ client_action_multi
+ l10n_br.cnab
+
+
+
Reprocessar Retorno
From 4f8dfb9b9f59ad6323e52f5770515ea1c38b0984 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 16 Oct 2019 17:49:52 -0300
Subject: [PATCH 160/612] [FIX] group_by_partner_id
---
l10n_br_account_payment_cobranca/views/account_invoice.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 7531d8d3aa90..1fe904ef9a34 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -107,6 +107,9 @@
search
+
+ {'group_by': 'partner_id'}
+
From 8e487b01b624648e5ab8c3060b6e4eccd4ad556c Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 16 Oct 2019 17:50:19 -0300
Subject: [PATCH 161/612] =?UTF-8?q?[IMP]=20Campos=20de=20situa=C3=A7=C3=A3?=
=?UTF-8?q?o=20cnab+pagamento=20indexados?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 3e30f5174738..81004c12b303 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -29,6 +29,7 @@ class AccountInvoice(models.Model):
related='move_line_receivable_id.state_cnab',
readonly=True,
store=True,
+ index=True,
)
eval_situacao_pagamento = fields.Selection(
@@ -36,6 +37,7 @@ class AccountInvoice(models.Model):
related='move_line_receivable_id.situacao_pagamento',
readonly=True,
store=True,
+ index=True,
)
eval_payment_mode_instrucoes = fields.Text(
From 1e68c215af0340b75420812a4525ced6c13bcb83 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Wed, 16 Oct 2019 17:50:27 -0300
Subject: [PATCH 162/612] [ADD] Campo active no modelo das faturas
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 81004c12b303..c24b5365eab9 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -24,6 +24,11 @@
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
+ active = fields.Boolean(
+ string=u'Ativo',
+ default=True,
+ )
+
eval_state_cnab = fields.Selection(
string=u'Estado CNAB',
related='move_line_receivable_id.state_cnab',
From d9e0082154db92ab57790622977668411e45d57b Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Thu, 17 Oct 2019 17:19:44 -0300
Subject: [PATCH 163/612] =?UTF-8?q?[IMP]=20Melhora=20no=20filtro=20"N?=
=?UTF-8?q?=C3=A3o=20Pago"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/views/account_invoice.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 1fe904ef9a34..50037a9824f6 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -110,6 +110,9 @@
{'group_by': 'partner_id'}
+
+ [('state','!=','paid')]
+
From 2ed4017c95a2ac89c38248c7c2af89f9b664bcdb Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 29 Oct 2019 08:58:56 -0300
Subject: [PATCH 164/612] =?UTF-8?q?[FIX]=20Ambiente=20na=20busca=20por=20u?=
=?UTF-8?q?m=20novo=20Token=20-=20Api=20Banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index c24b5365eab9..c6dd7d0b4999 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -129,10 +129,11 @@ def create_bank_api_operation(self, request, operation_type=False,
operation_id.register_post(request)
self.bank_api_operation_ids += operation_id
- def obtain_token(self, company_id):
+ def obtain_token(self, company_id, environment):
"""
Método para buscar ou atualizar o Token da empresa
:param company_id: Empresa
+ :param environment: Ambiente da operação
:return: O Token da empresa
"""
@@ -259,7 +260,7 @@ def register_invoice_api(self):
barcode_endpoint = company_id.raiz_endpoint
environment = company_id.environment
- token = record.obtain_token(company_id)
+ token = record.obtain_token(company_id, environment)
for boleto in boleto_list:
ApiItau.convert_to(boleto, tipo_ambiente=environment)
From bacbbccfa02a5b0b3e6511ff1e7a9b269e2e400a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 31 Oct 2019 18:10:42 -0300
Subject: [PATCH 165/612] =?UTF-8?q?[ADD]=20Cron=20para=20processamento=20d?=
=?UTF-8?q?e=20Ordens=20de=20D=C3=A9bito=20da=20API=20Banc=C3=A1ria?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../__manifest__.py | 1 +
.../data/ir_cron.xml | 15 +++++++++++++
.../models/account_payment_order.py | 21 ++++++++++++++++++-
3 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 l10n_br_account_payment_cobranca/data/ir_cron.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 9fc63ad725f4..fdcc51fe054d 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -24,6 +24,7 @@
'data': [
'data/l10n_br_payment_export_type.xml',
'data/boleto_data.xml',
+ 'data/ir_cron.xml',
'security/cnab_cobranca_security.xml',
diff --git a/l10n_br_account_payment_cobranca/data/ir_cron.xml b/l10n_br_account_payment_cobranca/data/ir_cron.xml
new file mode 100644
index 000000000000..e7c7bd08dc24
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/data/ir_cron.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ Confirma Ordens de Débito API
+ 1
+ days
+ -1
+
+ True
+ account.payment.order
+ _confirm_debit_orders_api
+
+
+
\ No newline at end of file
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 5a1e1bbd3ee9..ba8b5bd236e0 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -82,7 +82,26 @@ class PaymentOrder(models.Model):
readonly=True,
domain=[('is_erro_exportacao', '=', True)],
)
-
+
+ def _confirm_debit_orders_api(self):
+ """
+ Method create to confirm all bank_api exclusive account.payment.order
+ :return:
+ """
+ _logger.info("_confirm_debit_orders_api()")
+
+ order_ids = self.search([
+ ('active', '=', False),
+ ('state', '=', 'draft'),
+ ('name', 'ilike', 'api')
+ ])
+
+ for order_id in order_ids:
+ try:
+ order_id.draft2open()
+ order_id.active = True
+ except Exception as e:
+ _logger.warn(str(e))
@api.model
def _prepare_bank_payment_line(self, paylines):
From b44c2acd557084ef38ce363460e6fbb52de5b380 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Mon, 11 Nov 2019 17:17:11 -0200
Subject: [PATCH 166/612] =?UTF-8?q?[IMP]=20Permiss=C3=A3o=20para=20validar?=
=?UTF-8?q?=20faturas=20sem=20modo=20de=20pagamento?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index c6dd7d0b4999..0d222cb5b055 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -427,5 +427,7 @@ def create_account_payment_line_baixa(self):
@api.multi
def invoice_validate(self):
result = super(AccountInvoice, self).invoice_validate()
- self.create_account_payment_line()
+ filtered_invoice_ids = self.filtered(lambda s: s.payment_mode_id)
+ if filtered_invoice_ids:
+ filtered_invoice_ids.create_account_payment_line()
return result
From d19efaa23f3a5fa0e3a7e330768aec6288012f56 Mon Sep 17 00:00:00 2001
From: Hugo Borges
Date: Tue, 19 Nov 2019 10:54:03 -0200
Subject: [PATCH 167/612] [FIX] company environment
---
.../models/account_invoice_api_confirm.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
index c994cc1bbc39..8e0f10d81227 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
@@ -64,12 +64,13 @@ def _default_environment(self):
@api.multi
def api_register_confirm(self):
# TODO: Redundant code
+ environment = self.env.user.company_id.environment
for record in self:
if len(record.invoice_ids) > 1:
for invoice_id in record.invoice_ids:
try:
invoice_id.obtain_token(
- self.env.user.company_id.sudo())
+ self.env.user.company_id.sudo(), environment)
invoice_id.with_delay().register_invoice_api()
except Exception as e:
_logger.debug('Erro ao processar fatura %s. %s' % (
From dbb6fed09ea22e861d42e56e7b9da64abbf4e441 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 27 Nov 2019 12:20:07 -0200
Subject: [PATCH 168/612] =?UTF-8?q?[ADD]=20Juros=20no=20payment.term=20car?=
=?UTF-8?q?t=C3=A3o?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../__manifest__.py | 2 +
.../data/account_analytic_tag_data.xml | 8 +++
.../models/__init__.py | 1 +
.../models/account_invoice.py | 34 +++++++++++++
.../models/account_payment_term.py | 51 +++++++++++++++++++
.../views/account_payment_term_view.xml | 24 +++++++++
6 files changed, 120 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
create mode 100644 l10n_br_account_payment_cobranca/models/account_payment_term.py
create mode 100644 l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index fdcc51fe054d..4a7d7179d8f0 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -25,6 +25,7 @@
'data/l10n_br_payment_export_type.xml',
'data/boleto_data.xml',
'data/ir_cron.xml',
+ 'data/account_analytic_tag_data.xml',
'security/cnab_cobranca_security.xml',
@@ -33,6 +34,7 @@
'views/res_partner_bank.xml',
'views/account_payment_order.xml',
'views/account_payment_line.xml',
+ 'views/account_payment_term_view.xml',
'views/bank_payment_line.xml',
'views/account_invoice.xml',
'views/bank_api_operation_views.xml',
diff --git a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
new file mode 100644
index 000000000000..3ef7328e7fa3
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ Juros
+
+
+
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index ea553c006c84..9aac69e126ff 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -9,6 +9,7 @@
from . import account_payment_line
from . import account_payment_mode
from . import account_payment_order
+from . import account_payment_term
from . import bank_api_operation
from . import bank_payment_line
from . import l10n_br_cnab
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 0d222cb5b055..6ca468fdd5c2 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -62,6 +62,40 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ @api.onchange('payment_term_id')
+ def _onchange_payment_term(self):
+ interest_analytic_tag_id = self.env.ref(
+ 'l10n_br_account_payment_cobranca.'
+ 'account_analytic_tag_interest')
+
+ to_remove_invoice_line_ids = \
+ self.invoice_line_ids.filtered(
+ lambda i: interest_analytic_tag_id in i.analytic_tag_ids)
+
+ self.invoice_line_ids -= to_remove_invoice_line_ids
+
+ payment_term_id = self.payment_term_id
+ amount_total = self.amount_total
+ if payment_term_id.has_interest and amount_total > 0:
+ invoice_line_data = {
+ 'name': 'Taxa de juros por parcelamento no cartão',
+ 'partner_id': self.partner_id.id,
+ 'account_id': payment_term_id.interest_account_id.id,
+ 'analytic_tag_ids': [
+ (6, 0, [interest_analytic_tag_id.id])
+ ],
+ 'quantity': 1,
+ 'price_unit':
+ amount_total * payment_term_id.interest_rate / 100
+ }
+
+ self.update({
+ 'invoice_line_ids': [
+ (6, 0, self.invoice_line_ids.ids),
+ (0, 0, invoice_line_data)
+ ],
+ })
+
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_id = self.move_line_receivable_id
payment_order_ids = self.env['account.payment.order'].search([
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_term.py b/l10n_br_account_payment_cobranca/models/account_payment_term.py
new file mode 100644
index 000000000000..352c26abf803
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/models/account_payment_term.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+# © 2019 KMEE INFORMATICA LTDA
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+import openerp.addons.decimal_precision as dp
+
+from odoo import models, fields, api
+
+PAYMENT_SELECTION = [
+ ('boleto', 'Boleto'),
+ ('cartao', 'Cartão'),
+ ('cheque', 'Cheque'),
+ ('dinheiro', 'Dinheiro'),
+ ('outros', 'Outros'),
+]
+
+
+class AccountPaymentTerm(models.Model):
+ _inherit = 'account.payment.term'
+
+ payment_mode_selection = fields.Selection(
+ selection=PAYMENT_SELECTION,
+ string='Modo de Pagamento'
+ )
+
+ has_interest = fields.Boolean(
+ string='Juros?',
+ default=False,
+ )
+
+ interest_rate = fields.Float(
+ string='Taxa de Juros(%)',
+ digits=dp.get_precision('Account'),
+ default=0.0,
+ )
+
+ interest_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta',
+ help='Conta padrão para Juros',
+ )
+
+ @api.onchange('payment_mode_selection')
+ def _onchange_payment_mode(self):
+ if self.payment_mode_selection not in ['cartao']:
+ self.has_interest = False
+
+ @api.onchange('has_interest')
+ def _onchange_has_interest(self):
+ if not self.has_interest:
+ self.interest_rate = 0
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml b/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
new file mode 100644
index 000000000000..572c914b19dd
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ l10n_br_account_product.payment.term.form
+ account.payment.term
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 3a869153b10770d01a530ed5b75ff980b5fb248e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 27 Nov 2019 12:21:34 -0200
Subject: [PATCH 169/612] [IMP] account_analytic_tag data noupdate=1
---
.../data/account_analytic_tag_data.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
index 3ef7328e7fa3..9c49a1fd62ef 100644
--- a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
+++ b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
@@ -1,5 +1,5 @@
-
+
Juros
From 53cdce111be7c9b152771b625f0bc7e29f5e7e53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 3 Dec 2019 11:52:13 -0200
Subject: [PATCH 170/612] =?UTF-8?q?[FIX]=20Recomputar=20receivable=5Finvoi?=
=?UTF-8?q?ce=20ap=C3=B3s=20adicionar=20pagamento?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 6ca468fdd5c2..b2b6d9371412 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -465,3 +465,15 @@ def invoice_validate(self):
if filtered_invoice_ids:
filtered_invoice_ids.create_account_payment_line()
return result
+
+ @api.multi
+ def register_payment(self, payment_line, writeoff_acc_id=False,
+ writeoff_journal_id=False):
+
+ res = super(AccountInvoice, self).register_payment(
+ payment_line, writeoff_acc_id, writeoff_journal_id)
+
+ for inv in self:
+ inv._compute_receivables()
+
+ return res
From 7d61f3383b6978560e0823b5ec1172eee7fefb02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 3 Dec 2019 14:28:14 -0200
Subject: [PATCH 171/612] [ADD] Valor residual na account.move.line
---
.../febraban/boleto/document.py | 9 ++++++---
.../models/account_invoice.py | 15 ++++++++++-----
.../models/account_move_line.py | 6 ++++++
.../views/account_move_line.xml | 3 +++
4 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
index 0c08218fe262..b33e1d61eae1 100644
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
@@ -70,9 +70,12 @@ def _move_line(self, move_line):
self.boleto.data_documento = datetime.date(datetime.strptime(
move_line.invoice_id.date_invoice, '%Y-%m-%d'))
self.boleto.data_processamento = date.today()
- self.boleto.valor = str("%.2f" % move_line.debit or move_line.credit)
- self.boleto.valor_documento = str("%.2f" % move_line.debit or
- move_line.credit)
+ self.boleto.valor = str("%.2f" % move_line.residual if
+ move_line.residual else
+ move_line.debit or move_line.credit)
+ self.boleto.valor_documento = str("%.2f" % move_line.residual if
+ move_line.residual else
+ move_line.debit or move_line.credit)
self.boleto.especie = \
move_line.currency_id and move_line.currency_id.symbol or 'R$'
self.boleto.quantidade = '' # str("%.2f" % move_line.amount_currency)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index b2b6d9371412..0f0c566a6357 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -356,11 +356,8 @@ def get_invoice_fiscal_number(self):
return self.number
@api.multi
- def action_move_create(self):
- result = super(AccountInvoice, self).action_move_create()
-
+ def _pos_action_move_create(self):
for inv in self:
-
# inv.transaction_id = sequence
inv._compute_receivables()
for index, interval in enumerate(inv.move_line_receivable_id):
@@ -399,8 +396,12 @@ def action_move_create(self):
instrucoes += inv.instrucoes + '\n'
interval.instrucoes = instrucoes
- return result
+ @api.multi
+ def action_move_create(self):
+ result = super(AccountInvoice, self).action_move_create()
+ self._pos_action_move_create()
+ return result
@api.multi
def create_account_payment_line_baixa(self):
@@ -473,7 +474,11 @@ def register_payment(self, payment_line, writeoff_acc_id=False,
res = super(AccountInvoice, self).register_payment(
payment_line, writeoff_acc_id, writeoff_journal_id)
+ self._pos_action_move_create()
+
for inv in self:
inv._compute_receivables()
+ receivable_id = inv.move_line_receivable_id
+ receivable_id.residual = inv.residual
return res
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index de9943691fac..00ded9630b83 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -60,6 +60,12 @@ class AccountMoveLine(models.Model):
readonly=True,
)
+ residual = fields.Monetary(
+ string=u'Valor Residual',
+ default=0.0,
+ currency_field='company_currency_id'
+ )
+
@api.multi
def _prepare_payment_line_vals(self, payment_order):
vals = super(AccountMoveLine, self)._prepare_payment_line_vals(
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index 9b030ab41b28..c746abd5f2ca 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -14,6 +14,9 @@
+
+
+
From 54937247375b592eab4ba786d3346c2fdd2a8184 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Tue, 3 Dec 2019 14:41:45 -0200
Subject: [PATCH 172/612] =?UTF-8?q?[IMP]=20Valida=C3=A7=C3=A3o=20para=20ap?=
=?UTF-8?q?enas=20poder=20registrar=20pagamentos=20em=20faturas=20ainda=20?=
=?UTF-8?q?n=C3=A3o=20exportadas?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 0f0c566a6357..12af085d5267 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -467,6 +467,23 @@ def invoice_validate(self):
filtered_invoice_ids.create_account_payment_line()
return result
+ @api.multi
+ def assign_outstanding_credit(self, credit_aml_id):
+ self.ensure_one()
+ if self.eval_situacao_pagamento in \
+ ['paga', 'liquidada', 'baixa_liquidacao']:
+ raise UserError(_(
+ "Não é possível adicionar pagamentos em uma fatura que "
+ "já está paga."
+ ))
+ if self.eval_state_cnab in ['accepted', 'exported', 'done']:
+ raise UserError(_(
+ "Não é possível adicionar pagamentos em uma fatura já "
+ "exportada ou aceita no banco."
+ ))
+ return super(AccountInvoice, self).assign_outstanding_credit(
+ credit_aml_id)
+
@api.multi
def register_payment(self, payment_line, writeoff_acc_id=False,
writeoff_journal_id=False):
From 971dfc917bad3411b9c5d835a6cfaa0998d72822 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 4 Dec 2019 15:44:50 -0200
Subject: [PATCH 173/612] [FIX] data_arquivo ao processar retorno
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 52673188cb6b..5ca141d7fb93 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -708,7 +708,7 @@ def reprocessar_arquivo_retorno(self):
cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
- self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
+ self.data_arquivo = datetime.strptime(data_arquivo.zfill(6), "%d%m%y")
self.bank_account_id = self._busca_conta(
arquivo_parser.header.codigo_do_banco,
@@ -751,7 +751,7 @@ def processar_arquivo_retorno(self):
# )
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
- self.data_arquivo = datetime.strptime(data_arquivo, "%d%m%y")
+ self.data_arquivo = datetime.strptime(data_arquivo.zfill(6), "%d%m%y")
if self.search([
('data_arquivo', '=', self.data_arquivo),
@@ -819,7 +819,7 @@ def processar_arquivo_retorno(self):
'ref':
'Retorno Gerado em %s' %
datetime.strftime(datetime.strptime(
- data_arquivo, "%d%m%y"), "%d/%m/%Y"),
+ data_arquivo.zfill(6), "%d%m%y"), "%d/%m/%Y"),
'date': str(datetime.now()),
'line_ids': lines,
'journal_id': lines[0][2]['journal_id']
From 5fd2cc29511a01b6bf0bd62db3ee40d0daf4f391 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Wed, 4 Dec 2019 17:43:05 -0200
Subject: [PATCH 174/612] [ADD] Taxa adicional no modo de pagamento
---
.../data/account_analytic_tag_data.xml | 4 +++
.../models/account_invoice.py | 33 +++++++++++++++++++
.../models/account_payment_mode.py | 20 +++++++++++
.../views/account_payment_mode.xml | 7 ++++
4 files changed, 64 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
index 9c49a1fd62ef..879d1b6ceb04 100644
--- a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
+++ b/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
@@ -5,4 +5,8 @@
Juros
+
+ Taxa
+
+
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 12af085d5267..1167d3db33b8 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -62,6 +62,39 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ @api.onchange('payment_mode_id')
+ def _onchange_payment_mode_id(self):
+ tax_analytic_tag_id = self.env.ref(
+ 'l10n_br_account_payment_cobranca.'
+ 'account_analytic_tag_tax')
+
+ to_remove_invoice_line_ids = \
+ self.invoice_line_ids.filtered(
+ lambda i: tax_analytic_tag_id in i.analytic_tag_ids)
+
+ self.invoice_line_ids -= to_remove_invoice_line_ids
+
+ payment_mode_id = self.payment_mode_id
+ if payment_mode_id.product_tax_id:
+ invoice_line_data = {
+ 'name': 'Taxa adicional do modo de pagamento escolhido',
+ 'partner_id': self.partner_id.id,
+ 'account_id': payment_mode_id.tax_account_id.id,
+ 'product_id': payment_mode_id.product_tax_id.id,
+ 'price_unit': payment_mode_id.product_tax_id.lst_price,
+ 'quantity': 1,
+ 'analytic_tag_ids': [
+ (6, 0, [tax_analytic_tag_id.id])
+ ],
+ }
+
+ self.update({
+ 'invoice_line_ids': [
+ (6, 0, self.invoice_line_ids.ids),
+ (0, 0, invoice_line_data)
+ ],
+ })
+
@api.onchange('payment_term_id')
def _onchange_payment_term(self):
interest_analytic_tag_id = self.env.ref(
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 3827674a1fa7..dd4dd430216f 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -115,6 +115,26 @@ class PaymentMode(models.Model):
string=u'Conta Padrão para Taxas Bancárias',
help=u'Conta padrão para recebimentos de Taxas Bancárias'
)
+ product_tax_id = fields.Many2one(
+ comodel_name='product.product',
+ string='Taxa Adicional',
+ )
+ tax_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Padrão',
+ help='Conta padrão para Taxa',
+ )
+
+ @api.onchange('product_tax_id')
+ def _onchange_product_tax_id(self):
+ if not self.product_tax_id:
+ self.tax_account_id = False
+
+ @api.constrains('product_override')
+ def _constrains_product_override(self):
+ if self.product_override and self.product_override_value <= 0:
+ raise ValidationError(
+ u'O valor da Taxa deve ser maior que 0 (zero)')
@api.constrains('boleto_type', 'boleto_carteira',
'boleto_modalidade', 'boleto_convenio',
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index c5d9fb82619f..e79c150ae780 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -9,6 +9,13 @@
ref="l10n_br_account_payment_order.view_payment_mode_form_inherit_l10n_br_payment"/>
+
+
+
+
+
+
From ff2fba16ddb3ecdde04302a8e9b97184a177c3ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 5 Dec 2019 10:55:29 -0200
Subject: [PATCH 175/612] [ADD] CNAB Ondelete
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py | 1 +
l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 1b98900913dc..5b3e62b6e79c 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -45,6 +45,7 @@ class L10nBrCnabEvento(models.Model):
lote_id = fields.Many2one(
string="Lote",
comodel_name="l10n_br.cnab.lote",
+ ondelete='cascade',
)
nosso_numero = fields.Char(
string=u"Nosso Número"
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index a6986a0aa1be..f1e329440bff 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -19,7 +19,8 @@ class L10nBrCnabLote(models.Model):
)
cnab_id = fields.Many2one(
string="CNAB",
- comodel_name="l10n_br.cnab"
+ comodel_name="l10n_br.cnab",
+ ondelete='cascade',
)
empresa_inscricao_numero = fields.Char(
string=u"Número de Inscrição"
From 8ffd454e4b3ce92adeca26925cb8244181692a7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Uch=C3=B4as=20Borges?=
Date: Thu, 5 Dec 2019 12:51:02 -0200
Subject: [PATCH 176/612] [IMP] situacao_pagamento constrains on write
---
.../models/account_move_line.py | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 00ded9630b83..10845b08c2d4 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -135,3 +135,23 @@ def _update_check(self):
return True
return super(AccountMoveLine, self)._update_check()
+
+ @api.multi
+ def write(self, vals):
+ """
+ Sobrescrita do método Write. Não deve ser possível voltar o state_cnab
+ ou a situacao_pagamento para um estado anterior
+ :param vals:
+ :return:
+ """
+ state_cnab = vals.get('state_cnab')
+
+ if state_cnab and (self.state_cnab == 'done' or (
+ self.state_cnab in ['accepted', 'accepted_hml'] and
+ state_cnab not in ['accepted', 'accepted_hml', 'done'])):
+ vals.pop('state_cnab', False)
+
+ if self.situacao_pagamento not in ['inicial', 'aberta']:
+ vals.pop('situacao_pagamento', False)
+
+ return super(AccountMoveLine, self).write(vals)
From dc6695860acbb864056b25ca66fcd1fd23e0315c Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Fri, 6 Dec 2019 16:06:14 -0300
Subject: [PATCH 177/612] [FIX] Bock assing outstanding credit in invoices paid
in credit card
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 1167d3db33b8..262bb8e7cd87 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -503,6 +503,12 @@ def invoice_validate(self):
@api.multi
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
+
+ if self.payment_term_id.payment_mode_selection == 'cartao':
+ raise UserError(_(
+ "Não é possível adicionar pagamentos em uma fatura "
+ "parcelada no cartão de crédito"
+ ))
if self.eval_situacao_pagamento in \
['paga', 'liquidada', 'baixa_liquidacao']:
raise UserError(_(
From d90021bb008c79df05895ab6f67472409c6b4708 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 18 Dec 2019 09:12:12 -0300
Subject: [PATCH 178/612] [NEW] Extraction erpbrasil.febraban from
l10n_br_account_payment_cobranca
---
.../__manifest__.py | 4 -
.../febraban/__init__.py | 6 -
.../febraban/boleto/__init__.py | 6 -
.../febraban/boleto/document.py | 350 -----------
.../febraban/cnab.py | 89 ---
.../febraban/cnab_240/__init__.py | 4 -
.../febraban/cnab_240/bancos/__init__.py | 6 -
.../febraban/cnab_240/bancos/bb.py | 65 --
.../febraban/cnab_240/bancos/bradesco.py | 67 --
.../febraban/cnab_240/bancos/bradesco.py.orig | 71 ---
.../febraban/cnab_240/bancos/cef.py | 92 ---
.../febraban/cnab_240/bancos/itau.py | 67 --
.../febraban/cnab_240/bancos/santander.py | 42 --
.../febraban/cnab_240/cnab_240.py | 574 ------------------
.../febraban/cnab_240/cnab_240.py.orig | 566 -----------------
.../febraban/cnab_400/__init__.py | 6 -
.../febraban/cnab_400/bancos/__init__.py | 4 -
.../febraban/cnab_400/bancos/bradesco.py | 97 ---
.../febraban/cnab_400/bancos/itau.py | 176 ------
.../febraban/cnab_400/cnab_400.py | 401 ------------
.../febraban/pag_for/__init__.py | 8 -
.../febraban/pag_for/bancos/__init__.py | 6 -
.../febraban/pag_for/bancos/bradesco.py | 60 --
.../febraban/pag_for/pag_for500.py | 573 -----------------
.../models/account_invoice.py | 128 +---
.../models/account_move_line.py | 30 +-
.../models/account_payment_mode.py | 6 +-
.../models/account_payment_order.py | 20 -
.../models/l10n_br_cnab.py | 137 +----
.../reports/report.py | 11 +-
30 files changed, 9 insertions(+), 3663 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/febraban/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/boleto/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/boleto/document.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
delete mode 100644 l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 4a7d7179d8f0..5226fddd85fb 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -13,10 +13,6 @@
'license': 'AGPL-3',
'author': 'KMEE, Odoo Community Association (OCA)',
'website': 'http://www.kmee.com.br',
- 'external_dependencies': {
- 'python': ['cnab240',
- 'pyboleto'],
- },
'depends': [
'base_transaction_id',
'l10n_br_account_payment_order',
diff --git a/l10n_br_account_payment_cobranca/febraban/__init__.py b/l10n_br_account_payment_cobranca/febraban/__init__.py
deleted file mode 100644
index 2cfbd6d7e782..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/__init__.py b/l10n_br_account_payment_cobranca/febraban/boleto/__init__.py
deleted file mode 100644
index 4338cb783c5d..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/boleto/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2012 KMEE
-# @author Luis Felipe Miléo
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-from . import document
diff --git a/l10n_br_account_payment_cobranca/febraban/boleto/document.py b/l10n_br_account_payment_cobranca/febraban/boleto/document.py
deleted file mode 100644
index b33e1d61eae1..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/boleto/document.py
+++ /dev/null
@@ -1,350 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA (Luis Felipe Mileo mileo@kmee.com.br)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from datetime import datetime, date
-import logging
-
-_logger = logging.getLogger(__name__)
-
-try:
- from pyboleto import bank
-except ImportError as err:
- _logger.debug = err
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-BoletoException = bank.BoletoException
-
-
-class Boleto:
- boleto = object
- account_number = ''
- account_digit = ''
-
- branch_number = ''
- branch_digit = ''
-
- nosso_numero = ''
-
- @staticmethod
- def getBoleto(move_line, nosso_numero):
- boleto_type = move_line.payment_mode_id.boleto_type
- if boleto_type:
- return dict_boleto[boleto_type][0](move_line, nosso_numero)
- raise BoletoException(u'Configure o tipo de boleto no modo de '
- u'pagamento')
-
- @staticmethod
- def getBoletoClass(move_line):
- bank_code = \
- move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bank_id.code_bc
- return bank.get_class_for_codigo(bank_code)
-
- def __init__(self, move_line, nosso_numero):
- self._cedente(move_line.company_id)
- self._sacado(move_line.partner_id)
- self._move_line(move_line)
- self.nosso_numero = str(nosso_numero)
-
- def getAccountNumber(self):
- if self.account_digit:
- return str(self.account_number + '-' +
- self.account_digit).encode('utf-8')
- return self.account_number.encode('utf-8')
-
- def getBranchNumber(self):
- if self.branch_digit:
- return str(self.branch_number + '-' +
- self.branch_digit).encode('utf-8')
- return self.branch_number.encode('utf-8')
-
- def _move_line(self, move_line):
- self._payment_mode(move_line.payment_mode_id)
- self._instructions(move_line.instrucoes)
- self.boleto.data_vencimento = datetime.date(datetime.strptime(
- move_line.date_maturity, '%Y-%m-%d'))
- self.boleto.data_documento = datetime.date(datetime.strptime(
- move_line.invoice_id.date_invoice, '%Y-%m-%d'))
- self.boleto.data_processamento = date.today()
- self.boleto.valor = str("%.2f" % move_line.residual if
- move_line.residual else
- move_line.debit or move_line.credit)
- self.boleto.valor_documento = str("%.2f" % move_line.residual if
- move_line.residual else
- move_line.debit or move_line.credit)
- self.boleto.especie = \
- move_line.currency_id and move_line.currency_id.symbol or 'R$'
- self.boleto.quantidade = '' # str("%.2f" % move_line.amount_currency)
- self.boleto.numero_documento = move_line.numero_documento
-
- def _instructions(self, instrucoes):
- """
- :param instrucoes:
- :return:
- """
- if instrucoes:
- for instrucao in instrucoes.split('\n'):
- self.boleto.instrucoes.append(instrucao)
-
- def _payment_mode(self, payment_mode_id):
- """
- :param payment_mode:
- :return:
- """
- self.boleto.convenio = payment_mode_id.boleto_convenio
- self.boleto.especie_documento = payment_mode_id.boleto_modalidade
- self.boleto.aceite = payment_mode_id.boleto_aceite
- self.boleto.carteira = str(payment_mode_id.boleto_carteira)
-
- def _cedente(self, company):
- """
- :param company:
- :return:
- """
- self.boleto.cedente = company.partner_id.legal_name.encode('utf-8')
- self.boleto.cedente_documento = company.cnpj_cpf.encode('utf-8')
- self.boleto.cedente_bairro = company.district
- self.boleto.cedente_cep = company.zip
- self.boleto.cedente_cidade = company.l10n_br_city_id.name
- self.boleto.cedente_logradouro = \
- company.street + ', ' + company.number
- self.boleto.cedente_uf = company.state_id.code
- self.boleto.agencia_cedente = self.getBranchNumber()
- self.boleto.conta_cedente = self.getAccountNumber()
-
- def _sacado(self, partner):
- """
-
- :param partner:
- :return:
- """
- self.boleto.sacado_endereco = \
- partner.street + ', ' + partner.number
- self.boleto.sacado_cidade = partner.l10n_br_city_id.name
- self.boleto.sacado_bairro = partner.district or ''
- self.boleto.sacado_uf = partner.state_id.code
- self.boleto.sacado_cep = partner.zip
- self.boleto.sacado_nome = partner.legal_name
- self.boleto.sacado_documento = partner.cnpj_cpf
-
- @classmethod
- def get_pdfs(cls, boleto_list):
- """
-
- :param boletoList:
- :return:
- """
- fbuffer = StringIO()
-
- fbuffer.reset()
- from pyboleto.pdf import BoletoPDF
-
- boleto = BoletoPDF(fbuffer)
- for i in range(len(boleto_list)):
- boleto.drawBoleto(boleto_list[i])
- boleto.nextPage()
- boleto.save()
- boleto_file = fbuffer.getvalue()
-
- fbuffer.close()
- return boleto_file
-
-
-class BoletoBB(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- # TODO: size o convenio and nosso numero, replace (7,2)
- # Size of convenio 4, 6, 7 or 8
- # Nosso Numero format. 1 or 2
- # Used only for convenio=6
- # 1: Nosso Numero with 5 positions
- # 2: Nosso Numero with 17 positions
- self.boleto = Boleto.getBoletoClass(move_line)(7, 2)
- self.account_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.acc_number
- self.branch_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoBarisul(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.acc_number
- self.branch_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoBradesco(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.acc_number
- self.branch_number = \
- move_line.payment_mode_id.fixed_journal_id. \
- bank_account_id.bra_number
- # bank specific
- self.account_digit = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number_dig
- self.branch_digit = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number_dig
- # end bank specific
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoCaixa(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- # bank specific
- self.account_digit = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number_dig
- # end bank specific
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoHsbc(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoItau157(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoItau(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoReal(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoSantander101(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.ios = '0'
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoStatander101201(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.ios = '0'
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoCaixaSigcb(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- from pyboleto.bank.caixa_sigcb import BoletoCaixaSigcb
- self.boleto = BoletoCaixaSigcb()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- # bank specific
- self.account_digit = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number_dig
- # end bank specific
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-class BoletoSicredi(Boleto):
-
- def __init__(self, move_line, nosso_numero):
- self.boleto = Boleto.getBoletoClass(move_line)()
- self.account_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.acc_number
- self.branch_number = move_line.payment_mode_id. \
- fixed_journal_id.bank_account_id.bra_number
- Boleto.__init__(self, move_line, nosso_numero)
- self.boleto.nosso_numero = self.nosso_numero
-
-
-dict_boleto = {
- '1': (BoletoBB, 'Banco do Brasil 18'),
- '2': (BoletoBarisul, 'Barisul x'),
- '3': (BoletoBradesco, 'Bradesco 06, 03'),
- '4': (BoletoCaixa, 'Caixa Economica SR'),
- '5': (BoletoHsbc, 'HSBC CNR CSB'),
- '6': (BoletoItau157, 'Itau 157'),
- '7': (BoletoItau, 'Itau 175, 174, 178, 104, 109'),
- '8': (BoletoReal, 'Real 57'),
- '9': (BoletoSantander101, 'Santander 102'),
- '10': (BoletoStatander101201, 'Santander 101, 201'),
- '11': (BoletoCaixaSigcb, 'Caixa Sigcb'),
- '12': (BoletoSicredi, 'Sicredi'),
-}
-
-
-def getBoletoSelection():
- list = []
- for i in dict_boleto:
- list.append((i, dict_boleto[i][1]))
- return list
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab.py b/l10n_br_account_payment_cobranca/febraban/cnab.py
deleted file mode 100644
index 869d227a2b01..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from __future__ import division, print_function, unicode_literals
-
-import logging
-import base64
-import codecs
-
-_logger = logging.getLogger(__name__)
-
-
-try:
- from cnab240.tipos import ArquivoCobranca400
-except ImportError as err:
- _logger.debug = (err)
-
-
-class Cnab(object):
-
- def __init__(self):
- self.arquivo = False
- self.cnab_type = False
-
- @staticmethod
- def get_cnab(bank, cnab_type='240'):
- if cnab_type == '240':
- from .cnab_240.cnab_240 import Cnab240
- return Cnab240.get_bank(bank)
- elif cnab_type == '400':
- from .cnab_400.cnab_400 import Cnab400
- return Cnab400.get_bank(bank)
- elif cnab_type == '500':
- from .pag_for.pag_for500 import PagFor500
- return PagFor500.get_bank(bank)
- else:
- return False
-
- @staticmethod
- def gerar_remessa(order):
- cnab = Cnab.get_cnab(
- order.company_partner_bank_id.bank_id.code_bc,
- order.payment_mode_id.payment_method_id.code
- )()
- return cnab.remessa(order)
-
- @staticmethod
- def detectar_retorno(cnab_file_object):
- arquivo_retono = base64.b64decode(cnab_file_object)
- f = open('/tmp/cnab_retorno.ret', 'wb')
- f.write(arquivo_retono)
- f.close()
- arquivo_retorno = codecs.open(
- '/tmp/cnab_retorno.ret',
- encoding='ascii'
- )
- header = arquivo_retorno.readline()
- arquivo_retorno.seek(0)
-
- if 210 < len(header) < 410:
- cnab_type = '400'
- banco = header[76:79]
- elif len(header) < 210:
- cnab_type = '240'
- banco = header[:3]
-
- cnab = Cnab.get_cnab(banco, cnab_type)()
- return cnab_type, cnab.retorno(arquivo_retorno)
-
- def retorno(self, arquivo_retorno):
- return ArquivoCobranca400(
- self.classe_retorno,
- arquivo=arquivo_retorno
- )
-
- def remessa(self, order):
- pass
-
- def convert_int(self, campo):
- if campo:
- return int(campo)
- # Retornamos de propósito vazio para que a cnab240 acuse o erro do
- # registro em branco pois, se retornarmos ZERO o erro vai passar
- # despercebido
- return ''
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
deleted file mode 100644
index 7813b32b4bc8..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
deleted file mode 100644
index 2cfbd6d7e782..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
deleted file mode 100644
index 5826a47b9484..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bb.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from __future__ import division, print_function, unicode_literals
-
-import re
-import string
-
-from ..cnab_240 import Cnab240
-
-
-class BB240(Cnab240):
-
- def __init__(self):
- super(Cnab240, self).__init__()
- from cnab240.bancos import bancodobrasil
- self.bank = bancodobrasil
-
- def _prepare_header(self):
- """
- Preparar header do arquivo.
- Adicionar informações no header do arquivo do Banco do Brasil
- """
- vals = super(BB240, self)._prepare_header()
- # vals['servico_servico'] = 1
- return vals
-
- def _prepare_cobranca(self, line):
- """
- Preparar o evento (segmentoA e segmentoB) apartir da payment.line
- :param line - payment.line
- :return: dict - Informações
- """
- vals = super(BB240, self)._prepare_cobranca(line)
- # vals['prazo_baixa'] = unicode(str(
- # vals['prazo_baixa']), "utf-8")
- # vals['desconto1_percentual'] = Decimal('0.00')
- # vals['valor_iof'] = Decimal('0.00')
- # # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- # vals['identificacao_titulo_banco'] = self.convert_int(
- # vals['identificacao_titulo_banco'])
- # vals['cedente_conta_dv'] = unicode(str(
- # vals['cedente_conta_dv']), "utf-8")
- # vals['cedente_agencia_dv'] = unicode(str(
- # vals['cedente_agencia_dv']), "utf-8")
- # vals['cedente_dv_ag_cc'] = unicode(str(
- # vals['cedente_dv_ag_cc']), "utf-8")
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
- # CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
-
- def str_to_unicode(inp_str):
- inp_str = unicode(inp_str, "utf-8")
- return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
deleted file mode 100644
index 7f9d5eb282b5..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import re
-import string
-from decimal import Decimal
-
-from ..cnab_240 import Cnab240
-
-
-class Bradesco240(Cnab240):
-
- def __init__(self):
- super(Cnab240, self).__init__()
- from cnab240.bancos import bradesco
- self.bank = bradesco
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
-
- vals = super(Bradesco240, self)._prepare_header()
- vals['servico_servico'] = 1
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Bradesco240, self)._prepare_cobranca(line)
- vals['prazo_baixa'] = unicode(str(
- vals['prazo_baixa']), "utf-8")
- vals['desconto1_percentual'] = Decimal('0.00')
- vals['valor_iof'] = Decimal('0.00')
- # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- vals['identificacao_titulo_banco'] = self.convert_int(
- vals['identificacao_titulo_banco'])
- vals['cedente_conta_dv'] = unicode(str(
- vals['cedente_conta_dv']), "utf-8")
- vals['cedente_agencia_dv'] = unicode(str(
- vals['cedente_agencia_dv']), "utf-8")
- vals['cedente_dv_ag_cc'] = unicode(str(
- vals['cedente_dv_ag_cc']), "utf-8")
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
- # CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
-
-
-def str_to_unicode(inp_str):
- inp_str = unicode(inp_str, "utf-8")
- return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
deleted file mode 100644
index 95d4537a20cb..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/bradesco.py.orig
+++ /dev/null
@@ -1,71 +0,0 @@
-# coding: utf-8
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-from ..cnab_240 import Cnab240
-import re
-import string
-from decimal import Decimal
-
-
-class Bradesco240(Cnab240):
-<<<<<<< HEAD
-=======
-
->>>>>>> [FIX] pep8 and merge clear
- def __init__(self):
- super(Cnab240, self).__init__()
- from cnab240.bancos import bradesco
- self.bank = bradesco
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
- vals = super(Bradesco240, self)._prepare_header()
- return vals
-
- def _prepare_segmento(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Bradesco240, self)._prepare_segmento(line)
- vals['prazo_baixa'] = unicode(str(
- vals['prazo_baixa']), "utf-8")
- vals['desconto1_percentual'] = Decimal('0.00')
- vals['valor_iof'] = Decimal('0.00')
- vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
- # CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
deleted file mode 100644
index 7e6e1c03ccd2..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/cef.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import re
-import string
-from decimal import Decimal
-
-from ..cnab_240 import Cnab240
-
-
-class Cef240(Cnab240):
-
- def __init__(self):
- super(Cnab240, self).__init__()
- from cnab240.bancos import cef
- self.bank = cef
-
- def _prepare_header(self):
- """
-
- :return:
- """
- vals = super(Cef240, self)._prepare_header()
- vals['cedente_dv_ag_cc'] = unicode(str(
- vals['cedente_dv_ag_cc']), "utf-8")
- vals['cedente_agencia_dv'] = unicode(str(
- vals['cedente_agencia_dv']), "utf-8")
- # TODO: adicionar campo para preencher o codigo do cedente no
- # cadastro da conta bancária
- vals['cedente_codigo_codCedente'] = 6088
- vals['nome_do_banco'] = u'CAIXA ECONOMICA FEDERAL'
- # Não pode pegar comentário da payment_line.
- vals['reservado_cedente_campo23'] = u'REMESSA TESTE'
- # reservado_banco_campo22 não é required. Código atualizado na
- # biblioteca cnab240
- vals['data_credito_hd_lote'] = 15052015
-
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Cef240, self)._prepare_cobranca(line)
-
- carteira, nosso_numero, digito = self.nosso_numero(
- line.move_line_id.transaction_ref)
-
- vals['cedente_dv_ag_cc'] = unicode(str(
- vals['cedente_dv_ag_cc']), "utf-8")
- # Informar o Número do Documento - Seu Número (mesmo das posições
- # 63-73 do Segmento P)
- vals['identificacao_titulo'] = unicode(str(
- vals['numero_documento']), "utf-8")
- # TODO: campo 27.3P CEF. Código do juros de mora
- vals['juros_cod_mora'] = 3
- vals['carteira_numero'] = self.convert_int(carteira)
- vals['nosso_numero'] = self.convert_int(nosso_numero)
- vals['nosso_numero_dv'] = self.convert_int(digito)
- vals['prazo_baixa'] = unicode(str(
- vals['prazo_baixa']), "utf-8")
-
- # Precisam estar preenchidos
- # Header lote
- # vals['servico_operacao'] = u'R'
- # vals['servico_servico'] = 1
- vals['cedente_conta_dv'] = unicode(str(
- vals['cedente_conta_dv']), "utf-8")
- vals['cedente_codigo_codCedente'] = 6088
- vals['data_credito_hd_lote'] = 15052015
-
- vals['desconto1_cod'] = 3
- vals['desconto1_data'] = 0
- vals['desconto1_percentual'] = Decimal('0.00')
- vals['valor_iof'] = Decimal('0.00')
-
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
- # CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = 14
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
deleted file mode 100644
index 0ebb6a40e564..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/itau.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import re
-import string
-
-from ..cnab_240 import Cnab240
-
-
-class Itau240(Cnab240):
- """
-
- """
-
- def __init__(self):
- """
-
- :return:
- """
- super(Cnab240, self).__init__()
- from cnab240.bancos import itau
- self.bank = itau
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
- vals = super(Itau240, self)._prepare_header()
- # vals['cedente_dv_ag_cc'] = self.convert_int(
- # vals['cedente_dv_ag_cc'])
- # vals['cedente_agencia_dv'] = self.convert_int(
- # vals['cedente_agencia_dv']),
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Itau240, self)._prepare_cobranca(line)
-
- carteira, nosso_numero, digito = self.nosso_numero(
- line.move_line_id.transaction_ref)
-
- vals['cedente_dv_ag_cc'] = self.convert_int(
- vals['cedente_dv_ag_cc'])
- vals['carteira_numero'] = self.convert_int(carteira)
- vals['nosso_numero'] = self.convert_int(nosso_numero)
- vals['nosso_numero_dv'] = self.convert_int(digito)
-
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos entre
- # CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
deleted file mode 100644
index e04fc80fb92c..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/bancos/santander.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from ..cnab_240 import Cnab240
-
-
-class Santander240(Cnab240):
- """
-
- """
-
- def __init__(self):
- """
-
- :return:
- """
- super(Cnab240, self).__init__()
- from cnab240.bancos import santander
- self.bank = santander
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
- vals = super(Santander240, self)._prepare_header()
- del vals['arquivo_hora_de_geracao']
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Santander240, self)._prepare_cobranca(line)
- return vals
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
deleted file mode 100644
index f38a96645d15..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py
+++ /dev/null
@@ -1,574 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from __future__ import division, print_function, unicode_literals
-
-import datetime
-import logging
-import re
-import string
-import time
-import unicodedata
-from decimal import Decimal
-
-from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
-
-from ..cnab import Cnab
-
-_logger = logging.getLogger(__name__)
-try:
- from cnab240.tipos import Arquivo, Lote
-except ImportError as err:
- _logger.debug = err
-
-
-class Cnab240(Cnab):
- """
- CNAB240
- """
-
- def __init__(self):
- super(Cnab, self).__init__()
-
- @staticmethod
- def get_bank(bank):
- '''
- Função chamada na criação do CNAB que dado o código do banco,
- instancia o objeto do banco e retorna o obj ao CNAB que sera criado.
- :param bank: str - Código do banco
- :return:
- '''
- if bank == '341':
- from .bancos.itau import Itau240
- return Itau240
- elif bank == '237':
- from .bancos.bradesco import Bradesco240
- return Bradesco240
- elif bank == '104':
- from .bancos.cef import Cef240
- return Cef240
- elif bank == '033':
- from .bancos.santander import Santander240
- return Santander240
- elif bank == '001':
- from .bancos.bb import BB240
- return BB240
- else:
- return Cnab240
-
- def get_inscricao_tipo(self, partner_id):
- # TODO: Implementar codigo para PIS/PASEP
- if partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_header(self):
- """
- Preparar o header do arquivo do CNAB
- :return: dict - Header do arquivo
- """
- header_arquivo = {
- # CONTROLE
- # 01.0
- 'controle_banco': self.convert_int(
- self.order.company_partner_bank_id.bank_id.code_bc
- ),
- # 02.0 # Sequencia para o Arquivo
- 'controle_lote': 1,
- # 03.0 0- Header do Arquivo
- 'controle_registro': 0,
- # 04.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
-
- # EMPRESA
- # 05.0 - 1 - CPF / 2 - CNPJ
- 'cedente_inscricao_tipo':
- self.get_inscricao_tipo(self.order.company_id.partner_id),
- # 06.0
- 'cedente_inscricao_numero':
- self.convert_int(punctuation_rm(self.order.company_id.cnpj_cpf)),
- # 07.0
- 'cedente_convenio': '0001222130126',
- # 08.0
- 'cedente_agencia':
- self.convert_int(self.order.company_partner_bank_id.bra_number),
- # 09.0
- 'cedente_agencia_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- # 10.0
- 'cedente_conta':
- self.convert_int(punctuation_rm(
- self.order.company_partner_bank_id.acc_number)),
- # 11.0
- 'cedente_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig[0],
- # 12.0
- 'cedente_agencia_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig[1]
- if len(
- self.order.company_partner_bank_id.acc_number_dig
- ) > 1 else '',
- # 13.0
- 'cedente_nome':
- self.order.company_partner_bank_id.partner_id.legal_name[:30]
- if self.order.company_partner_bank_id.partner_id.legal_name
- else self.order.company_partner_bank_id.partner_id.name[:30],
- # 14.0
- 'nome_banco': self.order.company_partner_bank_id.bank_name,
- # 15.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
-
- # ARQUIVO
- # 16.0 Código Remessa = 1 / Retorno = 2
- 'arquivo_codigo': '1',
- # 17.0
- 'arquivo_data_de_geracao': self.data_hoje(),
- # 18.0
- 'arquivo_hora_de_geracao': self.hora_agora(),
- # 19.0 TODO: Número sequencial de arquivo
- 'arquivo_sequencia': self.convert_int(self.get_file_numeration()),
- # 20.0
- 'arquivo_layout': 103,
- # 21.0
- 'arquivo_densidade': 0,
- # 22.0
- 'reservado_banco': '',
- # 23.0
- 'reservado_empresa': 'EMPRESA 100',
- # 24.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
- }
-
- return header_arquivo
-
- def _prepare_header_lote(self):
- """
- Preparar o header de LOTE para arquivo do CNAB
- :return: dict - Header do arquivo
- """
- empresa = self.order.company_partner_bank_id.partner_id
-
- header_arquivo_lote = {
-
- # CONTROLE
- # 01.1
- 'controle_banco': self.convert_int(self.order.company_partner_bank_id.code_bc),
- # 02.1 Sequencia para o Arquivo
- 'controle_lote': 1,
- # 03.1 0- Header do Arquivo
- 'controle_registro': 1,
-
- # SERVICO
- # 04.1 # Header do lote sempre 'C'
- 'servico_operacao': 'C',
- # 05.1
- 'servico_servico': self.order.tipo_servico,
- # 06.1
- 'servico_forma_lancamento': 1,
- # 07.1
- 'servico_layout': 20,
- # 08.1
- # CNAB - Uso Exclusivo da FEBRABAN/CNAB
-
- # EMPRESA CEDENTE
- # 09.1
- 'empresa_inscricao_tipo': 2,
- # self.get_inscricao_tipo(self.order.company_id.partner_id),
- # 10.1
- 'empresa_inscricao_numero': punctuation_rm(empresa.cnpj_cpf),
- # 11.1
- 'cedente_convenio': self.order.codigo_convenio,
- # 12.1
- 'cedente_agencia':
- self.convert_int(self.order.company_partner_bank_id.bra_number),
- # 13.1
- 'cedente_agencia_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- # 14.1
- 'cedente_conta':
- self.convert_int(punctuation_rm(
- self.order.company_partner_bank_id.acc_number)),
- # 15.1
- 'cedente_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig[0],
- # 16.1
- 'cedente_agencia_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig[1]
- if len(
- self.order.company_partner_bank_id.acc_number_dig
- ) > 1 else '',
- # 17.1
- 'cedente_nome':
- self.order.company_partner_bank_id.partner_id.legal_name[:30]
- if self.order.company_partner_bank_id.partner_id.legal_name
- else self.order.company_partner_bank_id.partner_id.name[:30],
- # 18.1
- 'mensagem1': '',
-
- # ENDERECO
- # 19.1
- 'empresa_logradouro': empresa.street,
- # 20.1
- 'empresa_endereco_numero': empresa.number,
- # 21.1
- 'empresa_endereco_complemento': empresa.street2,
- # 22.1
- 'empresa_endereco_cidade': empresa.l10n_br_city_id.name,
- # 23.1
- 'empresa_endereco_cep': self.get_cep('prefixo', empresa.zip),
- # 24.1
- 'empresa_endereco_cep_complemento':
- self.get_cep('sufixo', empresa.zip),
- # 25.1
- 'empresa_endereco_estado': empresa.state_id.code,
-
- # 26.1
- 'indicativo_forma_pagamento': '',
- # 27.1
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
- # 28.1
- 'ocorrencias': '',
- }
- return header_arquivo_lote
-
- def get_file_numeration(self):
- # Função para retornar a numeração sequencial do arquivo
- return 1
-
- def _prepare_cobranca(self, line):
- """
- :param line:
- :return:
- """
- # prefixo, sufixo = self.cep(line.partner_id.zip)
-
- aceite = u'N'
- if not self.order.payment_mode_id.boleto_aceite == 'S':
- aceite = u'A'
-
- # Código agencia do cedente
- # cedente_agencia = cedente_agencia
-
- # Dígito verificador da agência do cedente
- # cedente_agencia_conta_dv = cedente_agencia_dv
-
- # Código da conta corrente do cedente
- # cedente_conta = cedente_conta
-
- # Dígito verificador da conta corrente do cedente
- # cedente_conta_dv = cedente_conta_dv
-
- # Dígito verificador de agencia e conta
- # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
-
- return {
- 'controle_banco': self.convert_int(
- self.order.company_partner_bank_id.code_bc),
- 'cedente_agencia': self.convert_int(
- self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': self.convert_int(
- self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig,
- 'cedente_agencia_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- 'identificacao_titulo': u'0000000', # TODO
- 'identificacao_titulo_banco': u'0000000', # TODO
- 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
- 'numero_documento': line.name,
- 'vencimento_titulo': self.format_date(
- line.ml_maturity_date),
- 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
- # TODO: fépefwfwe
- # TODO: Código adotado para identificar o título de cobrança.
- # 8 é Nota de cŕedito comercial
- 'especie_titulo': self.convert_int(self.order.payment_mode_id.boleto_especie),
- 'aceite_titulo': aceite,
- 'data_emissao_titulo': self.format_date(
- line.ml_date_created),
- # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
- # CEF/FEBRABAN e Itaú não tem.
- 'juros_mora_data': self.format_date(
- line.ml_maturity_date),
- 'juros_mora_taxa_dia': Decimal('0.00'),
- 'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': self.convert_int(
- self.get_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)) or '',
- 'sacado_nome': line.partner_id.legal_name,
- 'sacado_endereco': (
- line.partner_id.street + ' ' + line.partner_id.number),
- 'sacado_bairro': line.partner_id.district or '',
- 'sacado_cep':
- self.get_cep('prefixo', line.partner_id.zip),
- 'sacado_cep_sufixo':
- self.get_cep('sufixo', line.partner_id.zip),
- 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
- 'sacado_uf': line.partner_id.state_id.code,
- 'codigo_protesto':
- self.convert_int(self.order.payment_mode_id.boleto_protesto),
- 'prazo_protesto':
- self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo),
- 'codigo_baixa': 2,
- 'prazo_baixa': 0, # De 5 a 120 dias.
- 'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira':
- self.convert_int(self.order.payment_mode_id.boleto_carteira),
- }
-
- def _prepare_pagamento(self, line):
- """
- Prepara um dict para preencher os valores do segmento A e B apartir de
- uma linha da payment.order e insere informações que irão compor o
- header do lote
- :param line: payment.line - linha que sera base para evento
- :return: dict - Dict contendo todas informações dos segmentos
- """
- vals = {
-
- # SEGMENTO A
- # CONTROLE
- # 01.3A
- 'controle_banco':
- self.convert_int(self.order.company_partner_bank_id.code_bc),
- # 02.3A
- 'controle_lote': 1,
- # 03.3A - 3-Registros Iniciais do Lote
- 'controle_registro': 3,
-
- # SERVICO
- # 04.3A - Nº Seqüencial do Registro - Inicia em 1 em cada novo lote
- # TODO: Contador para o sequencial do lote
- 'servico_numero_registro': 1,
- # 05.3A
- # Segmento Código de Segmento do Reg.Detalhe
- # 06.3A
- 'servico_tipo_movimento': self.order.tipo_movimento,
- # 07.3A
- 'servico_codigo_movimento': self.order.codigo_instrucao_movimento,
-
- # FAVORECIDO
- # 08.3A - 018-TED 700-DOC
- 'favorecido_camara': 0,
- # 09.3A
- 'favorecido_banco': self.convert_int(line.bank_id.code_bc),
- # 10.3A
- 'favorecido_agencia': self.convert_int(line.bank_id.bra_number),
- # 11.3A
- 'favorecido_agencia_dv': line.bank_id.bra_number_dig,
- # 12.3A
- 'favorecido_conta': punctuation_rm(line.bank_id.acc_number),
- # 13.3A
- 'favorecido_conta_dv': line.bank_id.acc_number_dig[0]
- if line.bank_id.acc_number_dig else '',
- # 14.3A
- 'favorecido_dv': line.bank_id.acc_number_dig[1]
- if len(line.bank_id.bra_number_dig or '') > 1 else '',
- # 15.3A
- 'favorecido_nome': line.partner_id.name,
-
- # CREDITO
- # 16.3A -
- 'credito_seu_numero': line.name,
- # 17.3A
- 'credito_data_pagamento': self.format_date(line.date),
- # 18.3A
- 'credito_moeda_tipo': line.currency.name,
- # 19.3A
- 'credito_moeda_quantidade': Decimal('0.00000'),
- # 20.3A
- 'credito_valor_pagamento':
- Decimal(str(line.amount_currency)).quantize(Decimal('1.00')),
- # 21.3A
- # 'credito_nosLoteso_numero': '',
- # 22.3A
- # 'credito_data_real': '',
- # 23.3A
- # 'credito_valor_real': '',
-
- # INFORMAÇÔES
- # 24.3A
- # 'outras_informacoes': '',
- # 25.3A
- # 'codigo_finalidade_doc': line.codigo_finalidade_doc,
- # 26.3A
- 'codigo_finalidade_ted': line.codigo_finalidade_ted or '',
- # 27.3A
- 'codigo_finalidade_complementar':
- line.codigo_finalidade_complementar or '',
- # 28.3A
- # CNAB - Uso Exclusivo FEBRABAN/CNAB
- # 29.3A
- # 'aviso_ao_favorecido': line.aviso_ao_favorecido,
- 'aviso_ao_favorecido': 0,
- # 'ocorrencias': '',
-
- # SEGMENTO B
- # Preenchido no segmento A
- # 01.3B
- # 02.3B
- # 03.3B
-
- # 04.3B
- # 05.3B
- # 06.3B
-
- # DADOS COMPLEMENTARES - FAVORECIDOS
- # 07.3B
- 'favorecido_tipo_inscricao':
- self.get_inscricao_tipo(line.partner_id),
- # 08.3B
- 'favorecido_num_inscricao': line.partner_id.cnpj_cpf and
- self.convert_int(punctuation_rm(line.partner_id.cnpj_cpf)) or '',
- # 09.3B
- 'favorecido_endereco_rua': line.partner_id.street or '',
- # 10.3B
- 'favorecido_endereco_num': self.convert_int(line.partner_id.number) or 0,
- # 11.3B
- 'favorecido_endereco_complemento': line.partner_id.street2 or '',
- # 12.3B
- 'favorecido_endereco_bairro': line.partner_id.district or '',
- # 13.3B
- 'favorecido_endereco_cidade':
- line.partner_id.l10n_br_city_id.name or '',
- # 14.3B
- # 'favorecido_cep': self.convert_int(line.partner_id.zip[:5]) or 0,
- 'favorecido_cep': self.get_cep('prefixo', line.partner_id.zip),
- # 15.3B
- 'favorecido_cep_complemento':
- self.get_cep('sufixo', line.partner_id.zip),
- # 16.3B
- 'favorecido_estado': line.partner_id.state_id.code or '',
-
- # DADOS COMPLEMENTARES - PAGAMENTO
- # 17.3B
- 'pagamento_vencimento': 0,
- # 18.3B
- 'pagamento_valor_documento': Decimal('0.00'),
- # 19.3B
- 'pagamento_abatimento': Decimal('0.00'),
- # 20.3B
- 'pagamento_desconto': Decimal('0.00'),
- # 21.3B
- 'pagamento_mora': Decimal('0.00'),
- # 22.3B
- 'pagamento_multa': Decimal('0.00'),
- # 23.3B
- # TODO: Verificar se este campo é retornado no retorno
- # 'cod_documento_favorecido': '',
- # 24.3B - Informado No SegmentoA
- # 'aviso_ao_favorecido': '0',
- # 25.3B
- # 'codigo_ug_centralizadora': '0',
- # 26.3B
- # 'codigo_ispb': '0',
- }
- return vals
-
- def _adicionar_evento(self, line):
- """
- Adicionar o evento no arquivo de acordo com seu tipo
- """
- # if self.order.payment_order_type == 'payment':
- # incluir = self.arquivo.incluir_debito_pagamento
- # prepare = self._prepare_pagamento
- # else:
- # incluir = self.arquivo.incluir_cobranca
- # prepare = self._prepare_cobranca
- pass
-
- def remessa(self, order):
- """
- Cria a remessa de eventos que sera anexada ao arquivo
- :param order: payment.order
- :return: Arquivo Cnab pronto para download
- """
- # cobrancasimples_valor_titulos = 0
-
- self.order = order
-
- # Preparar Header do Arquivo
- self.arquivo = Arquivo(self.bank, **self._prepare_header())
-
- if order.payment_order_type == 'payment':
- incluir = self.arquivo.incluir_debito_pagamento
- prepare = self._prepare_pagamento
-
- header = self.bank.registros.HeaderLotePagamento(
- **self._prepare_header_lote())
-
- trailer = self.bank.registros.TrailerLotePagamento()
- trailer.somatoria_valores = Decimal('0.00')
- trailer.somatoria_quantidade_moedas = Decimal('0.00000')
-
- lote_pagamento = Lote(self.bank, header, trailer)
- self.arquivo.adicionar_lote(lote_pagamento)
-
- else:
- incluir = self.arquivo.incluir_cobranca
- prepare = self._prepare_cobranca
-
- for line in order.bank_line_ids:
- # para cada linha da payment order adicoinar como um novo evento
- # self._adicionar_evento(line)
- # try:
- incluir(tipo_lote=30, **prepare(line))
- # except:
- # from odoo import exceptions
- # raise exceptions.ValidationError("Erro")
- # self.arquivo.lotes[0].header.servico_servico = 30
- # TODO: tratar soma de tipos de cobranca
- # cobrancasimples_valor_titulos += line.amount_currency
- # self.arquivo.lotes[0].trailer.cobrancasimples_valor_titulos = \
- # Decimal(cobrancasimples_valor_titulos).quantize(
- # Decimal('1.00'))
-
- remessa = unicode(self.arquivo)
- return unicodedata.normalize(
- 'NFKD', remessa).encode('ascii', 'ignore')
-
- def get_cep(self, tipo, value):
- '''
- :param tipo:
- :param value:
- :return:
- '''
- if not value:
- if tipo == 'prefixo':
- return 0
- else:
- return ''
- value = punctuation_rm(value)
- sufixo = value[-3:]
- prefixo = value[:5]
- if tipo == 'sufixo':
- return sufixo
- else:
- return prefixo
-
- def format_date(self, srt_date):
- if not srt_date:
- return 0
- return self.convert_int(datetime.datetime.strptime(
- srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
-
- def data_hoje(self):
- return (self.convert_int(time.strftime("%d%m%Y")))
-
- def hora_agora(self):
- return (self.convert_int(time.strftime("%H%M%S")))
-
- def nosso_numero(self, format):
- """
- Hook para ser sobrescrito e adicionar informação
- :param format:
- :return:
- """
- pass
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig b/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
deleted file mode 100644
index 1fabc0a2c0b9..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_240/cnab_240.py.orig
+++ /dev/null
@@ -1,566 +0,0 @@
-# coding: utf-8
-# ###########################################################################
-#
-# Author: Luis Felipe Mileo
-# Fernando Marcato Rodrigues
-# Daniel Sadamo Hirayama
-# Copyright 2015 KMEE - www.kmee.com.br
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from __future__ import division, print_function, unicode_literals
-
-import datetime
-import logging
-import re
-import string
-import time
-import unicodedata
-from decimal import Decimal
-
-from openerp.addons.l10n_br_base.tools.misc import punctuation_rm
-
-from ..cnab import Cnab
-
-_logger = logging.getLogger(__name__)
-try:
-<<<<<<< HEAD
- from cnab240.tipos import Arquivo
- from cnab240.errors import (Cnab240Error)
-=======
- from cnab240.tipos import Arquivo, Lote
->>>>>>> fixup! [FIX] Flake8
-except ImportError as err:
- _logger.debug = err
-
-
-class Cnab240(Cnab):
- """
- CNAB240
- """
-
- def __init__(self):
- super(Cnab, self).__init__()
-
- @staticmethod
- def get_bank(bank):
- '''
- Função chamada na criação do CNAB que dado o código do banco,
- instancia o objeto do banco e retorna o obj ao CNAB que sera criado.
- :param bank: str - Código do banco
- :return:
- '''
- if bank == '341':
- from .bancos.itau import Itau240
- return Itau240
- elif bank == '237':
- from .bancos.bradesco import Bradesco240
- return Bradesco240
- elif bank == '104':
- from .bancos.cef import Cef240
- return Cef240
- elif bank == '033':
- from .bancos.santander import Santander240
- return Santander240
- elif bank == '001':
- from .bancos.bb import BB240
- return BB240
- else:
- return Cnab240
-
- def inscricao_tipo(self, partner_id):
- # TODO: Implementar codigo para PIS/PASEP
- if partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_header(self):
- """
- Preparar o header do arquivo do CNAB
- :return: dict - Header do arquivo
- """
- header_arquivo = {
- # CONTROLE
- # 01.0
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- # 02.0 # Sequencia para o Arquivo
- 'controle_lote': 1,
- # 03.0 0- Header do Arquivo
- 'controle_registro': 0,
- # 04.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
-
- # EMPRESA
- # 05.0 - 1 - CPF / 2 - CNPJ
- 'cedente_inscricao_tipo':
- self.get_inscricao_tipo(self.order.company_id.partner_id),
- # 06.0
- 'cedente_inscricao_numero':
- int(punctuation_rm(self.order.company_id.cnpj_cpf)),
- # 07.0
- 'cedente_convenio': '0001222130126',
- # 08.0
- 'cedente_agencia':
- int(self.order.mode.bank_id.bra_number),
- # 09.0
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
- # 10.0
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- # 11.0
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
- # 12.0
- 'cedente_agencia_conta_dv':
- self.order.mode.bank_id.acc_number_dig[1]
- if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
- # 13.0
- 'cedente_nome':
- self.order.mode.bank_id.partner_id.legal_name[:30],
- # 14.0
- 'nome_banco': self.order.mode.bank_id.bank_name,
- # 15.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
-
- # ARQUIVO
- # 16.0 Código Remessa = 1 / Retorno = 2
- 'arquivo_codigo': '1',
- # 17.0
- 'arquivo_data_de_geracao': self.data_hoje(),
- # 18.0
- 'arquivo_hora_de_geracao': self.hora_agora(),
- # 19.0 TODO: Número sequencial de arquivo
- 'arquivo_sequencia': int(self.get_file_numeration()),
- # 20.0
- 'arquivo_layout': 103,
- # 21.0
- 'arquivo_densidade': 0,
- # 22.0
- 'reservado_banco': '',
- # 23.0
- 'reservado_empresa': 'EMPRESA 100',
- # 24.0
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
- }
-
- return header_arquivo
-
- def _prepare_header_lote(self):
- """
- Preparar o header de LOTE para arquivo do CNAB
- :return: dict - Header do arquivo
- """
- empresa = self.order.mode.bank_id.partner_id
-
- header_arquivo_lote = {
-
- # CONTROLE
- # 01.1
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- # 02.1 Sequencia para o Arquivo
- 'controle_lote': 1,
- # 03.1 0- Header do Arquivo
- 'controle_registro': 1,
-
- # SERVICO
- # 04.1 # Header do lote sempre 'C'
- 'servico_operacao': 'C',
- # 05.1
- 'servico_servico': self.order.tipo_servico,
- # 06.1
- 'servico_forma_lancamento': 1,
- # 07.1
- 'servico_layout': 20,
- # 08.1
- # CNAB - Uso Exclusivo da FEBRABAN/CNAB
-
- # EMPRESA CEDENTE
- # 09.1
- 'empresa_inscricao_tipo': 2,
- # self.get_inscricao_tipo(self.order.company_id.partner_id),
- # 10.1
- 'empresa_inscricao_numero': punctuation_rm(empresa.cnpj_cpf),
- # 11.1
- 'cedente_convenio': self.order.codigo_convenio,
- # 12.1
- 'cedente_agencia':
- int(self.order.mode.bank_id.bra_number),
- # 13.1
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
- # 14.1
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- # 15.1
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig[0],
- # 16.1
- 'cedente_agencia_conta_dv':
- self.order.mode.bank_id.acc_number_dig[1]
- if len(self.order.mode.bank_id.acc_number_dig) > 1 else '',
- # 17.1
- 'cedente_nome':
- self.order.mode.bank_id.partner_id.legal_name[:30],
- # 18.1
- 'mensagem1': '',
-
- # ENDERECO
- # 19.1
- 'empresa_logradouro': empresa.street,
- # 20.1
- 'empresa_endereco_numero': empresa.number,
- # 21.1
- 'empresa_endereco_complemento': empresa.street2,
- # 22.1
- 'empresa_endereco_cidade': empresa.l10n_br_city_id.name,
- # 23.1
- 'empresa_endereco_cep': self.get_cep('prefixo', empresa.zip),
- # 24.1
- 'empresa_endereco_cep_complemento':
- self.get_cep('sufixo', empresa.zip),
- # 25.1
- 'empresa_endereco_estado': empresa.state_id.code,
-
- # 26.1
- 'indicativo_forma_pagamento': '',
- # 27.1
- # CNAB - Uso Exclusivo FEBRABAN / CNAB
- # 28.1
- 'ocorrencias': '',
- }
- return header_arquivo_lote
-
- def get_file_numeration(self):
- # Função para retornar a numeração sequencial do arquivo
- return 1
-
- def sacado_inscricao_tipo(self, partner_id):
- # TODO: Implementar codigo para PIS/PASEP
- if partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_cobranca(self, line):
- """
- :param line:
- :return:
- """
- # prefixo, sulfixo = self.cep(line.partner_id.zip)
-
- aceite = u'N'
- if not self.order.mode.boleto_aceite == 'S':
- aceite = u'A'
-
- # Código agencia do cedente
- # cedente_agencia = cedente_agencia
-
- # Dígito verificador da agência do cedente
- # cedente_agencia_conta_dv = cedente_agencia_dv
-
- # Código da conta corrente do cedente
- # cedente_conta = cedente_conta
-
- # Dígito verificador da conta corrente do cedente
- # cedente_conta_dv = cedente_conta_dv
-
- # Dígito verificador de agencia e conta
- # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
-
- return {
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- 'cedente_agencia': int(self.order.mode.bank_id.bra_number),
- 'cedente_conta': int(self.order.mode.bank_id.acc_number),
- 'cedente_conta_dv': self.order.mode.bank_id.acc_number_dig,
- 'cedente_agencia_dv': self.order.mode.bank_id.bra_number_dig,
- 'identificacao_titulo': u'0000000', # TODO
- 'identificacao_titulo_banco': u'0000000', # TODO
- 'identificacao_titulo_empresa': line.move_line_id.move_id.name,
- 'numero_documento': line.name,
- 'vencimento_titulo': self.format_date(
- line.ml_maturity_date),
- 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
- # TODO: fépefwfwe
- # TODO: Código adotado para identificar o título de cobrança.
- # 8 é Nota de cŕedito comercial
- 'especie_titulo': int(self.order.mode.boleto_especie),
- 'aceite_titulo': aceite,
- 'data_emissao_titulo': self.format_date(
- line.ml_date_created),
- # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
- # CEF/FEBRABAN e Itaú não tem.
- 'juros_mora_data': self.format_date(
- line.ml_maturity_date),
- 'juros_mora_taxa_dia': Decimal('0.00'),
- 'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': int(
- self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': int(
- self.rmchar(line.partner_id.cnpj_cpf)),
- 'sacado_nome': line.partner_id.legal_name,
- 'sacado_endereco': (
- line.partner_id.street + ' ' + line.partner_id.number),
- 'sacado_bairro': line.partner_id.district,
- 'sacado_cep': int(prefixo),
- 'sacado_cep_sufixo': int(sulfixo),
- 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
- 'sacado_uf': line.partner_id.state_id.code,
- 'codigo_protesto': int(self.order.mode.boleto_protesto),
- 'prazo_protesto': int(self.order.mode.boleto_protesto_prazo),
- 'codigo_baixa': 2,
- 'prazo_baixa': 0, # De 5 a 120 dias.
- 'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': int(self.order.mode.boleto_carteira),
- }
-
- def _prepare_pagamento(self, line):
- """
- Prepara um dict para preencher os valores do segmento A e B apartir de
- uma linha da payment.order e insere informações que irão compor o
- header do lote
- :param line: payment.line - linha que sera base para evento
- :return: dict - Dict contendo todas informações dos segmentos
- """
- vals = {
-
- # SEGMENTO A
- # CONTROLE
- # 01.3A
- 'controle_banco': int(self.order.mode.bank_id.bank_bic),
- # 02.3A
- 'controle_lote': 1,
- # 03.3A - 3-Registros Iniciais do Lote
- 'controle_registro': 3,
-
- # SERVICO
- # 04.3A - Nº Seqüencial do Registro - Inicia em 1 em cada novo lote
- # TODO: Contador para o sequencial do lote
- 'servico_numero_registro': 1,
- # 05.3A
- # Segmento Código de Segmento do Reg.Detalhe
- # 06.3A
- 'servico_tipo_movimento': self.order.tipo_movimento,
- # 07.3A
- 'servico_codigo_movimento': self.order.codigo_instrucao_movimento,
-
- # FAVORECIDO
- # 08.3A - 018-TED 700-DOC
- 'favorecido_camara': 0,
- # 09.3A
- 'favorecido_banco': int(line.bank_id.bank_bic),
- # 10.3A
- 'favorecido_agencia': int(line.bank_id.bra_number),
- # 11.3A
- 'favorecido_agencia_dv': line.bank_id.bra_number_dig,
- # 12.3A
- 'favorecido_conta': punctuation_rm(line.bank_id.acc_number),
- # 13.3A
- 'favorecido_conta_dv': line.bank_id.acc_number_dig[0]
- if line.bank_id.acc_number_dig else '',
- # 14.3A
- 'favorecido_dv': line.bank_id.acc_number_dig[1]
- if len(line.bank_id.bra_number_dig or '') > 1 else '',
- # 15.3A
- 'favorecido_nome': line.partner_id.name,
-
- # CREDITO
- # 16.3A -
- 'credito_seu_numero': line.name,
- # 17.3A
- 'credito_data_pagamento': self.format_date(line.date),
- # 18.3A
- 'credito_moeda_tipo': line.currency.name,
- # 19.3A
- 'credito_moeda_quantidade': Decimal('0.00000'),
- # 20.3A
- 'credito_valor_pagamento':
- Decimal(str(line.amount_currency)).quantize(Decimal('1.00')),
- # 21.3A
- # 'credito_nosLoteso_numero': '',
- # 22.3A
- # 'credito_data_real': '',
- # 23.3A
- # 'credito_valor_real': '',
-
- # INFORMAÇÔES
- # 24.3A
- # 'outras_informacoes': '',
- # 25.3A
- # 'codigo_finalidade_doc': line.codigo_finalidade_doc,
- # 26.3A
- 'codigo_finalidade_ted': line.codigo_finalidade_ted or '',
- # 27.3A
- 'codigo_finalidade_complementar':
- line.codigo_finalidade_complementar or '',
- # 28.3A
- # CNAB - Uso Exclusivo FEBRABAN/CNAB
- # 29.3A
- # 'aviso_ao_favorecido': line.aviso_ao_favorecido,
- 'aviso_ao_favorecido': 0,
- # 'ocorrencias': '',
-
- # SEGMENTO B
- # Preenchido no segmento A
- # 01.3B
- # 02.3B
- # 03.3B
-
- # 04.3B
- # 05.3B
- # 06.3B
-
- # DADOS COMPLEMENTARES - FAVORECIDOS
- # 07.3B
- 'favorecido_tipo_inscricao':
- self.get_inscricao_tipo(line.partner_id),
- # 08.3B
- 'favorecido_num_inscricao':
- int(punctuation_rm(line.partner_id.cnpj_cpf)),
- # 09.3B
- 'favorecido_endereco_rua': line.partner_id.street or '',
- # 10.3B
- 'favorecido_endereco_num': int(line.partner_id.number) or 0,
- # 11.3B
- 'favorecido_endereco_complemento': line.partner_id.street2 or '',
- # 12.3B
- 'favorecido_endereco_bairro': line.partner_id.district or '',
- # 13.3B
- 'favorecido_endereco_cidade':
- line.partner_id.l10n_br_city_id.name or '',
- # 14.3B
- # 'favorecido_cep': int(line.partner_id.zip[:5]) or 0,
- 'favorecido_cep': self.get_cep('prefixo', line.partner_id.zip),
- # 15.3B
- 'favorecido_cep_complemento':
- self.get_cep('sufixo', line.partner_id.zip),
- # 16.3B
- 'favorecido_estado': line.partner_id.state_id.code or '',
-
- # DADOS COMPLEMENTARES - PAGAMENTO
- # 17.3B
- 'pagamento_vencimento': 0,
- # 18.3B
- 'pagamento_valor_documento': Decimal('0.00'),
- # 19.3B
- 'pagamento_abatimento': Decimal('0.00'),
- # 20.3B
- 'pagamento_desconto': Decimal('0.00'),
- # 21.3B
- 'pagamento_mora': Decimal('0.00'),
- # 22.3B
- 'pagamento_multa': Decimal('0.00'),
- # 23.3B
- # TODO: Verificar se este campo é retornado no retorno
- # 'cod_documento_favorecido': '',
- # 24.3B - Informado No SegmentoA
- # 'aviso_ao_favorecido': '0',
- # 25.3B
- # 'codigo_ug_centralizadora': '0',
- # 26.3B
- # 'codigo_ispb': '0',
- }
- return vals
-
- def _adicionar_evento(self, line):
- """
- Adicionar o evento no arquivo de acordo com seu tipo
- """
- # if self.order.payment_order_type == 'payment':
- # incluir = self.arquivo.incluir_debito_pagamento
- # prepare = self._prepare_pagamento
- # else:
- # incluir = self.arquivo.incluir_cobranca
- # prepare = self._prepare_cobranca
- pass
-
- def remessa(self, order):
- """
- Cria a remessa de eventos que sera anexada ao arquivo
- :param order: payment.order
- :return: Arquivo Cnab pronto para download
- """
- # cobrancasimples_valor_titulos = 0
-
- self.order = order
-
- # Preparar Header do Arquivo
- self.arquivo = Arquivo(self.bank, **self._prepare_header())
-
- if order.payment_order_type == 'payment':
- incluir = self.arquivo.incluir_debito_pagamento
- prepare = self._prepare_pagamento
- else:
- incluir = self.arquivo.incluir_cobranca
- prepare = self._prepare_cobranca
-
- for line in order.bank_line_ids:
- # para cada linha da payment order adicoinar como um novo evento
- # self._adicionar_evento(line)
- # try:
- incluir(**prepare(line))
- # except:
- # from openerp import exceptions
- # raise exceptions.ValidationError("Erro")
- self.arquivo.lotes[0].header.servico_servico = 1
- # TODO: tratar soma de tipos de cobranca
- # cobrancasimples_valor_titulos += line.amount_currency
- # self.arquivo.lotes[0].trailer.cobrancasimples_valor_titulos = \
- # Decimal(cobrancasimples_valor_titulos).quantize(
- # Decimal('1.00'))
-
- remessa = unicode(self.arquivo)
- return unicodedata.normalize(
- 'NFKD', remessa).encode('ascii', 'ignore')
-
- def get_cep(self, tipo, value):
- '''
- :param tipo:
- :param value:
- :return:
- '''
- if not value:
- if tipo == 'prefixo':
- return 0
- else:
- return ''
- value = punctuation_rm(value)
- sulfixo = format[-3:]
- prefixo = format[:5]
- if tipo == 'sulfixo':
- return sulfixo
- else:
- return prefixo
-
- def format_date(self, srt_date):
- if not srt_date:
- return 0
- return int(datetime.datetime.strptime(
- srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
-
- def data_hoje(self):
- return (int(time.strftime("%d%m%Y")))
-
- def hora_agora(self):
- return (int(time.strftime("%H%M%S")))
-
- def rmchar(self, format):
- return re.sub('[%s]' % re.escape(string.punctuation), '',
- format or '')
-
- def nosso_numero(self, format):
- """
- Hook para ser sobrescrito e adicionar informação
- :param format:
- :return:
- """
- pass
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
deleted file mode 100644
index 2cfbd6d7e782..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
deleted file mode 100644
index 5d3fd105cafb..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
deleted file mode 100644
index 373af4681665..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/bradesco.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-
-import re
-import string
-from decimal import Decimal
-
-from ..cnab_400 import Cnab400
-
-
-class Bradesco400(Cnab400):
-
- def __init__(self):
- super(Cnab400, self).__init__()
- from cnab240.bancos import bradesco_cobranca_400
- self.bank = bradesco_cobranca_400
- self.controle_linha = 2
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
-
- vals = super(Bradesco400, self)._prepare_header()
- vals['servico_servico'] = 1
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- vals = super(Bradesco400, self)._prepare_cobranca(line)
- vals['prazo_baixa'] = unicode(str(
- vals['prazo_baixa']), "utf-8")
- vals['desconto1_percentual'] = Decimal('0.00')
- vals['valor_iof'] = Decimal('0.00')
- # vals['cobrancasimples_valor_titulos'] = Decimal('02.00')
- vals['identificacao_titulo_banco'] = self.convert_int(
- vals['identificacao_titulo_banco'])
- vals['cedente_conta_dv'] = unicode(str(
- vals['cedente_conta_dv']), "utf-8")
- vals['cedente_agencia_dv'] = unicode(str(
- vals['cedente_agencia_dv']), "utf-8")
- # vals['cedente_dv_ag_cc'] = unicode(str(
- # vals['cedente_dv_ag_cc']), "utf-8")
-
- vals['sacado_cc_dv'] = u'0'
- vals['identificacao_empresa_beneficiaria_banco'] = \
- self.retorna_id_empr_benef()
- vals['digito_conferencia_numero_bancario'] = u'0'
- vals['condicao_emissao_papeleta'] = 1
-
- vals['indicador_rateio_credito'] = u""
- self.controle_linha += 1
-
- return vals
-
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
-
- def retorna_id_empr_benef(self):
- dig_cart = 3
- dig_ag = 5
- dig_conta = 7
-
- carteira = self.adiciona_digitos(
- self.order.payment_mode_id.boleto_carteira, dig_cart)
- agencia = self.adiciona_digitos(
- self.order.company_partner_bank_id.bra_number, dig_ag)
- conta = self.adiciona_digitos(
- self.order.company_partner_bank_id.acc_number, dig_conta)
-
- ident = u'0' + (carteira) + (agencia) + (conta) + \
- (self.order.company_partner_bank_id.acc_number_dig)
- return ident
-
- def adiciona_digitos(self, campo, num_digitos):
- chars_faltantes = num_digitos - len(campo)
- return (u'0' * chars_faltantes) + campo
-
-
-def str_to_unicode(inp_str):
- inp_str = unicode(inp_str, "utf-8")
- return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
deleted file mode 100644
index cfcf6a55a7b0..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/bancos/itau.py
+++ /dev/null
@@ -1,176 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2019 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from __future__ import division, print_function, unicode_literals
-
-import re
-import string
-from decimal import Decimal
-from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
-
-from ..cnab_400 import Cnab400
-
-
-class Itau400(Cnab400):
-
- def __init__(self):
- super(Cnab400, self).__init__()
- self.controle_linha = 1
-
- def remessa(self, order):
- from cnab240.bancos import itau_cobranca_400
- self.classe_remessa = itau_cobranca_400
- return super(Itau400, self).remessa(order)
-
- def retorno(self, arquivo_retorno):
- from cnab240.bancos import itau_cobranca_retorno_400
- self.classe_retorno = itau_cobranca_retorno_400
- return super(Itau400, self).retorno(arquivo_retorno)
-
- @property
- def inscricao_tipo(self):
- # TODO: Implementar codigo para PIS/PASEP
- if self.order.company_id.partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
- vals = {
- 'cedente_agencia': self.convert_int(
- self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': self.convert_int(
- self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': self.convert_int(
- self.order.company_partner_bank_id.acc_number_dig),
- 'cedente_nome': unicode(self.order.company_id.legal_name),
- 'arquivo_data_de_geracao': self.data_hoje(),
- 'arquivo_hora_de_geracao': self.hora_agora(),
- 'num_seq_registro': self.controle_linha,
- }
- self.controle_linha += 1
- return vals
-
- def _prepare_cobranca(self, line):
- """
-
- :param line:
- :return:
- """
- sacado_endereco = self.retorna_endereco(line.partner_id.id)
-
- # TODO: Garantir que o account.move.line selecionado é o correto
- move_line_id = line.payment_line_ids[:1].move_line_id
-
- # TODO: Guardar estrutura com códigos de ocorrências
- identificacao_ocorrencia = 1
- if move_line_id.state_cnab == 'added_paid':
- identificacao_ocorrencia = 34
-
- vals = {
- 'identificacao_titulo_empresa': line.identificacao_titulo_empresa,
- 'nosso_numero': self.convert_int(line.nosso_numero),
- 'numero_documento': self.adiciona_digitos_num_doc(
- line.numero_documento),
- 'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cedente_inscricao_numero': self.convert_int(punctuation_rm(
- self.order.company_id.cnpj_cpf)),
- 'cedente_agencia': self.convert_int(
- self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': self.convert_int(
- self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv': self.convert_int(
- self.order.company_partner_bank_id.acc_number_dig
- ),
- 'instrucao': 0, # TODO VERIFICAR
- 'quantidade_moeda': 0,
- 'carteira_numero': self.convert_int(
- self.order.payment_mode_id.boleto_carteira
- ),
- 'carteira_cod': self.order.payment_mode_id.boleto_modalidade,
- 'identificacao_ocorrencia': identificacao_ocorrencia,
- 'vencimento_titulo': self.format_date(
- line.date),
- 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
- 'agencia_cobradora': 0,
- 'especie_titulo': self.order.payment_mode_id.boleto_especie,
- 'aceite_titulo': self.order.payment_mode_id.boleto_aceite,
- 'data_emissao_titulo': self.format_date(
- line.date), # FIXME
- 'primeira_instrucao': self.convert_int(
- self.order.payment_mode_id.boleto_protesto
- ),
- 'segunda_instrucao': self.convert_int(
- self.order.payment_mode_id.boleto_protesto_prazo
-
- ),
- 'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
- line.amount_currency,
- self.order.payment_mode_id.cnab_percent_interest
- ),
- 'data_limite_desconto': 0,
- 'valor_desconto': Decimal('0.00'),
- 'valor_iof': Decimal('0.00'),
- 'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': self.convert_int(
- self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)) or '',
- 'sacado_nome': line.partner_id.legal_name,
- 'sacado_endereco': sacado_endereco,
- 'sacado_bairro': line.partner_id.district or '',
- 'sacado_cep': (
- line.partner_id.zip and
- self.convert_int(line.partner_id.zip.replace('-', '')) or ''
- ),
- 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
- 'sacado_uf': line.partner_id.state_id.code,
- 'sacador_avalista': self.order.payment_mode_id.comunicacao_2,
- 'juros_mora_data': 0,
- # self.format_date(
- # line.date),
- 'prazo': 0, # De 5 a 120 dias.
- # 'sacador_avalista': u'Protestar após 5 dias',
- 'num_seq_registro': self.controle_linha,
- }
- return vals
-
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
-
- def retorna_id_empr_benef(self):
- dig_cart = 3
- dig_ag = 5
- dig_conta = 7
-
- carteira = self.adiciona_digitos(
- self.order.payment_mode_id.boleto_carteira, dig_cart)
- agencia = self.adiciona_digitos(
- self.order.company_partner_bank_id.bra_number, dig_ag)
- conta = self.adiciona_digitos(
- self.order.company_partner_bank_id.acc_number, dig_conta)
-
- ident = u'0' + (carteira) + (agencia) + (conta) + \
- (self.order.company_partner_bank_id.acc_number_dig)
- return ident
-
- def adiciona_digitos(self, campo, num_digitos):
- chars_faltantes = num_digitos - len(campo)
- return (u'0' * chars_faltantes) + campo
-
-
-def str_to_unicode(inp_str):
- inp_str = unicode(inp_str, "utf-8")
- return inp_str
diff --git a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py b/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
deleted file mode 100644
index 92ace1c8071d..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/cnab_400/cnab_400.py
+++ /dev/null
@@ -1,401 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import datetime
-import logging
-import re
-import string
-import time
-import unicodedata
-from decimal import Decimal
-
-from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
-
-from ..cnab import Cnab
-
-_logger = logging.getLogger(__name__)
-try:
- from cnab240.tipos import ArquivoCobranca400
- from cnab240.errors import Cnab240Error
-except ImportError as err:
- _logger.debug = (err)
-
-IDENTIFICACAO_DA_OCORRENCIA = [
- ('01', u'Remessa'),
- ('02', u'Pedido de baixa'),
- ('03', u'Pedido de Protesto Falimentar'),
- ('04', u'Concessão de abatimento'),
- ('05', u'Cancelamento de abatimento concedido'),
- ('06', u'Alteração de vencimento'),
- ('07', u'Alteração do controle do participante'),
- ('08', u'Alteração de seu número'),
- ('09', u'Pedido de protesto'),
- ('18', u'Sustar protesto e baixar Título'),
- ('19', u'Sustar protesto e manter em carteira'),
- ('22', u'Transferência Cessão crédito ID. Prod.10'),
- ('23', u'Transferência entre Carteiras'),
- ('24', u'Dev. Transferência entre Carteiras'),
- ('31', u'Alteração de outros dados'),
- ('45', u'Pedido de Negativação (NOVO)'),
- ('46', u'Excluir Negativação com baixa (NOVO)'),
- ('47', u'Excluir negativação e manter pendente (NOVO)'),
- ('68', u'Acerto nos dados do rateio de Crédito'),
- ('69', u'Cancelamento do rateio de crédito'),
-]
-
-ESPECIE_DE_TITULO = [
- ('01', u'Duplicata'),
- ('02', u'Nota Promissória'),
- ('03', u'Nota de Seguro'),
- ('04', u'Cobrança Seriada'),
- ('05', u'Recibo'),
- ('10', u'Letras de Câmbio'),
- ('11', u'Nota de Débito'),
- ('12', u'Duplicata de Serv'),
- ('30', u'Boleto de Proposta'),
- ('99', u'Outros'),
-]
-
-# Essas instruções deverão ser enviadas no Arquivo-Remessa, quando da
-# entrada, desde que código de ocorrência na posição 109 a 110 do registro
-# de transação, seja “01”, para as instruções de protesto/negativação, o
-# CNPJ / CPF e o endereço do Pagador deverão ser informados corretamente
-LISTA_PRIMEIRA_INSTRUCAO = [
- ('05', u'Protesto Falimentar'),
- ('06', u'Protestar'),
- ('07', u'Negativar'),
- ('18', u'Decurso de prazo'),
-
- ('08', u'Não cobrar juros de mora'),
- ('09', u'Não receber após o vencimento'),
- ('10', u'Multas de 10% após o 4o dia do Vencimento'),
- ('11', u'Não receber após o 8o dia do vencimento.'),
- ('12', u'Cobrar encargos após o 5o dia do vencimento'),
- ('13', u'Cobrar encargos após o 10o dia do vencimento'),
- ('14', u'Cobrar encargos após o 15o dia do vencimento'),
- ('15', u'Conceder desconto mesmo se pago após o vencimento'),
-]
-
-
-class Cnab400(Cnab):
-
- def __init__(self):
- super(Cnab, self).__init__()
-
- @staticmethod
- def get_bank(bank):
- if bank == '237':
- from .bancos.bradesco import Bradesco400
- return Bradesco400
- elif bank == '341':
- from .bancos.itau import Itau400
- return Itau400
- else:
- return Cnab400
-
- @property
- def inscricao_tipo(self):
- # TODO: Implementar codigo para PIS/PASEP
- if self.order.company_id.partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_header(self):
- """
-
- :param:
- :return:
- """
- return {
- 'controle_banco': self.convert_int(
- self.order.company_partner_bank_id.bank_id.code_bc
- ),
- 'arquivo_data_de_geracao': self.data_hoje(),
- 'arquivo_hora_de_geracao': self.hora_agora(),
- # TODO: Número sequencial de arquivo
- 'arquivo_sequencia': self.convert_int(self.get_file_numeration()),
- 'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cedente_inscricao_numero': self.convert_int(punctuation_rm(
- self.order.company_id.cnpj_cpf)),
- 'cedente_agencia': self.convert_int(
- self.order.company_partner_bank_id.bra_number),
- 'cedente_conta':
- self.convert_int(self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig,
- 'cedente_agencia_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- 'cedente_nome':
- self.order.company_id.legal_name,
- 'arquivo_codigo': 1, # Remessa/Retorno
- 'servico_operacao': u'R',
- 'nome_banco':
- unicode(self.order.company_partner_bank_id.bank_name),
- 'codigo_empresa':
- self.convert_int(self.order.payment_mode_id.boleto_convenio),
- }
-
- def get_file_numeration(self):
- # TODO: FIX ME
- # numero = self.order.get_next_number()
- # if not numero:
- numero = 1
- return numero
-
- def format_date(self, srt_date):
- return self.convert_int(datetime.datetime.strptime(
- srt_date, '%Y-%m-%d').strftime('%d%m%y'))
-
- def nosso_numero(self, format):
- pass
-
- def cep(self, format):
- sulfixo = format[-3:]
- prefixo = format[:5]
- return prefixo, sulfixo
-
- def sacado_inscricao_tipo(self, partner_id):
- # TODO: Implementar codigo para PIS/PASEP
- if partner_id.is_company:
- return 2
- else:
- return 1
-
- def codificar(self, texto):
- return texto.encode('utf-8')
-
- def _prepare_cobranca(self, line):
- """
- :param line:
- :return:
- """
- prefixo, sulfixo = self.cep(line.partner_id.zip)
-
- aceite = u'N'
- if not self.order.payment_mode_id.boleto_aceite == 'S':
- aceite = u'A'
-
- codigo_protesto = 0
- dias_protestar = 0
- if self.order.payment_mode_id.boleto_protesto == '3' \
- or self.order.payment_mode_id.boleto_protesto == '0':
- codigo_protesto = 0
- dias_protestar = 0
- elif self.order.payment_mode_id.boleto_protesto == '1' \
- or self.order.payment_mode_id.boleto_protesto == '2':
- codigo_protesto = 6
- if (self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo)) < 5:
- dias_protestar = 5
- else:
- dias_protestar = self.convert_int(
- self.order.payment_mode_id.boleto_protesto_prazo)
-
- sacado_endereco = self.retorna_endereco(line.partner_id.id)
-
- # Código agencia do cedente
- # cedente_agencia = cedente_agencia
-
- # Dígito verificador da agência do cedente
- # cedente_agencia_conta_dv = cedente_agencia_dv
-
- # Código da conta corrente do cedente
- # cedente_conta = cedente_conta
-
- # Dígito verificador da conta corrente do cedente
- # cedente_conta_dv = cedente_conta_dv
-
- # Dígito verificador de agencia e conta
- # Era cedente_agencia_conta_dv agora é cedente_dv_ag_cc
-
- return {
-
- 'percentual_multa': Decimal('0.00'),
- 'valor_desconto': Decimal('0.00'),
- 'valor_abatimento_concedido_cancelado': Decimal('0.00'),
- 'primeira_instrucao': codigo_protesto,
- 'segunda_instrucao': dias_protestar,
- 'sacado_cep': self.convert_int(prefixo),
- 'sacado_cep_sufixo': self.convert_int(sulfixo),
- 'sacador_avalista':
- self.order.payment_mode_id.comunicacao_2,
- # 'sacador_avalista': u'Protestar após 5 dias',
- 'num_seq_registro':
- self.controle_linha,
-
- 'controle_banco': self.convert_int(
- self.order.company_partner_bank_id.bank_id.code_bc
- ),
- 'cedente_agencia': self.convert_int(
- self.order.company_partner_bank_id.bra_number),
- 'cedente_conta': self.convert_int(
- self.order.company_partner_bank_id.acc_number),
- 'cedente_conta_dv':
- self.order.company_partner_bank_id.acc_number_dig,
- 'cedente_agencia_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- 'identificacao_titulo': u'0000000', # TODO
- 'identificacao_titulo_banco': u'0000000', # TODO
- 'identificacao_titulo_empresa': line.name, # FIXME
-
- 'vencimento_titulo': self.format_date(
- line.date),
- 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
- # TODO: Código adotado para identificar o título de cobrança.
- # 8 é Nota de cŕedito comercial
- 'especie_titulo': self.convert_int(self.order.payment_mode_id.boleto_especie),
- 'aceite_titulo': aceite,
- 'data_emissao_titulo': self.format_date(
- line.date), # FIXME
- # TODO: trazer taxa de juros do Odoo. Depende do valor do 27.3P
- # CEF/FEBRABAN e Itaú não tem.
- 'juros_mora_data': self.format_date(
- line.date),
-
- # 'juros_mora_taxa_dia': Decimal('0.20'),
- 'juros_mora_taxa_dia': self.calcula_valor_juros_dia(
- line.amount_currency, 0), # line.percent_interest
-
- 'valor_abatimento': Decimal('0.00'),
- 'sacado_inscricao_tipo': self.convert_int(
- self.sacado_inscricao_tipo(line.partner_id)),
- 'sacado_inscricao_numero': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)) or '',
- 'sacado_nome': line.partner_id.legal_name,
-
- # 'sacado_endereco': (
- # line.partner_id.street +
- # ' ' + str(line.partner_id.number)
- # ),
-
- 'sacado_endereco': sacado_endereco,
-
- 'sacado_bairro': line.partner_id.district or '',
- 'sacado_cidade': line.partner_id.l10n_br_city_id.name,
- 'sacado_uf': line.partner_id.state_id.code,
- 'codigo_baixa': 2,
- 'prazo_baixa': 0, # De 5 a 120 dias.
- 'controlecob_data_gravacao': self.data_hoje(),
- 'cobranca_carteira': self.convert_int(
- self.order.payment_mode_id.boleto_carteira
- ),
- 'primeira_mensagem': u'',
- # Trazer da nova tela do payment_mode
- 'identificacao_ocorrencia': 1,
-
- # numero fatura esta copiando para communication
- 'numero_documento': self.adiciona_digitos_num_doc(
- line.communication),
- # 'numero_documento': str(line.move_line_id.invoice.number),
-
- }
-
- def remessa(self, order):
- """
-
- :param order:
- :return:
- """
- self.order = order
- self.arquivo = ArquivoCobranca400(
- self.classe_remessa, **self._prepare_header())
- for line in order.bank_line_ids:
- try:
- self.arquivo.incluir_cobranca(**self._prepare_cobranca(line))
- self.controle_linha += 1
- self.arquivo.trailer.num_seq_registro = self.controle_linha
- line.is_erro_exportacao = False
- line.mensagem_erro_exportacao = ''
-
- for payment_line in line.payment_line_ids:
- payment_line.move_line_id.state_cnab = 'exported'
-
- except Cnab240Error as e:
- mensagem = ''
- if hasattr(e, 'campo'):
- mensagem += u' Campo ' + e.campo.nome
- mensagem += u' valor ' + str(e.campo.valor)
- mensagem += u' inválido'
- else:
- mensagem += u' Erro desconhecido'
- line.is_erro_exportacao = True
- line.mensagem_erro_exportacao = mensagem
-
- for payment_line in line.payment_line_ids:
- payment_line.move_line_id.state_cnab = 'exporting_error'
-
- continue
-
- remessa = unicode(self.arquivo)
- return unicodedata.normalize(
- 'NFKD', remessa).encode('ascii', 'ignore')
-
- def data_hoje(self):
- return (self.convert_int(time.strftime("%d%m%y")))
-
- def hora_agora(self):
- return (self.convert_int(time.strftime("%H%M%S")))
-
- def calcula_valor_juros_dia(self, total_titulo, percent_juros):
- valor_juros = 0
- valor_juros = (total_titulo * (percent_juros / 100))
- return (Decimal(valor_juros).quantize(Decimal('1.00')))
-
- def adiciona_digitos_num_doc(self, campo):
- num_digitos = 10
- campo = str(campo)
- chars_faltantes = num_digitos - len(campo)
- return (u' ' * chars_faltantes) + campo
-
- # @api.multi
- def retorna_endereco(self, id_parceiro):
- # self.ensure_one()
- # workaround to get env
- res_partner_model = self.order.env['res.partner']
- res_partner_end_cobranca = res_partner_model.search(
- [('parent_id', '=', id_parceiro), ('type', '=', 'cnab_cobranca')],
- limit=1)
- if res_partner_end_cobranca:
- str_endereco = self.monta_endereco(res_partner_end_cobranca)
- else:
- res_partner_end_cobranca = res_partner_model.search(
- [('id', '=', id_parceiro)]
- )
- str_endereco = self.monta_endereco(res_partner_end_cobranca)
- # Essa abordagem substitui caracteres especiais por '?'
- # str_endereco = /
- # unicode(str_endereco.encode("ascii", errors="replace"))
-
- # Substitui sinal de grau por espaço
- if str_endereco:
- str_endereco = str_endereco.replace(u"\xb0", u" ")
-
- return str_endereco
-
- def monta_endereco(self, partner_item):
-
- street = self.check_address_item_filled(partner_item.street)
- number = self.check_address_item_filled(partner_item.number)
- complemento = self.check_address_item_filled(partner_item.street2)
- # distrito = self.check_address_item_filled(partner_item.district)
-
- str_endereco = (
- street +
- ' ' +
- number +
- ' ' +
- complemento
- # + ' ' +
- # partner_item.l10n_br_city_id.name +
- # ' ' + partner_item.state_id.name
- )
- return str_endereco
-
- def check_address_item_filled(self, item):
- if not item:
- return ('')
- else:
- return item
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py b/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
deleted file mode 100644
index 32c397f2f690..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from . import pag_for500
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
deleted file mode 100644
index 2cfbd6d7e782..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py b/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
deleted file mode 100644
index de45b9a00459..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/bancos/bradesco.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-
-import re
-import string
-
-from ..pag_for500 import PagFor500
-
-
-class BradescoPagFor(PagFor500):
-
- def __init__(self):
- super(PagFor500, self).__init__()
- from cnab240.bancos import bradescoPagFor
- self.bank = bradescoPagFor
- self.controle_linha = 2
-
- def _prepare_header(self):
- """
-
- :param order:
- :return:
- """
- vals = super(BradescoPagFor, self)._prepare_header()
- vals['codigo_comunicacao'] = self.convert_int(
- self.order.payment_mode_id.boleto_convenio)
- return vals
-
- def _prepare_cobranca(self, line, vals):
- """
-
- :param line:
- :return:
- """
- vals = super(BradescoPagFor, self)._prepare_cobranca(line, vals)
-
- # TODO campo para informar a data do pagamento.
- vals['data_para_efetivacao_pag'] = self.muda_campos_data(
- vals['vencimento_titulo'])
- self.controle_linha += 1
-
- return vals
-
- # Override cnab_240.nosso_numero. Diferentes números de dígitos
- # entre CEF e Itau
- def nosso_numero(self, format):
- digito = format[-1:]
- carteira = format[:3]
- nosso_numero = re.sub(
- '[%s]' % re.escape(string.punctuation), '', format[3:-1] or '')
- return carteira, nosso_numero, digito
-
- def muda_campos_data(self, campo):
- campo = str(campo)
- campo = campo[-4:] + campo[2:4] + campo[:2]
- return self.convert_int(campo)
diff --git a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py b/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
deleted file mode 100644
index e84aa22f1503..000000000000
--- a/l10n_br_account_payment_cobranca/febraban/pag_for/pag_for500.py
+++ /dev/null
@@ -1,573 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import datetime
-import logging
-import re
-import string
-import time
-import unicodedata
-from decimal import Decimal
-
-from odoo import _
-from odoo.addons.l10n_br_base.tools.misc import punctuation_rm
-from odoo.exceptions import Warning as UserError
-
-from ..cnab import Cnab
-
-_logger = logging.getLogger(__name__)
-try:
- from cnab240.tipos import Arquivo
-except ImportError as err:
- _logger.debug = (err)
-try:
- from pyboleto.data import BoletoData
-except ImportError as err:
- _logger.debug = (err)
-
-TIPO_CONTA_FORNECEDOR = [
- ('1', u'Conta corrente'),
- ('2', u'Conta Poupança'),
-]
-
-TIPO_DOCUMENTO = [
- ('01', u'Nota Fiscal/Fatura'),
- ('02', u'Fatura'),
- ('03', u'Nota Fiscal'),
- ('01', u'Duplicata'),
- ('01', u'Outros'),
-]
-
-MODALIDADE = [
- ('01', u'01 - Crédito em conta-corrente ou poupança Bradesco'),
- ('02', u'02 - Cheque OP ( Ordem de Pagamento'),
- ('03', u'03 - DOC COMPE'),
- ('05', u'05 - Crédito em conta real time'),
- ('08', u'08 - TED'),
- ('30', u'30 - Rastreamento de Títulos'),
- ('31', u'31 - Títulos de terceiros'),
-]
-
-TIPO_MOVIMENTO = [
- ('0', u'Inclusão'),
- ('5', u'Alteração'),
- ('9', u'Exclusão'),
-]
-
-CODIGO_MOVIMENTO = [
- ('00', u'Autoriza agendamento'),
- ('25', u'Desautoriza Agendamento'),
- ('50', u'Efetuar Alegçação'),
-]
-
-TIPO_DOC = [
- ('C', u'Titularidade Diferente'),
- ('D', u'Mesma Titularidade'),
-]
-
-FINALIDADE_DOC_TED = [
- ('01', u'Crédito em Conta Corrente'),
- ('02', u'Pagamento de Aluguel /Condomínios'),
- ('03', u'Pagamento de Duplicatas/Títulos'),
- ('04', u'Pagamento de Dividendos'),
- ('05', u'Pagamento de Mensal. Escolares'),
- ('06', u'Pagamento de Salário'),
- ('07', u'Pagamento de Fornec/Honor.'),
- ('08', u'Operações de Câmbio /Fundos /Bolsa de Valores'),
- ('09', u'Repasse de Arrec./Pagto de Tributos'),
- ('10', u'Transferência Internacional em Reais'),
- ('11', u'DOC COMPE/TED para Poupança'),
- ('12', u'DOC COMPE/TED para Depósito Judicial'),
- ('13', u'Pensão Alimentícia'),
- ('14', u'Restituição de Imposto de Renda'),
- ('18', u'Operações Seguro Habit.', u'SFH'),
- ('19', u'Operações do FDS', u'Caixa'),
- ('20', u'Pagamento De Operação De Crédito'),
- ('23', u'Taxa de Administração'),
- ('27', u'Pagamento Acordo/Execução Judicial'),
- ('28', u'Liquidação de Empréstimos Consignados'),
- ('29', u'Pagamento de Bolsa Auxilio'),
- ('30', u'Remuneração A Cooperado'),
- ('31', u'Pagamento de Prebenda'),
- ('33', u'Pagamento de Juros sobre Capital Próprio'),
- ('34', u'Pagamento de Rendimentos ou Amortização s/ Cotas '
- u'e/ou Debêntures'),
- ('35', u'Taxa De Serviço'),
- ('37', u'Pagamento de Juros e/ou Amortização de Títulos '
- u'Depositados em Garantia.'),
- ('38', u'Estorno Ou Restituição', u'Diversos'),
- ('59', u'Restituição de Prêmios de Seguros'),
- ('60', u'Pagamento de Indenização Sinistro Seguro'),
- ('61', u'Pagamento de Premio de Co-Seguro'),
- ('63', u'Pagamento de Indenização Sinistro Co-Seguro'),
- ('64', u'Pagamento de Premio De Resseguro'),
- ('65', u'Restituição de Premio De Resseguro'),
- ('66', u'Pagamento de Indenização Sinistro Resseguro'),
- ('67', u'Restituição Indenização Sinistro Resseguro'),
- ('68', u'Pagamento de Despesas Com Sinistro'),
- ('69', u'Pagamento de Inspeções/Vistorias Prévias'),
- ('70', u'Pagamento de Resgate de Titulo de Capitalização'),
- ('71', u'Pagamento de Sorteio de Titulo de Capitalização'),
- ('72', u'Devolução Mensal de Titulo de Capitalização.'),
- ('73', u'Restituição de Contribuição de Plano Previdenciário'),
- ('74', u'Pagamento de Beneficio Previdenciário Pecúlio'),
- ('75', u'Pagamento de Beneficio Previdenciário Pensão'),
- ('76', u'Pagamento de Beneficio Previdenciário Aposentadoria'),
- ('77', u'Pagamento de Resgate Previdenciário'),
- ('78', u'Pagamento de Comissão de Corretagem'),
- ('79', u'Pagamento de Transferências/Portabilidade de Reserva '
- u'Seguro/Previdência'),
- ('80', u'Pagamento de Impostos'),
- ('81', u'Pagamento de Serviços Públicos'),
- ('82', u'Pagamento de Honorários'),
- ('83', u'Pagamento de Corretoras'),
- ('84', u'Repasse de Valores BNDES'),
- ('85', u'Liquidação de Compromissos com BNDES'),
- ('86', u'Compra e Venda de Ações'),
- ('87', u'Contratos Referenciados em Ações ou Índices de Ações'),
- ('88', u'Operação De Cambio'),
- ('89', u'Pagamento de Boleto Bancário em Cartório'),
- ('90', u'Pagamento de Tarifas pela Prestação de Serviços de Arrecadação'
- u' de Convênios'),
- ('91', u'Operações no Mercado de Renda Fixa e Variável com Utilização '
- u'de Intermediário'),
- ('92', u'Operação de Câmbio Mercado Interbancário Instituições '
- u'sem Reservas Bancárias'),
- ('93', u'Pagamento de Operações com Identificação de Destinatário Final'),
- ('94', u'Ordem Bancaria do Tesouro - OBT'),
- ('99', u'Outros'),
-]
-
-
-class PagFor500(Cnab):
- """
-
- """
-
- def __init__(self):
- super(Cnab, self).__init__()
-
- @staticmethod
- def get_bank(bank):
- if bank == '237':
- from .bancos.bradesco import BradescoPagFor
- return BradescoPagFor
- else:
- return PagFor500
-
- @property
- def inscricao_tipo(self):
- # TODO: Implementar codigo para PIS/PASEP
- if self.order.company_id.partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_header(self):
- """
-
- :param:
- :return:
- """
- return {
- 'arquivo_data_de_geracao': self.data_hoje_pag_for(),
- 'arquivo_hora_de_geracao': self.hora_agora(),
- # TODO: Número sequencial de arquivo
- 'numero_remessa': self.convert_int(self.get_file_numeration()),
- 'cedente_inscricao_tipo': self.inscricao_tipo,
- 'cnpj_cpf_base': self.convert_int(punctuation_rm(
- self.order.company_id.cnpj_cpf)[0:8]),
- 'cnpj_cpf_filial': self.convert_int(punctuation_rm(
- self.order.company_id.cnpj_cpf)[9:12]),
- 'sufixo_cnpj': self.convert_int(punctuation_rm(
- self.order.company_id.cnpj_cpf)[12:14]),
- 'cedente_agencia':
- self.convert_int(self.order.company_partner_bank_id.bra_number),
- 'cedente_conta':
- self.convert_int(self.order.company_partner_bank_id.acc_number),
- 'cedente_agencia_conta_dv':
- self.order.company_partner_bank_id.bra_number_dig,
- 'nome_empresa_pagadora': self.order.company_id.legal_name,
- 'cedente_codigo_agencia_digito':
- self.order.company_partner_bank_id.bra_number_dig,
- 'arquivo_codigo': 1, # Remessa/Retorno
- 'servico_operacao': u'R',
- 'reservado_empresa': u'BRADESCO PAG FOR',
- # Sequencial crescente e nunca pode ser repetido
- 'numero_lista_debito': self.convert_int(self.get_file_numeration()),
- # TODO: Sequencial crescente de
- # 1 a 1 no arquivo. O primeiro header
- # será sempre 000001
- 'sequencial': 1
- }
-
- def get_file_numeration(self):
- numero = self.order.get_next_number()
- if not numero:
- numero = 1
- return numero
-
- def format_date(self, srt_date):
- return self.convert_int(datetime.datetime.strptime(
- srt_date, '%Y-%m-%d').strftime('%d%m%Y'))
-
- def format_date_ano_mes_dia(self, srt_date):
- return self.convert_int(datetime.datetime.strptime(
- srt_date, '%Y-%m-%d').strftime('%Y%m%d'))
-
- def nosso_numero(self, format):
- pass
-
- def cep(self, format):
- sulfixo = format[-3:]
- prefixo = format[:5]
- return prefixo, sulfixo
-
- def sacado_inscricao_tipo(self, partner_id):
- # TODO: Implementar codigo para PIS/PASEP
- if partner_id.is_company:
- return 2
- else:
- return 1
-
- def _prepare_cobranca(self, line, vals):
- """
-
- :param line:
- :return:
- """
- segmento = {}
-
- vals.update(segmento)
-
- # TODO this zip code
- prefixo, sulfixo = self.cep(line.partner_id.zip)
-
- segmento = {
- 'conta_complementar':
- self.convert_int(self.order.company_partner_bank_id.acc_number),
- # 'especie_titulo': 8,
-
- 'tipo_inscricao': self.convert_int(
- self.sacado_inscricao_tipo(line.partner_id)),
- 'cnpj_cpf_base_forn': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)[0:8]) or '',
- 'cnpj_cpf_filial_forn': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)[9:12]) or '',
- 'cnpj_cpf_forn_sufixo': line.partner_id.cnpj_cpf and self.convert_int(
- punctuation_rm(line.partner_id.cnpj_cpf)[12:14]) or '',
- 'nome_forn': line.partner_id.legal_name,
- 'endereco_forn': (
- line.partner_id.street + ' ' + line.partner_id.number),
- 'cep_forn': self.convert_int(prefixo),
- 'cep_complemento_forn': self.convert_int(sulfixo),
-
- # TODO quando banco é 237, deve-se extrair da linha
- # digitável. Do contrário, zeros.
- # 'nosso_numero': 11, # FIXME
-
- # 'numero_documento': line.name,
- # 'vencimento_titulo': self.format_date_ano_mes_dia(
- # line.ml_maturity_date),
-
- 'data_emissao_titulo': self.format_date_ano_mes_dia(
- line.ml_date_created),
-
- 'desconto1_data': 0,
- 'fator_vencimento': 0, # FIXME
-
- 'valor_titulo': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
-
- 'valor_pagto': Decimal(str(line.amount_currency)).quantize(
- Decimal('1.00')),
-
- 'valor_desconto': Decimal('0.00'),
-
- 'valor_acrescimo': Decimal('0.00'),
-
- # FIXME
- 'tipo_documento': 2, # NF, Fatura, Duplicata...
- # NF_Fatura_01/Fatura_02/NF_03/Duplicata_04/Outros_05
- 'numero_nf': self.convert_int(line.ml_inv_ref.internal_number),
-
- 'modalidade_pagamento': self.convert_int(
- line.order_id.mode.type_purchase_payment),
-
- # Quando não informada o sistema assume a data constante do campo
- # Vencimento
- 'data_para_efetivacao_pag': 0,
-
- 'tipo_movimento': 0,
- # TODO Tipo de Movimento.
- # 0 - Inclusão.
- # 5 - Alteração.
- # 9 - Exclusão.
-
- 'codigo_movimento': 0, # Autoriza agendamento
-
- # Quando não informado consulta em todos processamentos
- # 'horario_consulta_saldo': u'5',
-
- 'codigo_area_empresa': 0,
-
- 'codigo_lancamento': 0, # FIXME
-
- 'tipo_conta_fornecedor': 1, # FIXME
-
- # O Primeiro registro de transação sempre será o registro
- # “000002”, e assim sucessivamente.
- 'sequencial': 3, # FIXME
-
- # Trailer
- 'totais_quantidade_registros': 0,
- 'total_valor_arq': Decimal('0.00'),
- # FIXME: lib nao reconhece campo
- 'sequencial_trailer': self.convert_int(self.get_file_numeration()),
- 'sequencial_transacao': self.controle_linha,
- 'codigo_protesto':
- self.convert_int(self.order.payment_mode_id.boleto_protesto),
- 'prazo_protesto':
- self.convert_int(self.order.payment_mode_id.boleto_protesto_prazo),
- 'codigo_baixa': 2,
- 'prazo_baixa': 0, # De 5 a 120 dias.
- 'controlecob_data_gravacao': self.data_hoje(),
-
- }
- segmento.update(vals)
- return segmento
-
- def remessa(self, order):
- """
-
- :param order:
- :return:
- """
-
- pag_valor_titulos = 0
-
- self.order = order
- self.arquivo = Arquivo(self.bank, **self._prepare_header())
- cont_lote = 0
-
- for line in order.line_ids:
- self.arquivo.incluir_pagamento(
- **self.incluir_pagamento_for(line))
- pag_valor_titulos += line.amount_currency
- self.arquivo.trailer.total_valor_arq = Decimal(
- pag_valor_titulos).quantize(Decimal('1.00'))
- self.arquivo.trailer.sequencial_transacao = self.controle_linha
-
- cont_lote += 1
- remessa = unicode(self.arquivo)
- return unicodedata.normalize(
- 'NFKD', remessa).encode('ascii', 'ignore')
-
- def data_hoje(self):
- return (self.convert_int(time.strftime("%d%m%Y")))
-
- def data_hoje_pag_for(self):
- return (self.convert_int(time.strftime("%Y%m%d")))
-
- def hora_agora(self):
- return (self.convert_int(time.strftime("%H%M%S")))
-
- @staticmethod
- def modulo11(num, base, r):
- return BoletoData.modulo11(num, base=9, r=0)
-
- def incluir_pagamento_for(self, line):
- mode = line.order_id.mode.type_purchase_payment
- if mode in ('01'):
- return self.lancamento_credito_bradesco(line)
- elif mode in ('02'):
- raise UserError(_(u'Operação não suportada'))
- elif mode in ('03'):
- return self.lancamento_doc(line)
- elif mode in ('05'):
- raise UserError(_(u'Operação não suportada'))
- elif mode in ('08'):
- return self.lancamento_ted(line)
- elif mode in ('30'):
- raise UserError(_(u'Operação não suportada'))
- elif mode in ('31'):
- # titulos de terceiros
- return self.lancamento_titulos_terceiros(line)
- raise UserError(_(u'Operação não suportada'))
-
- def lancamento_credito_bradesco(self, line):
- # TODO:
- # modalidade 01.
-
- vals = {
- 'especie_titulo': line.order_id.mode.type_purchase_payment,
-
- 'codigo_banco_forn': 237,
- 'codigo_agencia_forn': self.convert_int(line.bank_id.bra_number),
- 'digito_agencia_forn_transacao': line.bank_id.bra_number_dig,
- 'conta_corrente_forn': self.convert_int(line.bank_id.acc_number),
- 'digito_conta_forn_transacao': line.bank_id.acc_number_dig,
-
- 'numero_pagamento': self.adiciona_digitos_num_pag(
- line.communication),
-
- 'carteira': self.convert_int(self.order.payment_mode_id.boleto_carteira),
-
- 'nosso_numero': 0,
-
- 'vencimento_titulo': self.format_date_ano_mes_dia(
- line.ml_maturity_date),
-
- 'informacoes_complementares': u'',
- }
-
- return self._prepare_cobranca(line, vals)
-
- def lancamento_ted(self, line):
- # TODO:
- # modalidade 08.
-
- vals = {
- 'conta_complementar':
- self.convert_int(self.order.company_partner_bank_id.acc_number),
- 'especie_titulo':
- line.order_id.mode.type_purchase_payment,
-
- # TODO: código do banco. Para a Modalidade de Pagamento valor
- # pode variar
- 'codigo_banco_forn':
- self.convert_int(line.bank_id.bank.bic),
- 'codigo_agencia_forn':
- self.convert_int(line.bank_id.bra_number),
- 'digito_agencia_forn_transacao':
- line.bank_id.bra_number_dig,
- 'conta_corrente_forn':
- self.convert_int(line.bank_id.acc_number),
- 'digito_conta_forn_transacao':
- line.bank_id.acc_number_dig,
- # TODO Gerado pelo cliente pagador quando do agendamento de
- # pagamento por parte desse, exceto para a modalidade 30 -
- # Títulos em Cobrança Bradesco
- # communication
- 'numero_pagamento':
- self.adiciona_digitos_num_pag(
- line.communication),
-
- 'carteira': 0,
-
- 'nosso_numero': 0,
-
- 'vencimento_titulo': self.format_date_ano_mes_dia(
- line.ml_maturity_date),
-
- 'fator_vencimento': 0, # FIXME
-
- # 'modalidade_pagamento':
- # self.convert_int(self.order.payment_mode_id.boleto_especie),
-
- 'tipo_movimento': 0,
- # TODO Tipo de Movimento.
- # 0 - Inclusão.
- # 5 - Alteração.
- # 9 - Exclusão. Wkf Odoo.
- 'codigo_movimento': 0, # FIXME
- # 'horario_consulta_saldo': u'5', # FIXME
-
- # 'informacoes_complementares': self.montar_info_comple_ted(),
- 'informacoes_complementares': u'',
-
- 'codigo_lancamento': 0, # FIXME
- 'tipo_conta_fornecedor': 1, # FIXME
-
- }
-
- return self._prepare_cobranca(line, vals)
-
- def lancamento_doc(self):
- # TODO:
-
- vals = {}
-
- return self._prepare_cobranca(vals)
-
- def lancamento_titulos_terceiros(self, line):
- # TODO:
-
- res_cods_ag_cc = \
- self.ler_linha_digitavel_codigos_ag_cc(line.linha_digitavel)
-
- vals = {
- 'conta_complementar':
- self.convert_int(self.order.company_partner_bank_id.acc_number),
- 'especie_titulo':
- line.order_id.mode.type_purchase_payment,
-
- # extrair do código de barras
- 'codigo_banco_forn': res_cods_ag_cc['codigo_banco_forn'],
- 'codigo_agencia_forn': res_cods_ag_cc['codigo_agencia_forn'],
- 'digito_agencia_forn_transacao': res_cods_ag_cc[
- 'digito_agencia_forn_transacao'],
- 'conta_corrente_forn': res_cods_ag_cc['conta_corrente_forn'],
- 'digito_conta_forn_transacao': res_cods_ag_cc[
- 'digito_conta_forn_transacao'],
-
- 'carteira': res_cods_ag_cc['carteira']
-
- }
-
- return self._prepare_cobranca(vals)
-
- def adiciona_digitos_num_pag(self, campo):
- num_digitos = 16
- campo = str(campo)
- chars_faltantes = num_digitos - len(campo)
- return (u' ' * chars_faltantes) + campo
-
- def montar_info_comple_ted(self):
- tipo_doc_compe = TIPO_DOC[0][0]
- num_doc_ted = '000000'
- # pagamento duplicatas. Ou será 01?
- finalidade_doc_compe = FINALIDADE_DOC_TED[2][0]
- tipo_conta_doc_ted = '01'
- codigo_identif_transf = '0000000000000000000000000'
- fim_do_campo = ' '
- info_comple = tipo_doc_compe + num_doc_ted + finalidade_doc_compe + \
- tipo_conta_doc_ted + codigo_identif_transf + fim_do_campo
- return (info_comple.encode('utf-8'))
-
- def ler_linha_digitavel_codigos_ag_cc(self, linha_digitavel):
- codigo_banco_fornecedor = linha_digitavel[:3]
- res = {}
-
- # para banco = 237, bradesco
- if (codigo_banco_fornecedor == '237'):
- res = {
- 'codigo_banco_forn': self.convert_int(codigo_banco_fornecedor),
- 'codigo_agencia_forn': self.convert_int(linha_digitavel[4:8]),
- # Calcular usando modulo 11 base 7
- 'digito_agencia_forn_transacao': u'',
- 'conta_corrente_forn': self.convert_int(linha_digitavel[23:30]),
- # Calcular usando modulo 11 base 7
- 'digito_conta_forn_transacao': u'',
-
- 'carteira': self.convert_int(linha_digitavel[8:10]),
-
- 'nosso_numero': self.convert_int(linha_digitavel[11:21])
- }
- # para outros bancos
- else:
- res = {
- 'codigo_banco_forn': self.convert_int(codigo_banco_fornecedor),
- 'codigo_agencia_forn': 0,
- 'digito_agencia_forn_transacao': u'',
- 'conta_corrente_forn': 0,
- 'digito_conta_forn_transacao': u'',
-
- 'carteira': 0,
-
- 'nosso_numero': 0,
- }
- return res
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 262bb8e7cd87..9de41f83e97f 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -5,13 +5,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-import json
-from datetime import datetime
-from dateutil.relativedelta import relativedelta
-
-from pyboleto.bank_api.itau import ApiItau
-
-from odoo.addons.queue_job.job import job
from odoo import models, fields, api, _
from odoo.exceptions import UserError
from ..constantes import (
@@ -62,6 +55,10 @@ class AccountInvoice(models.Model):
readonly=True,
)
+ def register_invoice_api(self):
+ """ Registrar o boleto via sua API"""
+ raise NotImplementedError
+
@api.onchange('payment_mode_id')
def _onchange_payment_mode_id(self):
tax_analytic_tag_id = self.env.ref(
@@ -196,51 +193,6 @@ def create_bank_api_operation(self, request, operation_type=False,
operation_id.register_post(request)
self.bank_api_operation_ids += operation_id
- def obtain_token(self, company_id, environment):
- """
- Método para buscar ou atualizar o Token da empresa
- :param company_id: Empresa
- :param environment: Ambiente da operação
- :return: O Token da empresa
- """
-
- token = company_id.api_itau_token
- if not token or company_id.api_itau_token_due_datetime <= \
- fields.Datetime.now():
-
- client_id = company_id.client_id
- client_secret = company_id.client_secret
- endpoint = company_id.api_endpoint
-
- token_request = False
- try:
- token_request = ApiItau.generate_api_key(
- client_id, client_secret, endpoint)
- token_request_dict = json.loads(token_request.content)
- token = token_request_dict.get('access_token')
- company_id.api_itau_token = token
- company_id.api_itau_token_due_datetime = \
- fields.Datetime.context_timestamp(
- self, datetime.now()) + relativedelta(
- seconds=token_request_dict.get('expires_in'))
-
- except Exception as e:
- company_id.api_itau_token = ''
- company_id.api_itau_token_due_datetime = \
- fields.Datetime.now()
- raise UserError(_(
- u"Erro na obtenção do Token de acesso à Api. %s"
- ) % str(e))
- finally:
- self.create_bank_api_operation(
- token_request,
- operation_type='token_request',
- environment=environment,
- )
- self._cr.commit()
-
- return token
-
@api.multi
def create_api_account_payment_line(self):
# TODO: Criar CRON para confirmar as account.payment.order no final de
@@ -307,78 +259,6 @@ def create_api_account_payment_line(self):
% (count, payorder.name))
return payorder
- @job
- @api.multi
- def register_invoice_api(self):
- for record in self:
- receivable_ids = record.mapped('move_line_receivable_id')
- if not receivable_ids:
- return False
-
- boleto_list = receivable_ids.generate_boleto(validate=False)
- if not boleto_list:
- raise UserError(_(
- u"Não foi possível registrar as faturas pela API"
- ))
-
- company_id = record.partner_id.company_id.sudo()
-
- itau_key = company_id.itau_key
- barcode_endpoint = company_id.raiz_endpoint
- environment = company_id.environment
-
- token = record.obtain_token(company_id, environment)
-
- for boleto in boleto_list:
- ApiItau.convert_to(boleto, tipo_ambiente=environment)
- response = False
- try:
- response = boleto.post(token, itau_key, barcode_endpoint)
- if response and response.ok:
- # Remove Invoice from debit.orders
- record._remove_payment_order_line(_raise=False)
-
- # Create new Debit Order for payment_order_line
- try:
- record.create_api_account_payment_line()
-
- except Exception as e:
- _logger.debug(str(e))
- else:
- receivable_ids.write({
- 'state_cnab': 'not_accepted'
- })
-
- except Exception as e:
- raise UserError(_(
- u"Erro ao registrar a fatura boleto. Verifique se as "
- u"configurações da API estão corretas. %s"
- ) % str(e))
-
- finally:
- if response and response.ok:
- # ambiente = 1 --> HML
- if boleto.tipo_ambiente == '1':
- receivable_ids.write({
- 'state_cnab': 'accepted_hml'
- })
- # PROD
- else:
- receivable_ids.write({
- 'state_cnab': 'accepted',
- 'situacao_pagamento': 'aberta'
- })
-
- record.create_bank_api_operation(
- response,
- operation_type='invoice_register',
- environment=environment,
- )
- self.message_post(_(
- "Comunicação com o banco via API concluída. Verifique a Aba "
- "'Operações Bancárias' consultar o resultado do processamento."
- ))
-
@api.multi
def get_invoice_fiscal_number(self):
""" Como neste modulo nao temos o numero do documento fiscal,
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 10845b08c2d4..38d6427ea73b 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -5,8 +5,6 @@
import logging
from odoo import models, fields, api, _
-
-from ..febraban.boleto.document import Boleto
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -100,33 +98,7 @@ def create_payment_line_from_move_line(self, payment_order):
@api.multi
def generate_boleto(self, validate=True):
- boleto_list = []
-
- for move_line in self:
-
- if validate and move_line.state_cnab not in \
- ['accepted', 'accepted_hml']:
- if move_line.state_cnab == 'not_accepted':
- raise UserError(_(
- u'Essa fatura foi transmitida com erro ao banco, '
- u'é necessário corrigí-la e reenviá-la.'
- ))
- raise UserError(_(
- u'Antes de imprimir o boleto é necessário transmitir a '
- u'fatura para registro no banco.'
- ))
-
- boleto = Boleto.getBoleto(
- move_line, move_line.nosso_numero
- )
-
- # Se a cobrança tiver sido emitida em homologação
- if move_line.state_cnab == 'accepted_hml':
- boleto.boleto.instrucoes.append(_(
- u'Boleto emitido em homologacao! Sem valor fiscal!'))
-
- boleto_list.append(boleto.boleto)
- return boleto_list
+ raise NotImplementedError
@api.multi
def _update_check(self):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index dd4dd430216f..48ab8f0c2d08 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -9,10 +9,6 @@
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, AVISO_FAVORECIDO
-from ..febraban.boleto.document import getBoletoSelection
-
-selection = getBoletoSelection()
-
class PaymentMode(models.Model):
_inherit = "account.payment.mode"
@@ -71,7 +67,7 @@ class PaymentMode(models.Model):
boleto_aceite = fields.Selection(
[('S', 'Sim'), ('N', 'Não')], string='Aceite', default='N')
boleto_type = fields.Selection(
- selection, string="Boleto")
+ selection=[], string="Boleto")
boleto_especie = fields.Selection([
('01', u'DUPLICATA MERCANTIL'),
('02', u'NOTA PROMISSÓRIA'),
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index ba8b5bd236e0..662f8054b99e 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -7,18 +7,12 @@
from __future__ import division, print_function, unicode_literals
from odoo import api, models, fields
-
-from ..febraban.cnab import Cnab
from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO, CODIGO_INSTRUCAO_MOVIMENTO
import logging
_logger = logging.getLogger(__name__)
-try:
- from cnab240.errors import (Cnab240Error)
-except ImportError as err:
- _logger.debug = err
class PaymentOrder(models.Model):
@@ -113,20 +107,6 @@ def _prepare_bank_payment_line(self, paylines):
result['ultimo_estado_cnab'] = paylines.move_line_id.state_cnab
return result
- def _generate_payment_file(self):
- try:
- return Cnab.gerar_remessa(order=self), self.name + '.REM'
- except Cnab240Error as e:
- _logger.error("Erro ao gerar o arquivo: \n\n{0}".format(e))
-
- @api.multi
- def generate_payment_file(self):
- """Returns (payment file as string, filename)"""
- self.ensure_one()
- if self.payment_method_id.code in ('240', '400', '500'):
- return self._generate_payment_file()
- return super(PaymentOrder, self).generate_payment_file()
-
@api.multi
def open2generated(self):
result = super(PaymentOrder, self).open2generated()
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 5ca141d7fb93..5cb50d037319 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -8,8 +8,6 @@
import re
from datetime import datetime
from ..constantes import CODIGO_OCORRENCIAS
-from ..febraban.cnab import Cnab
-from odoo.exceptions import UserError
from odoo import api, models, fields
@@ -703,142 +701,11 @@ def reprocessar_retorno_multi(self):
if cnab_id.state in ['done']:
cnab_id.reprocessar_arquivo_retorno()
- @api.multi
def reprocessar_arquivo_retorno(self):
- cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
- data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
- self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
- self.data_arquivo = datetime.strptime(data_arquivo.zfill(6), "%d%m%y")
-
- self.bank_account_id = self._busca_conta(
- arquivo_parser.header.codigo_do_banco,
- arquivo_parser.header.cedente_agencia,
- arquivo_parser.header.cedente_conta,
- )
-
- self.num_lotes = len(arquivo_parser.lotes)
- self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
- for lote in arquivo_parser.lotes:
-
- header = lote.header or arquivo_parser.header
- trailer = lote.trailer or arquivo_parser.trailer
-
- lote_id = self.lote_id and self.lote_id[0]
- bankless_line_id = \
- lote_id.evento_id.filtered(
- lambda e: not e.bank_payment_line_id)
- bankless_line_id.unlink()
+ raise NotImplementedError
- for evento in lote.eventos:
- if not lote_id:
- lote_id, lote_bank_account_id = self._cria_lote(
- header, lote, evento, trailer)
-
- if cnab_type == '240':
- self._reprocessa_lote_240(evento, lote_id)
- else:
- self._reprocessa_lote_400(evento, lote_id)
-
- #TODO: Verificar necessidade de atualizar dados do Account.Move
- return self.write({'state': 'done'})
-
- @api.multi
def processar_arquivo_retorno(self):
- cnab_type, arquivo_parser = Cnab.detectar_retorno(self.arquivo_retorno)
- # if not arquivo_parser.header.arquivo_codigo == u'2':
- # raise exceptions.Warning(
- # u"Este não é um arquivo de retorno!"
- # )
- data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao)
- self.sequencial_arquivo = str(arquivo_parser.header.sequencial_arquivo)
- self.data_arquivo = datetime.strptime(data_arquivo.zfill(6), "%d%m%y")
-
- if self.search([
- ('data_arquivo', '=', self.data_arquivo),
- ('sequencial_arquivo', '=', self.sequencial_arquivo),
- ('id', '!=', self.id)]):
- self.state = 'error'
- self.motivo_erro = u"O arquivo %s, de %s - sequencial %s, " \
- u"ja se encontra importado." % \
- (self.filename,
- datetime.strftime(fields.Datetime.from_string(
- self.data_arquivo), "%d/%m/%Y"),
- self.sequencial_arquivo)
- return
-
- self.bank_account_id = self._busca_conta(
- arquivo_parser.header.codigo_do_banco,
- arquivo_parser.header.cedente_agencia,
- arquivo_parser.header.cedente_conta,
- )
-
- self.num_lotes = len(arquivo_parser.lotes)
- self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros
- for lote in arquivo_parser.lotes:
-
- header = lote.header or arquivo_parser.header
- trailer = lote.trailer or arquivo_parser.trailer
-
- lote_id = False
- total_amount = 0.0
- lines = []
- inv_list = []
- for evento in lote.eventos:
- if not lote_id:
- lote_id, lote_bank_account_id = self._cria_lote(
- header, lote, evento, trailer)
-
- if cnab_type == '240':
- self._lote_240(evento, lote_id)
- else:
- line_vals, line_amount, invoices = \
- self._lote_400(evento, lote_id)
- for inv in invoices:
- inv_list.append(inv)
- if line_vals and line_amount:
- for line in line_vals:
- lines.append(line)
- total_amount += line_amount
-
- if total_amount and lines:
- counterpart_account_id = self.env['account.journal'].browse(
- lines[0][2]['journal_id']).default_debit_account_id.id
-
- lines.append(
- (0, 0, {
- 'name': 'cobranca',
- 'debit': total_amount,
- 'account_id': counterpart_account_id,
- 'journal_id': lines[0][2]['journal_id'],
- 'date_maturity': False,
- 'partner_id': False,
- })
- )
- move = self.env['account.move'].create({
- 'name': 'RetornoCnab_' + fields.Datetime.now(),
- 'ref':
- 'Retorno Gerado em %s' %
- datetime.strftime(datetime.strptime(
- data_arquivo.zfill(6), "%d%m%y"), "%d/%m/%Y"),
- 'date': str(datetime.now()),
- 'line_ids': lines,
- 'journal_id': lines[0][2]['journal_id']
- })
- move.post()
-
- for inv in inv_list:
- if inv.state != 'open':
- continue
- inv_move_lines = inv.move_line_receivable_id
- pay_move_lines = move.line_ids.filtered(
- lambda x: x.account_id == inv_move_lines.account_id and
- x.partner_id == inv_move_lines.partner_id and
- x.name == inv_move_lines.transaction_ref
- )
- move_lines = pay_move_lines | inv_move_lines
- move_lines.reconcile()
-
- return self.write({'state': 'done'})
+ raise NotImplementedError
def _get_name(self, data, filename):
cnab_ids = self.search([('data', '=', data)], order='id desc')
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index 8eab85c1a511..7141da4ae397 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -6,12 +6,9 @@
from __future__ import with_statement
from odoo.api import Environment
-from odoo.osv import osv
from odoo.report.interface import report_int
from odoo.report.render import render
-from ..febraban.boleto.document import Boleto
-
class ExternalPdf(render):
@@ -51,13 +48,7 @@ def create(self, cr, uid, ids, datas, context=False):
if not ids_move_lines:
return False
- boleto_list = ids_move_lines.generate_boleto()
- if not boleto_list:
- raise osv.except_osv(
- 'Error !', ('Não é possível gerar os boletos\n'
- 'Certifique-se que a fatura esteja confirmada e o '
- 'forma de pagamento seja duplicatas'))
- pdf_string = Boleto.get_pdfs(boleto_list)
+ pdf_string = ids_move_lines.generate_boleto()
self.obj = ExternalPdf(pdf_string)
self.obj.render()
return self.obj.pdf, 'pdf'
From 04da7a45476d8ff57cfab9112c82cb7f1306c101 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 18 Dec 2019 09:32:12 -0300
Subject: [PATCH 179/612] [IMP] l10n_br_account_payment_cobranca black, isort
---
l10n_br_account_payment_cobranca/__init__.py | 1 -
.../__manifest__.py | 70 +-
.../constantes.py | 704 +++++++------
.../data/ir_cron.xml | 2 +-
.../models/__init__.py | 1 -
.../models/account_invoice.py | 421 ++++----
.../models/account_invoice_api_confirm.py | 51 +-
.../models/account_move.py | 24 +-
.../models/account_move_line.py | 108 +-
.../models/account_payment.py | 3 +-
.../models/account_payment_line.py | 89 +-
.../models/account_payment_mode.py | 160 +--
.../models/account_payment_order.py | 92 +-
.../models/account_payment_term.py | 38 +-
.../models/bank_api_operation.py | 123 +--
.../models/bank_payment_line.py | 125 +--
.../models/l10n_br_cnab.py | 979 +++++++++---------
.../models/l10n_br_cnab_evento.py | 138 +--
.../models/l10n_br_cnab_lote.py | 50 +-
.../models/res_company.py | 61 +-
.../models/res_partner.py | 9 +-
.../models/res_partner_bank.py | 33 +-
.../reports/__init__.py | 1 -
.../reports/report.py | 23 +-
.../reports/report_print_button_view.xml | 2 +-
.../security/cnab_cobranca_security.xml | 2 +-
.../tests/test_remessa.REM | 12 +-
.../views/account_payment_line.xml | 2 +-
.../wizard/__init__.py | 1 -
.../wizard/payment_order_create.py | 91 +-
30 files changed, 1627 insertions(+), 1789 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__init__.py b/l10n_br_account_payment_cobranca/__init__.py
index c8562ac383ea..36f9107d400e 100644
--- a/l10n_br_account_payment_cobranca/__init__.py
+++ b/l10n_br_account_payment_cobranca/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# @author Daniel Sadamo
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 5226fddd85fb..594584835762 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# @author Daniel Sadamo
@@ -7,51 +6,42 @@
{
- 'name': 'Account Payment CNAB',
- 'version': '10.0.1.0.0',
- 'category': 'Banking addons',
- 'license': 'AGPL-3',
- 'author': 'KMEE, Odoo Community Association (OCA)',
- 'website': 'http://www.kmee.com.br',
- 'depends': [
- 'base_transaction_id',
- 'l10n_br_account_payment_order',
- ],
- 'data': [
- 'data/l10n_br_payment_export_type.xml',
- 'data/boleto_data.xml',
- 'data/ir_cron.xml',
- 'data/account_analytic_tag_data.xml',
-
- 'security/cnab_cobranca_security.xml',
-
- 'views/res_company.xml',
- 'views/account_payment_mode.xml',
- 'views/res_partner_bank.xml',
- 'views/account_payment_order.xml',
- 'views/account_payment_line.xml',
- 'views/account_payment_term_view.xml',
- 'views/bank_payment_line.xml',
- 'views/account_invoice.xml',
- 'views/bank_api_operation_views.xml',
-
- 'views/account_move_line.xml',
- 'views/l10n_br_cnab_retorno_view.xml',
- 'views/l10n_br_cnab_evento_views.xml',
-
+ "name": "Account Payment CNAB",
+ "version": "10.0.1.0.0",
+ "category": "Banking addons",
+ "license": "AGPL-3",
+ "author": "KMEE, Odoo Community Association (OCA)",
+ "website": "http://www.kmee.com.br",
+ "depends": ["base_transaction_id", "l10n_br_account_payment_order"],
+ "data": [
+ "data/l10n_br_payment_export_type.xml",
+ "data/boleto_data.xml",
+ "data/ir_cron.xml",
+ "data/account_analytic_tag_data.xml",
+ "security/cnab_cobranca_security.xml",
+ "views/res_company.xml",
+ "views/account_payment_mode.xml",
+ "views/res_partner_bank.xml",
+ "views/account_payment_order.xml",
+ "views/account_payment_line.xml",
+ "views/account_payment_term_view.xml",
+ "views/bank_payment_line.xml",
+ "views/account_invoice.xml",
+ "views/bank_api_operation_views.xml",
+ "views/account_move_line.xml",
+ "views/l10n_br_cnab_retorno_view.xml",
+ "views/l10n_br_cnab_evento_views.xml",
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
-
- 'wizard/payment_order_create_wizard.xml',
- 'reports/report_print_button_view.xml',
-
- 'security/ir.model.access.csv',
+ "wizard/payment_order_create_wizard.xml",
+ "reports/report_print_button_view.xml",
+ "security/ir.model.access.csv",
],
- 'demo': [
+ "demo": [
# 'demo/l10n_br_payment_mode.xml',
],
- 'test': [
+ "test": [
# 'tests/invoice_create.yml'
],
"installable": True,
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 651ea7715f76..2d4340c7ae2c 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -1,139 +1,158 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-SEQUENCIAL_EMPRESA = '0'
-SEQUENCIAL_FATURA = '1'
-SEQUENCIAL_CARTEIRA = '2'
+SEQUENCIAL_EMPRESA = "0"
+SEQUENCIAL_FATURA = "1"
+SEQUENCIAL_CARTEIRA = "2"
-COBRANCA = '01'
-BOLETO_PAGAMENTO_ELETRONICO = '03'
-CONCILIACAO_BANCARIA = '04'
-DEBITOS = '05'
-CUSTODIA_CHEQUES = '06'
-GESTAO_CAIXA = '07'
-CONSULTA_INFORMACAO_MARGEM = '08'
-AVERBACAO_CONSIGNACAO_RETENCAO = '09'
-PAGAMENTO_DIVIDENDOS = '10'
-MANUTENCAO_CONSIGNACAO = '11'
-CONSIGNACAO_PARCELAS = '12'
-GLOSA_CONSIGNACAO = '13'
-CONSULTA_TRIBUTOS_PAGAR = '14'
-PAGAMENTO_FORNECEDOR = '20'
-PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS = '22'
-INTEROPERABILIDADE_CONTAS = '23'
-COMPROR = '25'
-COMPROR_ROTATIVO = '26'
-ALEGACAO_PAGADOR = '29'
-PAGAMENTO_SALARIOS = '30'
-PAGAMENTO_HONORARIOS = '32'
-PAGAMENTO_BOLSA_AUXILIO = '33'
-PAGAMENTO_PREBENDA = '34'
-VENDOR = '40'
-VENDOR_TERMO = '41'
-PAGAMENTO_SINISTROS_SEGURADOS = '50'
-PAGAMENTO_DESPESAS_VIAJANTE = '60'
-PAGAMENTO_AUTORIZADO = '70'
-PAGAMENTO_CREDENCIADOS = '75'
-PAGAMENTO_REMUNERACAO = '77'
-PAGAMENTO_REPRESENTANTES = '80'
-PAGAMENTO_BENEFICIOS = '90'
-PAGAMENTOS_DIVERSOS = '98'
+COBRANCA = "01"
+BOLETO_PAGAMENTO_ELETRONICO = "03"
+CONCILIACAO_BANCARIA = "04"
+DEBITOS = "05"
+CUSTODIA_CHEQUES = "06"
+GESTAO_CAIXA = "07"
+CONSULTA_INFORMACAO_MARGEM = "08"
+AVERBACAO_CONSIGNACAO_RETENCAO = "09"
+PAGAMENTO_DIVIDENDOS = "10"
+MANUTENCAO_CONSIGNACAO = "11"
+CONSIGNACAO_PARCELAS = "12"
+GLOSA_CONSIGNACAO = "13"
+CONSULTA_TRIBUTOS_PAGAR = "14"
+PAGAMENTO_FORNECEDOR = "20"
+PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS = "22"
+INTEROPERABILIDADE_CONTAS = "23"
+COMPROR = "25"
+COMPROR_ROTATIVO = "26"
+ALEGACAO_PAGADOR = "29"
+PAGAMENTO_SALARIOS = "30"
+PAGAMENTO_HONORARIOS = "32"
+PAGAMENTO_BOLSA_AUXILIO = "33"
+PAGAMENTO_PREBENDA = "34"
+VENDOR = "40"
+VENDOR_TERMO = "41"
+PAGAMENTO_SINISTROS_SEGURADOS = "50"
+PAGAMENTO_DESPESAS_VIAJANTE = "60"
+PAGAMENTO_AUTORIZADO = "70"
+PAGAMENTO_CREDENCIADOS = "75"
+PAGAMENTO_REMUNERACAO = "77"
+PAGAMENTO_REPRESENTANTES = "80"
+PAGAMENTO_BENEFICIOS = "90"
+PAGAMENTOS_DIVERSOS = "98"
TIPO_SERVICO = [
- (COBRANCA, COBRANCA + u' - Cobrança'),
- (BOLETO_PAGAMENTO_ELETRONICO, BOLETO_PAGAMENTO_ELETRONICO +
- u' - Boleto de Pagamento Eletrônico'),
- (CONCILIACAO_BANCARIA, CONCILIACAO_BANCARIA + u' - Conciliação Bancária'),
- (DEBITOS, DEBITOS + u' - Débitos'),
- (CUSTODIA_CHEQUES, CUSTODIA_CHEQUES + u' - Custódia de Cheques'),
- (GESTAO_CAIXA, GESTAO_CAIXA + u' - Gestão de Caixa'),
- (CONSULTA_INFORMACAO_MARGEM, CONSULTA_INFORMACAO_MARGEM +
- u' - Consulta/Informação Margem'),
- (AVERBACAO_CONSIGNACAO_RETENCAO, AVERBACAO_CONSIGNACAO_RETENCAO +
- u' - Averbação da Consignação/Retenção'),
- (PAGAMENTO_DIVIDENDOS, PAGAMENTO_DIVIDENDOS + u' - Pagamento Dividendos'),
- (MANUTENCAO_CONSIGNACAO, MANUTENCAO_CONSIGNACAO +
- u' - Manutenção da Consignação'),
- (CONSIGNACAO_PARCELAS, CONSIGNACAO_PARCELAS +
- u' - Consignação de Parcelas'),
- (GLOSA_CONSIGNACAO, GLOSA_CONSIGNACAO +
- u' - Glosa da Consignação (INSS)'),
- (CONSULTA_TRIBUTOS_PAGAR, CONSULTA_TRIBUTOS_PAGAR +
- u' - Consulta de Tributos a pagar'),
- (PAGAMENTO_FORNECEDOR, PAGAMENTO_FORNECEDOR +
- u' - Pagamento Fornecedor'),
- (PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS, PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS +
- u' - Pagamento de Contas, Tributos e Impostos'),
- (INTEROPERABILIDADE_CONTAS, INTEROPERABILIDADE_CONTAS +
- u' - Interoperabilidade entre Contas de Instituições de Pagamentos'),
- (COMPROR, COMPROR + u' - Compror'),
- (COMPROR_ROTATIVO, COMPROR_ROTATIVO + u' - Compror Rotativo'),
- (ALEGACAO_PAGADOR, ALEGACAO_PAGADOR + u' - Alegação do Pagador'),
- (PAGAMENTO_SALARIOS, PAGAMENTO_SALARIOS + u' - Pagamento Salários'),
- (PAGAMENTO_HONORARIOS, PAGAMENTO_HONORARIOS +
- u' - Pagamento de honorários'),
- (PAGAMENTO_BOLSA_AUXILIO, PAGAMENTO_BOLSA_AUXILIO +
- u' - Pagamento de bolsa auxílio'),
- (PAGAMENTO_PREBENDA, PAGAMENTO_PREBENDA +
- u' - Pagamento de prebenda (remuneração a padres e sacerdotes)'),
- (VENDOR, VENDOR + u' - Vendor'),
- (VENDOR_TERMO, VENDOR_TERMO + u' - Vendor a Termo'),
- (PAGAMENTO_SINISTROS_SEGURADOS, PAGAMENTO_SINISTROS_SEGURADOS +
- u' - Pagamento Sinistros Segurados'),
- (PAGAMENTO_DESPESAS_VIAJANTE, PAGAMENTO_DESPESAS_VIAJANTE +
- u' - Pagamento Despesas Viajante em Trânsito'),
- (PAGAMENTO_AUTORIZADO, PAGAMENTO_AUTORIZADO + u' - Pagamento Autorizado'),
- (PAGAMENTO_CREDENCIADOS, PAGAMENTO_CREDENCIADOS +
- u' - Pagamento Credenciados'),
- (PAGAMENTO_REMUNERACAO, PAGAMENTO_REMUNERACAO +
- u' - Pagamento de Remuneração'),
- (PAGAMENTO_REPRESENTANTES, PAGAMENTO_REPRESENTANTES +
- u' - Pagamento Representantes / Vendedores Autorizados'),
- (PAGAMENTO_BENEFICIOS, PAGAMENTO_BENEFICIOS + u' - Pagamento Benefícios'),
- (PAGAMENTOS_DIVERSOS, PAGAMENTOS_DIVERSOS + u' - Pagamentos Diversos'),
+ (COBRANCA, COBRANCA + u" - Cobrança"),
+ (
+ BOLETO_PAGAMENTO_ELETRONICO,
+ BOLETO_PAGAMENTO_ELETRONICO + u" - Boleto de Pagamento Eletrônico",
+ ),
+ (CONCILIACAO_BANCARIA, CONCILIACAO_BANCARIA + u" - Conciliação Bancária"),
+ (DEBITOS, DEBITOS + u" - Débitos"),
+ (CUSTODIA_CHEQUES, CUSTODIA_CHEQUES + u" - Custódia de Cheques"),
+ (GESTAO_CAIXA, GESTAO_CAIXA + u" - Gestão de Caixa"),
+ (
+ CONSULTA_INFORMACAO_MARGEM,
+ CONSULTA_INFORMACAO_MARGEM + u" - Consulta/Informação Margem",
+ ),
+ (
+ AVERBACAO_CONSIGNACAO_RETENCAO,
+ AVERBACAO_CONSIGNACAO_RETENCAO + u" - Averbação da Consignação/Retenção",
+ ),
+ (PAGAMENTO_DIVIDENDOS, PAGAMENTO_DIVIDENDOS + u" - Pagamento Dividendos"),
+ (MANUTENCAO_CONSIGNACAO, MANUTENCAO_CONSIGNACAO + u" - Manutenção da Consignação"),
+ (CONSIGNACAO_PARCELAS, CONSIGNACAO_PARCELAS + u" - Consignação de Parcelas"),
+ (GLOSA_CONSIGNACAO, GLOSA_CONSIGNACAO + u" - Glosa da Consignação (INSS)"),
+ (
+ CONSULTA_TRIBUTOS_PAGAR,
+ CONSULTA_TRIBUTOS_PAGAR + u" - Consulta de Tributos a pagar",
+ ),
+ (PAGAMENTO_FORNECEDOR, PAGAMENTO_FORNECEDOR + u" - Pagamento Fornecedor"),
+ (
+ PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS,
+ PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS
+ + u" - Pagamento de Contas, Tributos e Impostos",
+ ),
+ (
+ INTEROPERABILIDADE_CONTAS,
+ INTEROPERABILIDADE_CONTAS
+ + u" - Interoperabilidade entre Contas de Instituições de Pagamentos",
+ ),
+ (COMPROR, COMPROR + u" - Compror"),
+ (COMPROR_ROTATIVO, COMPROR_ROTATIVO + u" - Compror Rotativo"),
+ (ALEGACAO_PAGADOR, ALEGACAO_PAGADOR + u" - Alegação do Pagador"),
+ (PAGAMENTO_SALARIOS, PAGAMENTO_SALARIOS + u" - Pagamento Salários"),
+ (PAGAMENTO_HONORARIOS, PAGAMENTO_HONORARIOS + u" - Pagamento de honorários"),
+ (
+ PAGAMENTO_BOLSA_AUXILIO,
+ PAGAMENTO_BOLSA_AUXILIO + u" - Pagamento de bolsa auxílio",
+ ),
+ (
+ PAGAMENTO_PREBENDA,
+ PAGAMENTO_PREBENDA
+ + u" - Pagamento de prebenda (remuneração a padres e sacerdotes)",
+ ),
+ (VENDOR, VENDOR + u" - Vendor"),
+ (VENDOR_TERMO, VENDOR_TERMO + u" - Vendor a Termo"),
+ (
+ PAGAMENTO_SINISTROS_SEGURADOS,
+ PAGAMENTO_SINISTROS_SEGURADOS + u" - Pagamento Sinistros Segurados",
+ ),
+ (
+ PAGAMENTO_DESPESAS_VIAJANTE,
+ PAGAMENTO_DESPESAS_VIAJANTE + u" - Pagamento Despesas Viajante em Trânsito",
+ ),
+ (PAGAMENTO_AUTORIZADO, PAGAMENTO_AUTORIZADO + u" - Pagamento Autorizado"),
+ (PAGAMENTO_CREDENCIADOS, PAGAMENTO_CREDENCIADOS + u" - Pagamento Credenciados"),
+ (PAGAMENTO_REMUNERACAO, PAGAMENTO_REMUNERACAO + u" - Pagamento de Remuneração"),
+ (
+ PAGAMENTO_REPRESENTANTES,
+ PAGAMENTO_REPRESENTANTES
+ + u" - Pagamento Representantes / Vendedores Autorizados",
+ ),
+ (PAGAMENTO_BENEFICIOS, PAGAMENTO_BENEFICIOS + u" - Pagamento Benefícios"),
+ (PAGAMENTOS_DIVERSOS, PAGAMENTOS_DIVERSOS + u" - Pagamentos Diversos"),
]
-CREDITO_CONTA_CORRENTE_SALARIO = (
- '01', u'01 - Crédito em Conta Corrente/Salário')
-CHEQUE_PAGAMENTO_ADMINISTRATIVO = (
- '02', u'02 - Cheque Pagamento / Administrativo')
-DOC_TED = ('03', u'03 - DOC/TED (1) (2)')
-CARTAO_SALARIO = (
- '04', u'04 - Cartão Salário (somente para Tipo de Serviço = \'30\')')
-CREDITO_CONTA_POUPANCA = ('05', u'05 - Crédito em Conta Poupança')
-OP_A_DISPOSICAO = ('10', u'10 - OP à Disposição')
+CREDITO_CONTA_CORRENTE_SALARIO = ("01", u"01 - Crédito em Conta Corrente/Salário")
+CHEQUE_PAGAMENTO_ADMINISTRATIVO = ("02", u"02 - Cheque Pagamento / Administrativo")
+DOC_TED = ("03", u"03 - DOC/TED (1) (2)")
+CARTAO_SALARIO = ("04", u"04 - Cartão Salário (somente para Tipo de Serviço = '30')")
+CREDITO_CONTA_POUPANCA = ("05", u"05 - Crédito em Conta Poupança")
+OP_A_DISPOSICAO = ("10", u"10 - OP à Disposição")
PAGAMENTO_CONTAS_TRIBUTOS_CODIGO_BARRAS = (
- '11', u'11 - Pagamento de Contas e Tributos com Código de Barras')
-TRIBUTO_DARF_NORMAL = ('16', u'16 - Tributo - DARF Normal')
-TRIBUTO_GPS = ('17', u'17 - Tributo - GPS (Guia da Previdência Social)')
-TRIBUTO_DARF_SIMPLES = ('18', u'18 - Tributo - DARF Simples')
-TRIBUTO_IPTU_PREFEITURAS = ('19', u'19 - Tributo - IPTU – Prefeituras')
-PAGAMENTO_AUTENTICACAO = ('20', u'20 - Pagamento com Autenticação')
-TRIBUTO_DARJ = ('21', u'21 - Tributo – DARJ')
-TRIBUTO_GARE_SP_ICMS = ('22', u'22 - Tributo - GARE-SP ICMS')
-TRIBUTO_GARE_SP_DR = ('23', u'23 - Tributo - GARE-SP DR')
-TRIBUTO_GARE_SP_ITCMD = ('24', u'24 - Tributo - GARE-SP ITCMD')
-TRIBUTO_IPVA = ('25', u'25 - Tributo - IPVA')
-TRIBUTO_LICENCIAMENTO = ('26', u'26 - Tributo - Licenciamento')
-TRIBUTO_DPVAT = ('27', u'27 - Tributo – DPVAT')
+ "11",
+ u"11 - Pagamento de Contas e Tributos com Código de Barras",
+)
+TRIBUTO_DARF_NORMAL = ("16", u"16 - Tributo - DARF Normal")
+TRIBUTO_GPS = ("17", u"17 - Tributo - GPS (Guia da Previdência Social)")
+TRIBUTO_DARF_SIMPLES = ("18", u"18 - Tributo - DARF Simples")
+TRIBUTO_IPTU_PREFEITURAS = ("19", u"19 - Tributo - IPTU – Prefeituras")
+PAGAMENTO_AUTENTICACAO = ("20", u"20 - Pagamento com Autenticação")
+TRIBUTO_DARJ = ("21", u"21 - Tributo – DARJ")
+TRIBUTO_GARE_SP_ICMS = ("22", u"22 - Tributo - GARE-SP ICMS")
+TRIBUTO_GARE_SP_DR = ("23", u"23 - Tributo - GARE-SP DR")
+TRIBUTO_GARE_SP_ITCMD = ("24", u"24 - Tributo - GARE-SP ITCMD")
+TRIBUTO_IPVA = ("25", u"25 - Tributo - IPVA")
+TRIBUTO_LICENCIAMENTO = ("26", u"26 - Tributo - Licenciamento")
+TRIBUTO_DPVAT = ("27", u"27 - Tributo – DPVAT")
LIQUIDACAO_TITULOS_PROPRIO_BANCO = (
- '30', u'30 - Liquidação de Títulos do Próprio Banco')
-PAGAMENTO_TITULOS_OUTROS_BANCOS = (
- '31', u'31 - Pagamento de Títulos de Outros Bancos')
-EXTRATO_CONTA_CORRENTE = ('40', u'40 - Extrato de Conta Corrente')
-TED_OUTRA_TITULARIDADE = ('41', u'41 - TED – Outra Titularidade (1)')
-TED_MESMA_TITULARIDADE = ('43', u'43 - TED – Mesma Titularidade (1)')
+ "30",
+ u"30 - Liquidação de Títulos do Próprio Banco",
+)
+PAGAMENTO_TITULOS_OUTROS_BANCOS = ("31", u"31 - Pagamento de Títulos de Outros Bancos")
+EXTRATO_CONTA_CORRENTE = ("40", u"40 - Extrato de Conta Corrente")
+TED_OUTRA_TITULARIDADE = ("41", u"41 - TED – Outra Titularidade (1)")
+TED_MESMA_TITULARIDADE = ("43", u"43 - TED – Mesma Titularidade (1)")
TED_TRANSFERENCIA_CONTA_INVESTIMENTO = (
- '44', u'44 - TED para Transferência de Conta Investimento')
-DEBITO_CONTA_CORRENTE = ('50', u'50 - Débito em Conta Corrente')
-EXTRATO_GESTAO_CAIXA = ('70', u'70 - Extrato para Gestão de Caixa')
-DEPOSITO_JUDICIAL_CONTA_CORRENTE = (
- '71', u'71 - Depósito Judicial em Conta Corrente')
-DEPOSITO_JUDICIAL_POUPANCA = ('72', u'72 - Depósito Judicial em Poupança')
-EXTRATO_CONTA_INVESTIMENTO = ('73', u'73 - Extrato de Conta Investimento')
+ "44",
+ u"44 - TED para Transferência de Conta Investimento",
+)
+DEBITO_CONTA_CORRENTE = ("50", u"50 - Débito em Conta Corrente")
+EXTRATO_GESTAO_CAIXA = ("70", u"70 - Extrato para Gestão de Caixa")
+DEPOSITO_JUDICIAL_CONTA_CORRENTE = ("71", u"71 - Depósito Judicial em Conta Corrente")
+DEPOSITO_JUDICIAL_POUPANCA = ("72", u"72 - Depósito Judicial em Poupança")
+EXTRATO_CONTA_INVESTIMENTO = ("73", u"73 - Extrato de Conta Investimento")
FORMA_LANCAMENTO = [
CREDITO_CONTA_CORRENTE_SALARIO,
@@ -168,28 +187,29 @@
EXTRATO_CONTA_INVESTIMENTO,
]
-CREDITO_EM_CONTA = ('01', u'01 - Crédito em Conta')
-PAGAMENTO_ALUGUEL = ('02', u'02 - Pagamento de Aluguel/Condomínio')
-PAGAMENTO_DUPLICATA_TITULOS = ('03', u'03 - Pagamento de Duplicata/Títulos')
-PAGAMENTO_DIVIDENDOS_C = ('04', u'04 - Pagamento de Dividendos')
-PAGAMENTO_MENSALIDADE_ESCOLAR = (
- '05', u'05 - Pagamento de Mensalidade Escolar')
-PAGAMENTO_SALARIOS_C = ('06', u'06 - Pagamento de Salários')
-PAGAMENTO_FORNECEDORES = ('07', u'07 - Pagamento a Fornecedores')
+CREDITO_EM_CONTA = ("01", u"01 - Crédito em Conta")
+PAGAMENTO_ALUGUEL = ("02", u"02 - Pagamento de Aluguel/Condomínio")
+PAGAMENTO_DUPLICATA_TITULOS = ("03", u"03 - Pagamento de Duplicata/Títulos")
+PAGAMENTO_DIVIDENDOS_C = ("04", u"04 - Pagamento de Dividendos")
+PAGAMENTO_MENSALIDADE_ESCOLAR = ("05", u"05 - Pagamento de Mensalidade Escolar")
+PAGAMENTO_SALARIOS_C = ("06", u"06 - Pagamento de Salários")
+PAGAMENTO_FORNECEDORES = ("07", u"07 - Pagamento a Fornecedores")
OPERACOES_CAMBIOS_FUNDOS_BOLSA = (
- '08', u'08 - Operações de Câmbios/Fundos/Bolsa de Valores')
-REPASSE_ARRECADACAO = (
- '09', u'09 - Repasse de Arrecadação/Pagamento de Tributos')
-TRANSFERECIA_INTERNACIONAL_EM_REAL = (
- '10', u'10 - Transferência Internacional em Real')
-DOC_POUPANCA = ('11', u'11 - DOC para Poupança')
-DOC_DEPOSITO_JUDICIAL = ('12', u'12 - DOC para Depósito Judicial')
-OUTROS = ('13', u'13 - Outros')
-PAGAMENTO_BOLSA_AUXILIO_C = ('16', u'16 - Pagamento de bolsa auxílio')
-REMUNERACAO_COOPERADO = ('17', u'17 - Remuneração à cooperado')
-PAGAMENTO_HONORARIOS_C = ('18', u'18 - Pagamento de honorários')
+ "08",
+ u"08 - Operações de Câmbios/Fundos/Bolsa de Valores",
+)
+REPASSE_ARRECADACAO = ("09", u"09 - Repasse de Arrecadação/Pagamento de Tributos")
+TRANSFERECIA_INTERNACIONAL_EM_REAL = ("10", u"10 - Transferência Internacional em Real")
+DOC_POUPANCA = ("11", u"11 - DOC para Poupança")
+DOC_DEPOSITO_JUDICIAL = ("12", u"12 - DOC para Depósito Judicial")
+OUTROS = ("13", u"13 - Outros")
+PAGAMENTO_BOLSA_AUXILIO_C = ("16", u"16 - Pagamento de bolsa auxílio")
+REMUNERACAO_COOPERADO = ("17", u"17 - Remuneração à cooperado")
+PAGAMENTO_HONORARIOS_C = ("18", u"18 - Pagamento de honorários")
PAGAMENTO_PREBENDA_C = (
- '19', u'19 - Pagamento de prebenda (Remuneração a padres e sacerdotes)')
+ "19",
+ u"19 - Pagamento de prebenda (Remuneração a padres e sacerdotes)",
+)
COMPLEMENTO_TIPO_SERVICO = [
CREDITO_EM_CONTA,
@@ -217,17 +237,19 @@
# (www.bcb.gov.br), Sistema de Pagamentos Brasileiro,
# Transferência de Arquivos,
# Dicionários de Domínios para o SPB.
-CODIGO_FINALIDADE_TED = [
- (' ', u'Padrão')
-]
+CODIGO_FINALIDADE_TED = [(" ", u"Padrão")]
-NAO_EMITE_AVISO = ('0', u'0 - Não Emite Aviso')
-EMITE_AVISO_REMETENTE = ('2', u'2 - Emite Aviso Somente para o Remetente')
-EMITE_AVISO_FAVORECIDO = ('5', u'5 - Emite Aviso Somente para o Favorecido')
-EMITE_AVISO_REMETENTE_FAVORECIDO = \
- ('6', u'6 - Emite Aviso para o Remetente e Favorecido')
-EMITE_AVISO_FAVORECIDO_2_VIAS_REMETENTE = \
- ('7', u'7 - Emite Aviso para o Favorecido e 2 Vias para o Remetente')
+NAO_EMITE_AVISO = ("0", u"0 - Não Emite Aviso")
+EMITE_AVISO_REMETENTE = ("2", u"2 - Emite Aviso Somente para o Remetente")
+EMITE_AVISO_FAVORECIDO = ("5", u"5 - Emite Aviso Somente para o Favorecido")
+EMITE_AVISO_REMETENTE_FAVORECIDO = (
+ "6",
+ u"6 - Emite Aviso para o Remetente e Favorecido",
+)
+EMITE_AVISO_FAVORECIDO_2_VIAS_REMETENTE = (
+ "7",
+ u"7 - Emite Aviso para o Favorecido e 2 Vias para o Remetente",
+)
AVISO_FAVORECIDO = [
NAO_EMITE_AVISO,
@@ -238,189 +260,213 @@
]
INDICATIVO_FORMA_PAGAMENTO = [
- ('01', u'01 - Débito em Conta Corrente'),
- ('02', u'02 - Débito Empréstimo/Financiamento'),
- ('03', u'03 - Débito Cartão de Crédito'),
+ ("01", u"01 - Débito em Conta Corrente"),
+ ("02", u"02 - Débito Empréstimo/Financiamento"),
+ ("03", u"03 - Débito Cartão de Crédito"),
]
TIPO_MOVIMENTO = [
- ('0', u'0 - Indica INCLUSÃO'),
- ('1', u'1 - Indica CONSULTA'),
- ('2', u'2 - Indica SUSPENSÃO'),
- ('3', u'3 - Indica ESTORNO (somente para retorno)'),
- ('4', u'4 - Indica REATIVAÇÃO'),
- ('5', u'5 - Indica ALTERAÇÃO'),
- ('7', u'7 - Indica LIQUIDAÇAO'),
- ('9', u'9 - Indica EXCLUSÃO'),
+ ("0", u"0 - Indica INCLUSÃO"),
+ ("1", u"1 - Indica CONSULTA"),
+ ("2", u"2 - Indica SUSPENSÃO"),
+ ("3", u"3 - Indica ESTORNO (somente para retorno)"),
+ ("4", u"4 - Indica REATIVAÇÃO"),
+ ("5", u"5 - Indica ALTERAÇÃO"),
+ ("7", u"7 - Indica LIQUIDAÇAO"),
+ ("9", u"9 - Indica EXCLUSÃO"),
]
CODIGO_INSTRUCAO_MOVIMENTO = [
- ('0', u'00 - Inclusão de Registro Detalhe Liberado'),
- ('9', u'09 - Inclusão do Registro Detalhe Bloqueado'),
- ('10', u'10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)'),
- ('11', u'11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)'),
- ('17', u'17 - Alteração do Valor do Título'),
- ('19', u'19 - Alteração da Data de Pagamento'),
- ('23', u'23 - Pagamento Direto ao Fornecedor - Baixar'),
- ('25', u'25 - Manutenção em Carteira - Não Pagar'),
- ('27', u'27 - Retirada de Carteira - Não Pagar'),
- ('33', u'33 - Estorno por Devolução da Câmara Centralizadora '
- u'(somente para Tipo de Movimento = \'3\')'),
- ('40', u'40 - Alegação do Pagador'),
- ('99', u'99 - Exclusão do Registro Detalhe Incluído Anteriormente'),
+ ("0", u"00 - Inclusão de Registro Detalhe Liberado"),
+ ("9", u"09 - Inclusão do Registro Detalhe Bloqueado"),
+ ("10", u"10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)"),
+ ("11", u"11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)"),
+ ("17", u"17 - Alteração do Valor do Título"),
+ ("19", u"19 - Alteração da Data de Pagamento"),
+ ("23", u"23 - Pagamento Direto ao Fornecedor - Baixar"),
+ ("25", u"25 - Manutenção em Carteira - Não Pagar"),
+ ("27", u"27 - Retirada de Carteira - Não Pagar"),
+ (
+ "33",
+ u"33 - Estorno por Devolução da Câmara Centralizadora "
+ u"(somente para Tipo de Movimento = '3')",
+ ),
+ ("40", u"40 - Alegação do Pagador"),
+ ("99", u"99 - Exclusão do Registro Detalhe Incluído Anteriormente"),
]
CODIGO_OCORRENCIAS = [
- ('00', u'00 - Crédito ou Débito Efetivado'),
- ('01', u'01 - Insuficiência de Fundos - Débito Não Efetuado'),
- ('02', u'02 - Crédito ou Débito Cancelado pelo Pagador/Credor'),
- ('03', u'03 - Débito Autorizado pela Agência - Efetuado'),
- ('AA', u'AA - Controle Inválido'),
- ('AB', u'AB - Tipo de Operação Inválido'),
- ('AC', u'AC - Tipo de Serviço Inválido'),
- ('AD', u'AD - Forma de Lançamento Inválida'),
- ('AE', u'AE - Tipo/Número de Inscrição Inválido'),
- ('AF', u'AF - Código de Convênio Inválido'),
- ('AG', u'AG - Agência/Conta Corrente/DV Inválido'),
- ('AH', u'AH - Nº Seqüencial do Registro no Lote Inválido'),
- ('AI', u'AI - Código de Segmento de Detalhe Inválido'),
- ('AJ', u'AJ - Tipo de Movimento Inválido'),
- ('AK', u'AK - Código da Câmara de Compensação do Banco'
- u' Favorecido/Depositário Inválido'),
- ('AL', u'AL - Código do Banco Favorecido, Instituição de Pagamento'
- u' ou Depositário Inválido'),
- ('AM', u'AM - Agência Mantenedora da Conta Corrente do'
- u' Favorecido Inválida'),
- ('AN', u'AN - Conta Corrente/DV/Conta de Pagamento do'
- u' Favorecido Inválido'),
- ('AO', u'AO - Nome do Favorecido Não Informado'),
- ('AP', u'AP - Data Lançamento Inválido'),
- ('AQ', u'AQ - Tipo/Quantidade da Moeda Inválido'),
- ('AR', u'AR - Valor do Lançamento Inválido'),
- ('AS', u'AS - Aviso ao Favorecido - Identificação Inválida'),
- ('AT', u'AT - Tipo/Número de Inscrição do Favorecido Inválido'),
- ('AU', u'AU - Logradouro do Favorecido Não Informado'),
- ('AV', u'AV - Nº do Local do Favorecido Não Informado'),
- ('AW', u'AW - Cidade do Favorecido Não Informada'),
- ('AX', u'AX - CEP/Complemento do Favorecido Inválido'),
- ('AY', u'AY - Sigla do Estado do Favorecido Inválida'),
- ('AZ', u'AZ - Código/Nome do Banco Depositário Inválido'),
- ('BA', u'BA - Código/Nome da Agência Depositária Não Informado'),
- ('BB', u'BB - Seu Número Inválido'),
- ('BC', u'BC - Nosso Número Inválido'),
- ('BD', u'BD - Inclusão Efetuada com Sucesso'),
- ('BE', u'BE - Alteração Efetuada com Sucesso'),
- ('BF', u'BF - Exclusão Efetuada com Sucesso'),
- ('BG', u'BG - Agência/Conta Impedida Legalmente'),
- ('BH', u'BH - Empresa não pagou salário'),
- ('BI', u'BI - Falecimento do mutuário'),
- ('BJ', u'BJ - Empresa não enviou remessa do mutuário'),
- ('BK', u'BK - Empresa não enviou remessa no vencimento'),
- ('BL', u'BL - Valor da parcela inválida'),
- ('BM', u'BM - Identificação do contrato inválida'),
- ('BN', u'BN - Operação de Consignação Incluída com Sucesso'),
- ('BO', u'BO - Operação de Consignação Alterada com Sucesso'),
- ('BP', u'BP - Operação de Consignação Excluída com Sucesso'),
- ('BQ', u'BQ - Operação de Consignação Liquidada com Sucesso'),
- ('BR', u'BR - Reativação Efetuada com Sucesso'),
- ('BS', u'BS - Suspensão Efetuada com Sucesso'),
- ('CA', u'CA - Código de Barras - Código do Banco Inválido'),
- ('CB', u'CB - Código de Barras - Código da Moeda Inválido'),
- ('CC', u'CC - Código de Barras - Dígito Verificador Geral Inválido'),
- ('CD', u'CD - Código de Barras - Valor do Título Inválido'),
- ('CE', u'CE - Código de Barras - Campo Livre Inválido'),
- ('CF', u'CF - Valor do Documento Inválido'),
- ('CG', u'CG - Valor do Abatimento Inválido'),
- ('CH', u'CH - Valor do Desconto Inválido'),
- ('CI', u'CI - Valor de Mora Inválido'),
- ('CJ', u'CJ - Valor da Multa Inválido'),
- ('CK', u'CK - Valor do IR Inválido'),
- ('CL', u'CL - Valor do ISS Inválido'),
- ('CM', u'CM - Valor do IOF Inválido'),
- ('CN', u'CN - Valor de Outras Deduções Inválido'),
- ('CO', u'CO - Valor de Outros Acréscimos Inválido'),
- ('CP', u'CP - Valor do INSS Inválido'),
- ('HA', u'HA - Lote Não Aceito'),
- ('HB', u'HB - Inscrição da Empresa Inválida para o Contrato'),
- ('HC', u'HC - Convênio com a Empresa Inexistente/Inválido'
- u' para o Contrato'),
- ('HD', u'HD - Agência/Conta Corrente da Empresa Inexistente/Inválido'
- u' para o Contrato'),
- ('HE', u'HE - Tipo de Serviço Inválido para o Contrato'),
- ('HF', u'HF - Conta Corrente da Empresa com Saldo Insuficiente'),
- ('HG', u'HG - Lote de Serviço Fora de Seqüência'),
- ('HH', u'HH - Lote de Serviço Inválido'),
- ('HI', u'HI - Arquivo não aceito'),
- ('HJ', u'HJ - Tipo de Registro Inválido'),
- ('HK', u'HK - Código Remessa / Retorno Inválido'),
- ('HL', u'HL - Versão de layout inválida'),
- ('HM', u'HM - Mutuário não identificado'),
- ('HN', u'HN - Tipo do beneficio não permite empréstimo'),
- ('HO', u'HO - Beneficio cessado/suspenso'),
- ('HP', u'HP - Beneficio possui representante legal'),
- ('HQ', u'HQ - Beneficio é do tipo PA (Pensão alimentícia)'),
- ('HR', u'HR - Quantidade de contratos permitida excedida'),
- ('HS', u'HS - Beneficio não pertence ao Banco informado'),
- ('HT', u'HT - Início do desconto informado já ultrapassado'),
- ('HU', u'HU - Número da parcela inválida'),
- ('HV', u'HV - Quantidade de parcela inválida'),
- ('HW', u'HW - Margem consignável excedida para o mutuário dentro'
- u' do prazo do contrato'),
- ('HX', u'HX - Empréstimo já cadastrado'),
- ('HY', u'HY - Empréstimo inexistente'),
- ('HZ', u'HZ - Empréstimo já encerrado'),
- ('H1', u'H1 - Arquivo sem trailer'),
- ('H2', u'H2 - Mutuário sem crédito na competência'),
- ('H3', u'H3 - Não descontado – outros motivos'),
- ('H4', u'H4 - Retorno de Crédito não pago'),
- ('H5', u'H5 - Cancelamento de empréstimo retroativo'),
- ('H6', u'H6 - Outros Motivos de Glosa'),
- ('H7', u'H7 - Margem consignável excedida para o mutuário acima'
- u' do prazo do contrato'),
- ('H8', u'H8 - Mutuário desligado do empregador'),
- ('H9', u'H9 - Mutuário afastado por licença'),
- ('IA', u'IA - Primeiro nome do mutuário diferente do primeiro nome'
- u' do movimento do censo ou diferente da base de Titular'
- u' do Benefício'),
- ('IB', u'IB - Benefício suspenso/cessado pela APS ou Sisobi'),
- ('IC', u'IC - Benefício suspenso por dependência de cálculo'),
- ('ID', u'ID - Benefício suspenso/cessado pela inspetoria/auditoria'),
- ('IE', u'IE - Benefício bloqueado para empréstimo pelo beneficiário'),
- ('IF', u'IF - Benefício bloqueado para empréstimo por TBM'),
- ('IG', u'IG - Benefício está em fase de concessão de PA ou desdobramento'),
- ('IH', u'IH - Benefício cessado por óbito'),
- ('II', u'II - Benefício cessado por fraude'),
- ('IJ', u'IJ - Benefício cessado por concessão de outro benefício'),
- ('IK', u'IK - Benefício cessado: estatutário transferido'
- u' para órgão de origem'),
- ('IL', u'IL - Empréstimo suspenso pela APS'),
- ('IM', u'IM - Empréstimo cancelado pelo banco'),
- ('IN', u'IN - Crédito transformado em PAB'),
- ('IO', u'IO - Término da consignação foi alterado'),
- ('IP', u'IP - Fim do empréstimo ocorreu durante período'
- u' de suspensão ou concessão'),
- ('IQ', u'IQ - Empréstimo suspenso pelo banco'),
- ('IR', u'IR - Não averbação de contrato – quantidade de'
- u' parcelas/competências informadas ultrapassou a data limite'
- u' da extinção de cota do dependente titular de benefícios'),
- ('TA', u'TA - Lote Não Aceito - Totais do Lote com Diferença'),
- ('YA', u'YA - Título Não Encontrado'),
- ('YB', u'YB - Identificador Registro Opcional Inválido'),
- ('YC', u'YC - Código Padrão Inválido'),
- ('YD', u'YD - Código de Ocorrência Inválido'),
- ('YE', u'YE - Complemento de Ocorrência Inválido'),
- ('YF', u'YF - Alegação já Informada'),
- ('ZA', u'ZA - Agência / Conta do Favorecido Substituída'),
- ('ZB', u'ZB - Divergência entre o primeiro e último nome do beneficiário'
- u' versus primeiro e último nome na Receita Federal'),
- ('ZC', u'ZC - Confirmação de Antecipação de Valor'),
- ('ZD', u'ZD - Antecipação parcial de valor'),
- ('ZE', u'ZE - Título bloqueado na base'),
- ('ZF', u'ZF - Sistema em contingência'
- u' – título valor maior que referência'),
- ('ZG', u'ZG - Sistema em contingência – título vencido'),
- ('ZH', u'ZH - Sistema em contingência – título indexado'),
- ('ZI', u'ZI - Beneficiário divergente'),
- ('ZJ', u'ZJ - Limite de pagamentos parciais excedido'),
- ('ZK', u'ZK - Boleto já liquidado'),
+ ("00", u"00 - Crédito ou Débito Efetivado"),
+ ("01", u"01 - Insuficiência de Fundos - Débito Não Efetuado"),
+ ("02", u"02 - Crédito ou Débito Cancelado pelo Pagador/Credor"),
+ ("03", u"03 - Débito Autorizado pela Agência - Efetuado"),
+ ("AA", u"AA - Controle Inválido"),
+ ("AB", u"AB - Tipo de Operação Inválido"),
+ ("AC", u"AC - Tipo de Serviço Inválido"),
+ ("AD", u"AD - Forma de Lançamento Inválida"),
+ ("AE", u"AE - Tipo/Número de Inscrição Inválido"),
+ ("AF", u"AF - Código de Convênio Inválido"),
+ ("AG", u"AG - Agência/Conta Corrente/DV Inválido"),
+ ("AH", u"AH - Nº Seqüencial do Registro no Lote Inválido"),
+ ("AI", u"AI - Código de Segmento de Detalhe Inválido"),
+ ("AJ", u"AJ - Tipo de Movimento Inválido"),
+ (
+ "AK",
+ u"AK - Código da Câmara de Compensação do Banco"
+ u" Favorecido/Depositário Inválido",
+ ),
+ (
+ "AL",
+ u"AL - Código do Banco Favorecido, Instituição de Pagamento"
+ u" ou Depositário Inválido",
+ ),
+ ("AM", u"AM - Agência Mantenedora da Conta Corrente do" u" Favorecido Inválida"),
+ ("AN", u"AN - Conta Corrente/DV/Conta de Pagamento do" u" Favorecido Inválido"),
+ ("AO", u"AO - Nome do Favorecido Não Informado"),
+ ("AP", u"AP - Data Lançamento Inválido"),
+ ("AQ", u"AQ - Tipo/Quantidade da Moeda Inválido"),
+ ("AR", u"AR - Valor do Lançamento Inválido"),
+ ("AS", u"AS - Aviso ao Favorecido - Identificação Inválida"),
+ ("AT", u"AT - Tipo/Número de Inscrição do Favorecido Inválido"),
+ ("AU", u"AU - Logradouro do Favorecido Não Informado"),
+ ("AV", u"AV - Nº do Local do Favorecido Não Informado"),
+ ("AW", u"AW - Cidade do Favorecido Não Informada"),
+ ("AX", u"AX - CEP/Complemento do Favorecido Inválido"),
+ ("AY", u"AY - Sigla do Estado do Favorecido Inválida"),
+ ("AZ", u"AZ - Código/Nome do Banco Depositário Inválido"),
+ ("BA", u"BA - Código/Nome da Agência Depositária Não Informado"),
+ ("BB", u"BB - Seu Número Inválido"),
+ ("BC", u"BC - Nosso Número Inválido"),
+ ("BD", u"BD - Inclusão Efetuada com Sucesso"),
+ ("BE", u"BE - Alteração Efetuada com Sucesso"),
+ ("BF", u"BF - Exclusão Efetuada com Sucesso"),
+ ("BG", u"BG - Agência/Conta Impedida Legalmente"),
+ ("BH", u"BH - Empresa não pagou salário"),
+ ("BI", u"BI - Falecimento do mutuário"),
+ ("BJ", u"BJ - Empresa não enviou remessa do mutuário"),
+ ("BK", u"BK - Empresa não enviou remessa no vencimento"),
+ ("BL", u"BL - Valor da parcela inválida"),
+ ("BM", u"BM - Identificação do contrato inválida"),
+ ("BN", u"BN - Operação de Consignação Incluída com Sucesso"),
+ ("BO", u"BO - Operação de Consignação Alterada com Sucesso"),
+ ("BP", u"BP - Operação de Consignação Excluída com Sucesso"),
+ ("BQ", u"BQ - Operação de Consignação Liquidada com Sucesso"),
+ ("BR", u"BR - Reativação Efetuada com Sucesso"),
+ ("BS", u"BS - Suspensão Efetuada com Sucesso"),
+ ("CA", u"CA - Código de Barras - Código do Banco Inválido"),
+ ("CB", u"CB - Código de Barras - Código da Moeda Inválido"),
+ ("CC", u"CC - Código de Barras - Dígito Verificador Geral Inválido"),
+ ("CD", u"CD - Código de Barras - Valor do Título Inválido"),
+ ("CE", u"CE - Código de Barras - Campo Livre Inválido"),
+ ("CF", u"CF - Valor do Documento Inválido"),
+ ("CG", u"CG - Valor do Abatimento Inválido"),
+ ("CH", u"CH - Valor do Desconto Inválido"),
+ ("CI", u"CI - Valor de Mora Inválido"),
+ ("CJ", u"CJ - Valor da Multa Inválido"),
+ ("CK", u"CK - Valor do IR Inválido"),
+ ("CL", u"CL - Valor do ISS Inválido"),
+ ("CM", u"CM - Valor do IOF Inválido"),
+ ("CN", u"CN - Valor de Outras Deduções Inválido"),
+ ("CO", u"CO - Valor de Outros Acréscimos Inválido"),
+ ("CP", u"CP - Valor do INSS Inválido"),
+ ("HA", u"HA - Lote Não Aceito"),
+ ("HB", u"HB - Inscrição da Empresa Inválida para o Contrato"),
+ ("HC", u"HC - Convênio com a Empresa Inexistente/Inválido" u" para o Contrato"),
+ (
+ "HD",
+ u"HD - Agência/Conta Corrente da Empresa Inexistente/Inválido"
+ u" para o Contrato",
+ ),
+ ("HE", u"HE - Tipo de Serviço Inválido para o Contrato"),
+ ("HF", u"HF - Conta Corrente da Empresa com Saldo Insuficiente"),
+ ("HG", u"HG - Lote de Serviço Fora de Seqüência"),
+ ("HH", u"HH - Lote de Serviço Inválido"),
+ ("HI", u"HI - Arquivo não aceito"),
+ ("HJ", u"HJ - Tipo de Registro Inválido"),
+ ("HK", u"HK - Código Remessa / Retorno Inválido"),
+ ("HL", u"HL - Versão de layout inválida"),
+ ("HM", u"HM - Mutuário não identificado"),
+ ("HN", u"HN - Tipo do beneficio não permite empréstimo"),
+ ("HO", u"HO - Beneficio cessado/suspenso"),
+ ("HP", u"HP - Beneficio possui representante legal"),
+ ("HQ", u"HQ - Beneficio é do tipo PA (Pensão alimentícia)"),
+ ("HR", u"HR - Quantidade de contratos permitida excedida"),
+ ("HS", u"HS - Beneficio não pertence ao Banco informado"),
+ ("HT", u"HT - Início do desconto informado já ultrapassado"),
+ ("HU", u"HU - Número da parcela inválida"),
+ ("HV", u"HV - Quantidade de parcela inválida"),
+ (
+ "HW",
+ u"HW - Margem consignável excedida para o mutuário dentro"
+ u" do prazo do contrato",
+ ),
+ ("HX", u"HX - Empréstimo já cadastrado"),
+ ("HY", u"HY - Empréstimo inexistente"),
+ ("HZ", u"HZ - Empréstimo já encerrado"),
+ ("H1", u"H1 - Arquivo sem trailer"),
+ ("H2", u"H2 - Mutuário sem crédito na competência"),
+ ("H3", u"H3 - Não descontado – outros motivos"),
+ ("H4", u"H4 - Retorno de Crédito não pago"),
+ ("H5", u"H5 - Cancelamento de empréstimo retroativo"),
+ ("H6", u"H6 - Outros Motivos de Glosa"),
+ (
+ "H7",
+ u"H7 - Margem consignável excedida para o mutuário acima"
+ u" do prazo do contrato",
+ ),
+ ("H8", u"H8 - Mutuário desligado do empregador"),
+ ("H9", u"H9 - Mutuário afastado por licença"),
+ (
+ "IA",
+ u"IA - Primeiro nome do mutuário diferente do primeiro nome"
+ u" do movimento do censo ou diferente da base de Titular"
+ u" do Benefício",
+ ),
+ ("IB", u"IB - Benefício suspenso/cessado pela APS ou Sisobi"),
+ ("IC", u"IC - Benefício suspenso por dependência de cálculo"),
+ ("ID", u"ID - Benefício suspenso/cessado pela inspetoria/auditoria"),
+ ("IE", u"IE - Benefício bloqueado para empréstimo pelo beneficiário"),
+ ("IF", u"IF - Benefício bloqueado para empréstimo por TBM"),
+ ("IG", u"IG - Benefício está em fase de concessão de PA ou desdobramento"),
+ ("IH", u"IH - Benefício cessado por óbito"),
+ ("II", u"II - Benefício cessado por fraude"),
+ ("IJ", u"IJ - Benefício cessado por concessão de outro benefício"),
+ ("IK", u"IK - Benefício cessado: estatutário transferido" u" para órgão de origem"),
+ ("IL", u"IL - Empréstimo suspenso pela APS"),
+ ("IM", u"IM - Empréstimo cancelado pelo banco"),
+ ("IN", u"IN - Crédito transformado em PAB"),
+ ("IO", u"IO - Término da consignação foi alterado"),
+ (
+ "IP",
+ u"IP - Fim do empréstimo ocorreu durante período" u" de suspensão ou concessão",
+ ),
+ ("IQ", u"IQ - Empréstimo suspenso pelo banco"),
+ (
+ "IR",
+ u"IR - Não averbação de contrato – quantidade de"
+ u" parcelas/competências informadas ultrapassou a data limite"
+ u" da extinção de cota do dependente titular de benefícios",
+ ),
+ ("TA", u"TA - Lote Não Aceito - Totais do Lote com Diferença"),
+ ("YA", u"YA - Título Não Encontrado"),
+ ("YB", u"YB - Identificador Registro Opcional Inválido"),
+ ("YC", u"YC - Código Padrão Inválido"),
+ ("YD", u"YD - Código de Ocorrência Inválido"),
+ ("YE", u"YE - Complemento de Ocorrência Inválido"),
+ ("YF", u"YF - Alegação já Informada"),
+ ("ZA", u"ZA - Agência / Conta do Favorecido Substituída"),
+ (
+ "ZB",
+ u"ZB - Divergência entre o primeiro e último nome do beneficiário"
+ u" versus primeiro e último nome na Receita Federal",
+ ),
+ ("ZC", u"ZC - Confirmação de Antecipação de Valor"),
+ ("ZD", u"ZD - Antecipação parcial de valor"),
+ ("ZE", u"ZE - Título bloqueado na base"),
+ ("ZF", u"ZF - Sistema em contingência" u" – título valor maior que referência"),
+ ("ZG", u"ZG - Sistema em contingência – título vencido"),
+ ("ZH", u"ZH - Sistema em contingência – título indexado"),
+ ("ZI", u"ZI - Beneficiário divergente"),
+ ("ZJ", u"ZJ - Limite de pagamentos parciais excedido"),
+ ("ZK", u"ZK - Boleto já liquidado"),
]
diff --git a/l10n_br_account_payment_cobranca/data/ir_cron.xml b/l10n_br_account_payment_cobranca/data/ir_cron.xml
index e7c7bd08dc24..e66e6d737919 100644
--- a/l10n_br_account_payment_cobranca/data/ir_cron.xml
+++ b/l10n_br_account_payment_cobranca/data/ir_cron.xml
@@ -12,4 +12,4 @@
_confirm_debit_orders_api
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index 9aac69e126ff..d5c25fea10cc 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 9de41f83e97f..bf248da25b68 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -1,57 +1,52 @@
-# -*- coding: utf-8 -*-
# @author Danimar Ribeiro
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import models, fields, api, _
+
+from odoo import _, api, fields, models
from odoo.exceptions import UserError
-from ..constantes import (
- SEQUENCIAL_EMPRESA, SEQUENCIAL_FATURA, SEQUENCIAL_CARTEIRA
-)
+
+from ..constantes import (SEQUENCIAL_CARTEIRA, SEQUENCIAL_EMPRESA,
+ SEQUENCIAL_FATURA)
_logger = logging.getLogger(__name__)
class AccountInvoice(models.Model):
- _inherit = 'account.invoice'
+ _inherit = "account.invoice"
- active = fields.Boolean(
- string=u'Ativo',
- default=True,
- )
+ active = fields.Boolean(string=u"Ativo", default=True)
eval_state_cnab = fields.Selection(
- string=u'Estado CNAB',
- related='move_line_receivable_id.state_cnab',
+ string=u"Estado CNAB",
+ related="move_line_receivable_id.state_cnab",
readonly=True,
store=True,
index=True,
)
eval_situacao_pagamento = fields.Selection(
- string=u'Situação do Pagamento',
- related='move_line_receivable_id.situacao_pagamento',
+ string=u"Situação do Pagamento",
+ related="move_line_receivable_id.situacao_pagamento",
readonly=True,
store=True,
index=True,
)
eval_payment_mode_instrucoes = fields.Text(
- string=u'Instruções de Cobrança do Modo de Pagamento',
- related='payment_mode_id.instrucoes',
+ string=u"Instruções de Cobrança do Modo de Pagamento",
+ related="payment_mode_id.instrucoes",
readonly=True,
)
- instrucoes = fields.Text(
- string=u'Instruções de cobrança',
- )
+ instrucoes = fields.Text(string=u"Instruções de cobrança")
bank_api_operation_ids = fields.One2many(
- string='Operações Realizadas',
- comodel_name='bank.api.operation',
- inverse_name='invoice_id',
+ string="Operações Realizadas",
+ comodel_name="bank.api.operation",
+ inverse_name="invoice_id",
readonly=True,
)
@@ -59,48 +54,48 @@ def register_invoice_api(self):
""" Registrar o boleto via sua API"""
raise NotImplementedError
- @api.onchange('payment_mode_id')
+ @api.onchange("payment_mode_id")
def _onchange_payment_mode_id(self):
tax_analytic_tag_id = self.env.ref(
- 'l10n_br_account_payment_cobranca.'
- 'account_analytic_tag_tax')
+ "l10n_br_account_payment_cobranca." "account_analytic_tag_tax"
+ )
- to_remove_invoice_line_ids = \
- self.invoice_line_ids.filtered(
- lambda i: tax_analytic_tag_id in i.analytic_tag_ids)
+ to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
+ lambda i: tax_analytic_tag_id in i.analytic_tag_ids
+ )
self.invoice_line_ids -= to_remove_invoice_line_ids
payment_mode_id = self.payment_mode_id
if payment_mode_id.product_tax_id:
invoice_line_data = {
- 'name': 'Taxa adicional do modo de pagamento escolhido',
- 'partner_id': self.partner_id.id,
- 'account_id': payment_mode_id.tax_account_id.id,
- 'product_id': payment_mode_id.product_tax_id.id,
- 'price_unit': payment_mode_id.product_tax_id.lst_price,
- 'quantity': 1,
- 'analytic_tag_ids': [
- (6, 0, [tax_analytic_tag_id.id])
- ],
+ "name": "Taxa adicional do modo de pagamento escolhido",
+ "partner_id": self.partner_id.id,
+ "account_id": payment_mode_id.tax_account_id.id,
+ "product_id": payment_mode_id.product_tax_id.id,
+ "price_unit": payment_mode_id.product_tax_id.lst_price,
+ "quantity": 1,
+ "analytic_tag_ids": [(6, 0, [tax_analytic_tag_id.id])],
}
- self.update({
- 'invoice_line_ids': [
- (6, 0, self.invoice_line_ids.ids),
- (0, 0, invoice_line_data)
- ],
- })
+ self.update(
+ {
+ "invoice_line_ids": [
+ (6, 0, self.invoice_line_ids.ids),
+ (0, 0, invoice_line_data),
+ ]
+ }
+ )
- @api.onchange('payment_term_id')
+ @api.onchange("payment_term_id")
def _onchange_payment_term(self):
interest_analytic_tag_id = self.env.ref(
- 'l10n_br_account_payment_cobranca.'
- 'account_analytic_tag_interest')
+ "l10n_br_account_payment_cobranca." "account_analytic_tag_interest"
+ )
- to_remove_invoice_line_ids = \
- self.invoice_line_ids.filtered(
- lambda i: interest_analytic_tag_id in i.analytic_tag_ids)
+ to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
+ lambda i: interest_analytic_tag_id in i.analytic_tag_ids
+ )
self.invoice_line_ids -= to_remove_invoice_line_ids
@@ -108,85 +103,91 @@ def _onchange_payment_term(self):
amount_total = self.amount_total
if payment_term_id.has_interest and amount_total > 0:
invoice_line_data = {
- 'name': 'Taxa de juros por parcelamento no cartão',
- 'partner_id': self.partner_id.id,
- 'account_id': payment_term_id.interest_account_id.id,
- 'analytic_tag_ids': [
- (6, 0, [interest_analytic_tag_id.id])
- ],
- 'quantity': 1,
- 'price_unit':
- amount_total * payment_term_id.interest_rate / 100
+ "name": "Taxa de juros por parcelamento no cartão",
+ "partner_id": self.partner_id.id,
+ "account_id": payment_term_id.interest_account_id.id,
+ "analytic_tag_ids": [(6, 0, [interest_analytic_tag_id.id])],
+ "quantity": 1,
+ "price_unit": amount_total * payment_term_id.interest_rate / 100,
}
- self.update({
- 'invoice_line_ids': [
- (6, 0, self.invoice_line_ids.ids),
- (0, 0, invoice_line_data)
- ],
- })
+ self.update(
+ {
+ "invoice_line_ids": [
+ (6, 0, self.invoice_line_ids.ids),
+ (0, 0, invoice_line_data),
+ ]
+ }
+ )
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_id = self.move_line_receivable_id
- payment_order_ids = self.env['account.payment.order'].search([
- ('payment_line_ids.move_line_id', 'in',
- [move_line_receivable_id.id])
- ])
+ payment_order_ids = self.env["account.payment.order"].search(
+ [("payment_line_ids.move_line_id", "in", [move_line_receivable_id.id])]
+ )
if payment_order_ids:
draft_cancel_payment_order_ids = payment_order_ids.filtered(
- lambda p: p.state in ['draft', 'cancel'])
+ lambda p: p.state in ["draft", "cancel"]
+ )
if payment_order_ids - draft_cancel_payment_order_ids:
if _raise:
- raise UserError(_(
- "A fatura não pode ser cancelada pois a mesma já se "
- "encontra exportada por uma ordem de pagamento."
- ))
+ raise UserError(
+ _(
+ "A fatura não pode ser cancelada pois a mesma já se "
+ "encontra exportada por uma ordem de pagamento."
+ )
+ )
for po_id in draft_cancel_payment_order_ids:
- p_line_id = self.env['account.payment.line'].search([
- ('order_id', '=', po_id.id),
- ('move_line_id', '=', move_line_receivable_id.id)
- ])
+ p_line_id = self.env["account.payment.line"].search(
+ [
+ ("order_id", "=", po_id.id),
+ ("move_line_id", "=", move_line_receivable_id.id),
+ ]
+ )
po_id.payment_line_ids -= p_line_id
@api.multi
def action_invoice_cancel(self):
for record in self:
- if record.eval_state_cnab == 'accepted':
- raise UserError(_(
- "A fatura não pode ser cancelada pois já foi aprovada "
- "no Banco."
- ))
- if record.eval_state_cnab == 'done':
- raise UserError(_(
- "Não é possível cancelar uma fatura finalizada."
- ))
- if record.eval_state_cnab == 'exported':
- raise UserError(_(
- "A fatura não pode ser cancelada pois já foi exportada "
- "em uma remessa."
- ))
+ if record.eval_state_cnab == "accepted":
+ raise UserError(
+ _(
+ "A fatura não pode ser cancelada pois já foi aprovada "
+ "no Banco."
+ )
+ )
+ if record.eval_state_cnab == "done":
+ raise UserError(_("Não é possível cancelar uma fatura finalizada."))
+ if record.eval_state_cnab == "exported":
+ raise UserError(
+ _(
+ "A fatura não pode ser cancelada pois já foi exportada "
+ "em uma remessa."
+ )
+ )
record._remove_payment_order_line()
super(AccountInvoice, self).action_invoice_cancel()
- def create_bank_api_operation(self, request, operation_type=False,
- environment=False):
+ def create_bank_api_operation(
+ self, request, operation_type=False, environment=False
+ ):
# 'not request' não é válido para o propósito
if request == False:
return
- operation_model = self.env['bank.api.operation']
+ operation_model = self.env["bank.api.operation"]
if not operation_type:
- operation_type = 'post'
+ operation_type = "post"
data = {
- 'operation_type': operation_type,
- 'invoice_id': self.id,
- 'environment': environment,
+ "operation_type": operation_type,
+ "invoice_id": self.id,
+ "environment": environment,
}
operation_id = operation_model.create(data)
@@ -197,66 +198,75 @@ def create_bank_api_operation(self, request, operation_type=False,
def create_api_account_payment_line(self):
# TODO: Criar CRON para confirmar as account.payment.order no final de
# cada dia
- apoo = self.env['account.payment.order']
+ apoo = self.env["account.payment.order"]
result_payorder_ids = []
payorder = False
for inv in self:
- if inv.state != 'open':
- raise UserError(_(
- "The invoice %s is not in Open state") % inv.number)
+ if inv.state != "open":
+ raise UserError(_("The invoice %s is not in Open state") % inv.number)
if not inv.move_id:
- raise UserError(_(
- "No Journal Entry on invoice %s") % inv.number)
+ raise UserError(_("No Journal Entry on invoice %s") % inv.number)
applicable_lines = inv.move_id.line_ids.filtered(
lambda x: (
- not x.reconciled and x.payment_mode_id.payment_order_ok and
- x.account_id.internal_type in ('receivable', 'payable') and
- not x.payment_line_ids
+ not x.reconciled
+ and x.payment_mode_id.payment_order_ok
+ and x.account_id.internal_type in ("receivable", "payable")
+ and not x.payment_line_ids
)
)
if not applicable_lines:
- raise UserError(_(
- 'No Payment Line created for invoice %s because '
- 'it already exists or because this invoice is '
- 'already paid.') % inv.number)
- payment_modes = applicable_lines.mapped('payment_mode_id')
+ raise UserError(
+ _(
+ "No Payment Line created for invoice %s because "
+ "it already exists or because this invoice is "
+ "already paid."
+ )
+ % inv.number
+ )
+ payment_modes = applicable_lines.mapped("payment_mode_id")
if not payment_modes:
- raise UserError(_(
- "No Payment Mode on invoice %s") % inv.number)
+ raise UserError(_("No Payment Mode on invoice %s") % inv.number)
for payment_mode in payment_modes:
- payorder = apoo.search([
- ('payment_mode_id', '=', payment_mode.id),
- ('state', '=', 'draft'),
- ('active', '=', False),
- ('name', 'ilike', 'api'),
- ], limit=1)
+ payorder = apoo.search(
+ [
+ ("payment_mode_id", "=", payment_mode.id),
+ ("state", "=", "draft"),
+ ("active", "=", False),
+ ("name", "ilike", "api"),
+ ],
+ limit=1,
+ )
new_payorder = False
if not payorder:
- payorder = apoo.create(inv._prepare_new_payment_order(
- payment_mode
- ))
+ payorder = apoo.create(inv._prepare_new_payment_order(payment_mode))
new_payorder = True
- payorder.name += '_api'
+ payorder.name += "_api"
payorder.active = False
result_payorder_ids.append(payorder.id)
count = 0
for line in applicable_lines.filtered(
- lambda x: x.payment_mode_id == payment_mode
+ lambda x: x.payment_mode_id == payment_mode
):
line.create_payment_line_from_move_line(payorder)
count += 1
if new_payorder:
- inv.message_post(_(
- '%d payment lines added to the new draft payment '
- 'order %s which has been automatically created.')
- % (count, payorder.name))
+ inv.message_post(
+ _(
+ "%d payment lines added to the new draft payment "
+ "order %s which has been automatically created."
+ )
+ % (count, payorder.name)
+ )
else:
- inv.message_post(_(
- '%d payment lines added to the existing draft '
- 'payment order %s.')
- % (count, payorder.name))
+ inv.message_post(
+ _(
+ "%d payment lines added to the existing draft "
+ "payment order %s."
+ )
+ % (count, payorder.name)
+ )
return payorder
@api.multi
@@ -274,39 +284,37 @@ def _pos_action_move_create(self):
# inv.transaction_id = sequence
inv._compute_receivables()
for index, interval in enumerate(inv.move_line_receivable_id):
- inv_number = inv.get_invoice_fiscal_number().split(
- '/')[-1].zfill(8)
- numero_documento = (
- inv_number + '/' + str(index + 1).zfill(2)
- )
+ inv_number = inv.get_invoice_fiscal_number().split("/")[-1].zfill(8)
+ numero_documento = inv_number + "/" + str(index + 1).zfill(2)
# Verificar se é boleto para criar o numero
if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
sequence = inv.company_id.get_own_number_sequence()
elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
- sequence = numero_documento.replace('/', '')
+ sequence = numero_documento.replace("/", "")
elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
# TODO: Implementar uma sequencia na carteira de cobranca
raise NotImplementedError
else:
- raise UserError(_(
- u"Favor acessar aba Cobrança da configuração da"
- u" sua empresa para determinar o tipo de "
- u"sequencia utilizada nas cobrancas"
- ))
+ raise UserError(
+ _(
+ u"Favor acessar aba Cobrança da configuração da"
+ u" sua empresa para determinar o tipo de "
+ u"sequencia utilizada nas cobrancas"
+ )
+ )
interval.transaction_ref = sequence
- interval.nosso_numero = sequence if \
- interval.payment_mode_id.gera_nosso_numero else '0'
+ interval.nosso_numero = (
+ sequence if interval.payment_mode_id.gera_nosso_numero else "0"
+ )
interval.numero_documento = numero_documento
- interval.identificacao_titulo_empresa = hex(
- interval.id
- ).upper()
- instrucoes = ''
+ interval.identificacao_titulo_empresa = hex(interval.id).upper()
+ instrucoes = ""
if inv.eval_payment_mode_instrucoes:
- instrucoes = inv.eval_payment_mode_instrucoes + '\n'
+ instrucoes = inv.eval_payment_mode_instrucoes + "\n"
if inv.instrucoes:
- instrucoes += inv.instrucoes + '\n'
+ instrucoes += inv.instrucoes + "\n"
interval.instrucoes = instrucoes
@api.multi
@@ -323,54 +331,63 @@ def create_account_payment_line_baixa(self):
applicable_lines = inv.move_id.line_ids.filtered(
lambda x: (
- x.payment_mode_id.payment_order_ok and
- x.account_id.internal_type in ('receivable', 'payable')
+ x.payment_mode_id.payment_order_ok
+ and x.account_id.internal_type in ("receivable", "payable")
)
)
if not applicable_lines:
- raise UserError(_(
- 'No Payment Line created for invoice %s because '
- 'it\'s internal type isn\'t receivable or payable.') %
- inv.number)
+ raise UserError(
+ _(
+ "No Payment Line created for invoice %s because "
+ "it's internal type isn't receivable or payable."
+ )
+ % inv.number
+ )
- payment_modes = applicable_lines.mapped('payment_mode_id')
+ payment_modes = applicable_lines.mapped("payment_mode_id")
if not payment_modes:
- raise UserError(_(
- "No Payment Mode on invoice %s") % inv.number)
+ raise UserError(_("No Payment Mode on invoice %s") % inv.number)
result_payorder_ids = []
- apoo = self.env['account.payment.order']
+ apoo = self.env["account.payment.order"]
for payment_mode in payment_modes:
- payorder = apoo.search([
- ('payment_mode_id', '=', payment_mode.id),
- ('state', '=', 'draft')
- ], limit=1)
+ payorder = apoo.search(
+ [
+ ("payment_mode_id", "=", payment_mode.id),
+ ("state", "=", "draft"),
+ ],
+ limit=1,
+ )
new_payorder = False
if not payorder:
- payorder = apoo.create(inv._prepare_new_payment_order(
- payment_mode
- ))
+ payorder = apoo.create(inv._prepare_new_payment_order(payment_mode))
new_payorder = True
result_payorder_ids.append(payorder.id)
action_payment_type = payorder.payment_type
count = 0
for line in applicable_lines.filtered(
- lambda x: x.payment_mode_id == payment_mode
+ lambda x: x.payment_mode_id == payment_mode
):
line.create_payment_line_from_move_line(payorder)
count += 1
if new_payorder:
- inv.message_post(_(
- '%d payment lines added to the new draft payment '
- 'order %s which has been automatically created.')
- % (count, payorder.name))
+ inv.message_post(
+ _(
+ "%d payment lines added to the new draft payment "
+ "order %s which has been automatically created."
+ )
+ % (count, payorder.name)
+ )
else:
- inv.message_post(_(
- '%d payment lines added to the existing draft '
- 'payment order %s.')
- % (count, payorder.name))
+ inv.message_post(
+ _(
+ "%d payment lines added to the existing draft "
+ "payment order %s."
+ )
+ % (count, payorder.name)
+ )
@api.multi
def invoice_validate(self):
@@ -384,31 +401,37 @@ def invoice_validate(self):
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
- if self.payment_term_id.payment_mode_selection == 'cartao':
- raise UserError(_(
- "Não é possível adicionar pagamentos em uma fatura "
- "parcelada no cartão de crédito"
- ))
- if self.eval_situacao_pagamento in \
- ['paga', 'liquidada', 'baixa_liquidacao']:
- raise UserError(_(
- "Não é possível adicionar pagamentos em uma fatura que "
- "já está paga."
- ))
- if self.eval_state_cnab in ['accepted', 'exported', 'done']:
- raise UserError(_(
- "Não é possível adicionar pagamentos em uma fatura já "
- "exportada ou aceita no banco."
- ))
- return super(AccountInvoice, self).assign_outstanding_credit(
- credit_aml_id)
+ if self.payment_term_id.payment_mode_selection == "cartao":
+ raise UserError(
+ _(
+ "Não é possível adicionar pagamentos em uma fatura "
+ "parcelada no cartão de crédito"
+ )
+ )
+ if self.eval_situacao_pagamento in ["paga", "liquidada", "baixa_liquidacao"]:
+ raise UserError(
+ _(
+ "Não é possível adicionar pagamentos em uma fatura que "
+ "já está paga."
+ )
+ )
+ if self.eval_state_cnab in ["accepted", "exported", "done"]:
+ raise UserError(
+ _(
+ "Não é possível adicionar pagamentos em uma fatura já "
+ "exportada ou aceita no banco."
+ )
+ )
+ return super(AccountInvoice, self).assign_outstanding_credit(credit_aml_id)
@api.multi
- def register_payment(self, payment_line, writeoff_acc_id=False,
- writeoff_journal_id=False):
+ def register_payment(
+ self, payment_line, writeoff_acc_id=False, writeoff_journal_id=False
+ ):
res = super(AccountInvoice, self).register_payment(
- payment_line, writeoff_acc_id, writeoff_journal_id)
+ payment_line, writeoff_acc_id, writeoff_journal_id
+ )
self._pos_action_move_create()
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
index 8e0f10d81227..7a54a3adb272 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import logging
from odoo import api, fields, models
@@ -18,44 +16,48 @@ class AccountInvoiceAPIConfirm(models.TransientModel):
_description = "Registrar as faturas selecionadas via API"
environment = fields.Char(
- string='Ambiente',
- default=lambda self: self._default_environment(),
+ string="Ambiente", default=lambda self: self._default_environment()
)
invoice_ids = fields.Many2many(
- comodel_name='account.invoice',
- string='Faturas',
+ comodel_name="account.invoice",
+ string="Faturas",
default=lambda self: self._default_invoice_ids(),
)
@api.model
def _default_invoice_ids(self):
- active_ids = self.env['account.invoice'].browse(
- self._context.get('active_ids'))
+ active_ids = self.env["account.invoice"].browse(self._context.get("active_ids"))
valid_ids = active_ids.filtered(
- lambda a: a.state == 'open' and a.eval_state_cnab not in [
- 'added_paid', 'accepted', 'done', 'accepted_hml']).ids
+ lambda a: a.state == "open"
+ and a.eval_state_cnab
+ not in ["added_paid", "accepted", "done", "accepted_hml"]
+ ).ids
return valid_ids
@api.model
def _default_environment(self):
# TODO: Multi-company approach
- active_ids = self.env['account.invoice'].browse(
- self._context.get('active_ids'))
+ active_ids = self.env["account.invoice"].browse(self._context.get("active_ids"))
environment = active_ids[:1].partner_id.company_id.environment
if not environment:
- message = "Nenhum ambiente está configurado no cadastro da " \
- "empresa. Favor escolher entre Produção e Homologação."
+ message = (
+ "Nenhum ambiente está configurado no cadastro da "
+ "empresa. Favor escolher entre Produção e Homologação."
+ )
_logger.error(message)
raise UserError(message)
try:
- environment_text = self.env['res.company']._fields.get(
- 'environment').selection[int(environment) - 1][-1]
+ environment_text = (
+ self.env["res.company"]
+ ._fields.get("environment")
+ .selection[int(environment) - 1][-1]
+ )
except Exception as e:
- message = 'Erro ao obter ambiente. %s' % str(e)
+ message = "Erro ao obter ambiente. %s" % str(e)
_logger.error(message)
raise UserError(message)
@@ -70,15 +72,20 @@ def api_register_confirm(self):
for invoice_id in record.invoice_ids:
try:
invoice_id.obtain_token(
- self.env.user.company_id.sudo(), environment)
+ self.env.user.company_id.sudo(), environment
+ )
invoice_id.with_delay().register_invoice_api()
except Exception as e:
- _logger.debug('Erro ao processar fatura %s. %s' % (
- invoice_id.number, str(e)))
+ _logger.debug(
+ "Erro ao processar fatura %s. %s"
+ % (invoice_id.number, str(e))
+ )
else:
for invoice_id in record.invoice_ids:
try:
invoice_id.register_invoice_api()
except Exception as e:
- _logger.debug('Erro ao processar fatura %s. %s' % (
- invoice_id.number, str(e)))
\ No newline at end of file
+ _logger.debug(
+ "Erro ao processar fatura %s. %s"
+ % (invoice_id.number, str(e))
+ )
diff --git a/l10n_br_account_payment_cobranca/models/account_move.py b/l10n_br_account_payment_cobranca/models/account_move.py
index 097faa762531..bdf4cb727dad 100644
--- a/l10n_br_account_payment_cobranca/models/account_move.py
+++ b/l10n_br_account_payment_cobranca/models/account_move.py
@@ -1,11 +1,9 @@
-# -*- coding: utf-8 -*-
# © 2019 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+from odoo import _, api, models
from odoo.exceptions import ValidationError
-from odoo import models, api, _
-
class AccountMove(models.Model):
_inherit = "account.move"
@@ -13,13 +11,17 @@ class AccountMove(models.Model):
@api.multi
def unlink(self):
for record in self:
- payment_line_ids = record.line_ids.mapped('payment_line_ids')
- if any(state not in ['draft', 'cancel'] for
- state in payment_line_ids.mapped('state')):
- raise ValidationError(_(
- "Não foi possível cancelar a fatura, pois existem linhas "
- "de pagamentos ativas vinculadas ao lançamento de diário"
- "dela."
- ))
+ payment_line_ids = record.line_ids.mapped("payment_line_ids")
+ if any(
+ state not in ["draft", "cancel"]
+ for state in payment_line_ids.mapped("state")
+ ):
+ raise ValidationError(
+ _(
+ "Não foi possível cancelar a fatura, pois existem linhas "
+ "de pagamentos ativas vinculadas ao lançamento de diário"
+ "dela."
+ )
+ )
payment_line_ids.unlink()
return super(AccountMove, self).unlink()
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 38d6427ea73b..f4fc6a028fe3 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -1,81 +1,63 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import models, fields, api, _
+
+from odoo import _, api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
ESTADOS_CNAB = [
- ('draft', u'Inicial'),
- ('added', u'Adicionada à ordem de pagamento'),
- ('added_paid', u'Adicionada para Baixa'),
- ('exported', u'Exportada'),
- ('exporting_error', u'Erro ao exportar'),
- ('accepted', u'Aceita'),
- ('accepted_hml', u'Aceita em Homologação'),
- ('not_accepted', u'Não aceita pelo banco'),
- ('done', u'Concluído'),
+ ("draft", u"Inicial"),
+ ("added", u"Adicionada à ordem de pagamento"),
+ ("added_paid", u"Adicionada para Baixa"),
+ ("exported", u"Exportada"),
+ ("exporting_error", u"Erro ao exportar"),
+ ("accepted", u"Aceita"),
+ ("accepted_hml", u"Aceita em Homologação"),
+ ("not_accepted", u"Não aceita pelo banco"),
+ ("done", u"Concluído"),
]
SITUACAO_PAGAMENTO = [
- ('inicial', 'Inicial'),
- ('aberta', 'Aberta'),
- ('paga', 'Paga'),
- ('liquidada', 'Liquidada'),
- ('baixa', 'Baixa Simples'),
- ('baixa_liquidacao', 'Baixa por Liquidação em Dinheiro'),
+ ("inicial", "Inicial"),
+ ("aberta", "Aberta"),
+ ("paga", "Paga"),
+ ("liquidada", "Liquidada"),
+ ("baixa", "Baixa Simples"),
+ ("baixa_liquidacao", "Baixa por Liquidação em Dinheiro"),
]
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
- state_cnab = fields.Selection(
- ESTADOS_CNAB, u'Estados CNAB', default='draft')
- date_payment_created = fields.Date(
- u'Data da criação do pagamento', readonly=True)
- nosso_numero = fields.Char(
- string=u'Nosso Numero',
- )
- numero_documento = fields.Char(
- string=u'Número documento'
- )
- identificacao_titulo_empresa = fields.Char(
- string=u'Identificação Titulo Empresa',
- )
+ state_cnab = fields.Selection(ESTADOS_CNAB, u"Estados CNAB", default="draft")
+ date_payment_created = fields.Date(u"Data da criação do pagamento", readonly=True)
+ nosso_numero = fields.Char(string=u"Nosso Numero")
+ numero_documento = fields.Char(string=u"Número documento")
+ identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
situacao_pagamento = fields.Selection(
- selection=SITUACAO_PAGAMENTO,
- string=u'Situação do Pagamento',
- default='inicial'
- )
- instrucoes = fields.Text(
- string=u'Instruções de cobrança',
- readonly=True,
+ selection=SITUACAO_PAGAMENTO, string=u"Situação do Pagamento", default="inicial"
)
+ instrucoes = fields.Text(string=u"Instruções de cobrança", readonly=True)
residual = fields.Monetary(
- string=u'Valor Residual',
- default=0.0,
- currency_field='company_currency_id'
+ string=u"Valor Residual", default=0.0, currency_field="company_currency_id"
)
@api.multi
def _prepare_payment_line_vals(self, payment_order):
- vals = super(AccountMoveLine, self)._prepare_payment_line_vals(
- payment_order
- )
- vals['nosso_numero'] = self.nosso_numero
- vals['numero_documento'] = self.numero_documento
- vals['identificacao_titulo_empresa'] = \
- self.identificacao_titulo_empresa
+ vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
+ vals["nosso_numero"] = self.nosso_numero
+ vals["numero_documento"] = self.numero_documento
+ vals["identificacao_titulo_empresa"] = self.identificacao_titulo_empresa
- if self.invoice_id.state == 'paid':
- vals['amount_currency'] = self.credit or self.debit
+ if self.invoice_id.state == "paid":
+ vals["amount_currency"] = self.credit or self.debit
return vals
@@ -86,9 +68,9 @@ def create_payment_line_from_move_line(self, payment_order):
:param payment_order:
:return:
"""
- state_cnab = 'added'
- if self.invoice_id.state == 'paid':
- state_cnab = 'added_paid'
+ state_cnab = "added"
+ if self.invoice_id.state == "paid":
+ state_cnab = "added_paid"
self.state_cnab = state_cnab
@@ -116,14 +98,18 @@ def write(self, vals):
:param vals:
:return:
"""
- state_cnab = vals.get('state_cnab')
-
- if state_cnab and (self.state_cnab == 'done' or (
- self.state_cnab in ['accepted', 'accepted_hml'] and
- state_cnab not in ['accepted', 'accepted_hml', 'done'])):
- vals.pop('state_cnab', False)
-
- if self.situacao_pagamento not in ['inicial', 'aberta']:
- vals.pop('situacao_pagamento', False)
+ state_cnab = vals.get("state_cnab")
+
+ if state_cnab and (
+ self.state_cnab == "done"
+ or (
+ self.state_cnab in ["accepted", "accepted_hml"]
+ and state_cnab not in ["accepted", "accepted_hml", "done"]
+ )
+ ):
+ vals.pop("state_cnab", False)
+
+ if self.situacao_pagamento not in ["inicial", "aberta"]:
+ vals.pop("situacao_pagamento", False)
return super(AccountMoveLine, self).write(vals)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment.py b/l10n_br_account_payment_cobranca/models/account_payment.py
index bef93bfccffd..f3f36ad4535b 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Daniel Sadamo Hirayama
# @author Hugo Uchôas Borges
@@ -8,7 +7,7 @@
class AccountPayment(models.Model):
- _inherit = 'account.payment'
+ _inherit = "account.payment"
@api.multi
def post(self):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index c6eea459b04c..3377a7f620ed 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -1,90 +1,79 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, fields, api
-from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \
- AVISO_FAVORECIDO
+from odoo import api, fields, models
+
+from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO)
class PaymentLine(models.Model):
- _inherit = 'account.payment.line'
+ _inherit = "account.payment.line"
@api.model
def default_get(self, fields_list):
res = super(PaymentLine, self).default_get(fields_list)
- mode = self.env['account.payment.order'].browse(
- self.env.context.get('order_id')).payment_mode_id
+ mode = (
+ self.env["account.payment.order"]
+ .browse(self.env.context.get("order_id"))
+ .payment_mode_id
+ )
if mode.codigo_finalidade_doc:
- res.update({
- 'codigo_finalidade_doc': mode.codigo_finalidade_doc})
+ res.update({"codigo_finalidade_doc": mode.codigo_finalidade_doc})
if mode.codigo_finalidade_ted:
- res.update({
- 'codigo_finalidade_ted': mode.codigo_finalidade_ted
- })
+ res.update({"codigo_finalidade_ted": mode.codigo_finalidade_ted})
if mode.codigo_finalidade_complementar:
- res.update({
- 'codigo_finalidade_complementar':
- mode.codigo_finalidade_complementar
- })
+ res.update(
+ {"codigo_finalidade_complementar": mode.codigo_finalidade_complementar}
+ )
if mode.aviso_ao_favorecido:
- res.update({
- 'aviso_ao_favorecido': mode.aviso_ao_favorecido
- })
+ res.update({"aviso_ao_favorecido": mode.aviso_ao_favorecido})
return res
- nosso_numero = fields.Char(
- string=u'Nosso Numero',
- )
- numero_documento = fields.Char(
- string=u'Número documento'
- )
- identificacao_titulo_empresa = fields.Char(
- string=u'Identificação Titulo Empresa',
- )
+ nosso_numero = fields.Char(string=u"Nosso Numero")
+ numero_documento = fields.Char(string=u"Número documento")
+ identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u'Complemento do Tipo de Serviço',
- help=u'Campo P005 do CNAB',
+ string=u"Complemento do Tipo de Serviço",
+ help=u"Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u'Código Finalidade da TED',
- help=u'Campo P011 do CNAB',
+ string=u"Código Finalidade da TED",
+ help=u"Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2,
- string=u'Código de finalidade complementar',
- help=u'Campo P013 do CNAB',
+ size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u'Aviso ao Favorecido',
- help=u'Campo P006 do CNAB',
- default='0',
+ string=u"Aviso ao Favorecido",
+ help=u"Campo P006 do CNAB",
+ default="0",
)
abatimento = fields.Float(
digits=(13, 2),
- string=u'Valor do Abatimento',
- help=u'Campo G045 do CNAB',
- default=0.00
+ string=u"Valor do Abatimento",
+ help=u"Campo G045 do CNAB",
+ default=0.00,
)
desconto = fields.Float(
digits=(13, 2),
- string=u'Valor do Desconto',
- help=u'Campo G046 do CNAB',
- default=0.00
+ string=u"Valor do Desconto",
+ help=u"Campo G046 do CNAB",
+ default=0.00,
)
mora = fields.Float(
digits=(13, 2),
- string=u'Valor da Mora',
- help=u'Campo G047 do CNAB',
- default=0.00
+ string=u"Valor da Mora",
+ help=u"Campo G047 do CNAB",
+ default=0.00,
)
multa = fields.Float(
digits=(13, 2),
- string=u'Valor da Multa',
- help=u'Campo G048 do CNAB',
- default=0.00
+ string=u"Valor da Multa",
+ help=u"Campo G048 do CNAB",
+ default=0.00,
)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 48ab8f0c2d08..ead569c1dbe6 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -1,89 +1,92 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
-from odoo.exceptions import ValidationError
from odoo.addons import decimal_precision as dp
-from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
- COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, AVISO_FAVORECIDO
+from odoo.exceptions import ValidationError
+
+from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO, FORMA_LANCAMENTO,
+ TIPO_SERVICO)
class PaymentMode(models.Model):
_inherit = "account.payment.mode"
condicao_emissao_papeleta = fields.Selection(
- [('1', 'Banco emite e Processa'),
- ('2', 'Cliente emite e banco processa'), ],
- u'Condição Emissão de Papeleta', default='1')
- cnab_percent_interest = fields.Float(string=u"Percentual de Juros",
- digits=dp.get_precision('Account'))
+ [("1", "Banco emite e Processa"), ("2", "Cliente emite e banco processa")],
+ u"Condição Emissão de Papeleta",
+ default="1",
+ )
+ cnab_percent_interest = fields.Float(
+ string=u"Percentual de Juros", digits=dp.get_precision("Account")
+ )
comunicacao_2 = fields.Char("Comunicação para o sacador avalista")
tipo_servico = fields.Selection(
- selection=TIPO_SERVICO,
- string=u'Tipo de Serviço',
- help=u'Campo G025 do CNAB'
+ selection=TIPO_SERVICO, string=u"Tipo de Serviço", help=u"Campo G025 do CNAB"
)
forma_lancamento = fields.Selection(
selection=FORMA_LANCAMENTO,
- string=u'Forma Lançamento',
- help=u'Campo G029 do CNAB'
+ string=u"Forma Lançamento",
+ help=u"Campo G029 do CNAB",
)
codigo_convenio = fields.Char(
size=20,
- string=u'Código do Convênio no Banco',
- help=u'Campo G007 do CNAB',
- default=u'0001222130126',
+ string=u"Código do Convênio no Banco",
+ help=u"Campo G007 do CNAB",
+ default=u"0001222130126",
)
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u'Complemento do Tipo de Serviço',
- help=u'Campo P005 do CNAB'
+ string=u"Complemento do Tipo de Serviço",
+ help=u"Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u'Código Finalidade da TED',
- help=u'Campo P011 do CNAB'
+ string=u"Código Finalidade da TED",
+ help=u"Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2,
- string=u'Código de finalidade complementar',
- help=u'Campo P013 do CNAB',
+ size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u'Aviso ao Favorecido',
- help=u'Campo P006 do CNAB',
+ string=u"Aviso ao Favorecido",
+ help=u"Campo P006 do CNAB",
default=0,
)
# A exportação CNAB não se encaixa somente nos parâmetros de
# débito e crédito.
- boleto_carteira = fields.Char('Carteira', size=3)
- boleto_modalidade = fields.Char('Modalidade', size=2)
- boleto_convenio = fields.Char(u'Codigo convênio', size=10)
- boleto_variacao = fields.Char(u'Variação', size=2)
- boleto_cnab_code = fields.Char(u'Código Cnab', size=20)
+ boleto_carteira = fields.Char("Carteira", size=3)
+ boleto_modalidade = fields.Char("Modalidade", size=2)
+ boleto_convenio = fields.Char(u"Codigo convênio", size=10)
+ boleto_variacao = fields.Char(u"Variação", size=2)
+ boleto_cnab_code = fields.Char(u"Código Cnab", size=20)
boleto_aceite = fields.Selection(
- [('S', 'Sim'), ('N', 'Não')], string='Aceite', default='N')
- boleto_type = fields.Selection(
- selection=[], string="Boleto")
- boleto_especie = fields.Selection([
- ('01', u'DUPLICATA MERCANTIL'),
- ('02', u'NOTA PROMISSÓRIA'),
- ('03', u'NOTA DE SEGURO'),
- ('04', u'MENSALIDADE ESCOLAR'),
- ('05', u'RECIBO'),
- ('06', u'CONTRATO'),
- ('07', u'COSSEGUROS'),
- ('08', u'DUPLICATA DE SERVIÇO'),
- ('09', u'LETRA DE CÂMBIO'),
- ('13', u'NOTA DE DÉBITOS'),
- ('15', u'DOCUMENTO DE DÍVIDA'),
- ('16', u'ENCARGOS CONDOMINIAIS'),
- ('17', u'CONTA DE PRESTAÇÃO DE SERVIÇOS'),
- ('99', u'DIVERSOS'),
- ], string=u'Espécie do Título', default='01')
+ [("S", "Sim"), ("N", "Não")], string="Aceite", default="N"
+ )
+ boleto_type = fields.Selection(selection=[], string="Boleto")
+ boleto_especie = fields.Selection(
+ [
+ ("01", u"DUPLICATA MERCANTIL"),
+ ("02", u"NOTA PROMISSÓRIA"),
+ ("03", u"NOTA DE SEGURO"),
+ ("04", u"MENSALIDADE ESCOLAR"),
+ ("05", u"RECIBO"),
+ ("06", u"CONTRATO"),
+ ("07", u"COSSEGUROS"),
+ ("08", u"DUPLICATA DE SERVIÇO"),
+ ("09", u"LETRA DE CÂMBIO"),
+ ("13", u"NOTA DE DÉBITOS"),
+ ("15", u"DOCUMENTO DE DÍVIDA"),
+ ("16", u"ENCARGOS CONDOMINIAIS"),
+ ("17", u"CONTA DE PRESTAÇÃO DE SERVIÇOS"),
+ ("99", u"DIVERSOS"),
+ ],
+ string=u"Espécie do Título",
+ default="01",
+ )
boleto_protesto = fields.Char(
# [ Deixado manualmente, pois cada banco parece ter sua tabela.
# ('0', u'Sem instrução'),
@@ -93,48 +96,53 @@ class PaymentMode(models.Model):
# ('7', u'Negativar (Dias Corridos)'),
# ('8', u'Não Negativar')
# ]
- string=u'Códigos de Protesto', default='0')
- boleto_protesto_prazo = fields.Char(u'Prazo protesto', size=2)
+ string=u"Códigos de Protesto",
+ default="0",
+ )
+ boleto_protesto_prazo = fields.Char(u"Prazo protesto", size=2)
gera_nosso_numero = fields.Boolean(
- string=u'Gerar nosso número?',
- help=u'Dependendo da carteira, banco, etc. '
- u'O nosso número pode ser gerado pelo banco.',
- default=True
+ string=u"Gerar nosso número?",
+ help=u"Dependendo da carteira, banco, etc. "
+ u"O nosso número pode ser gerado pelo banco.",
+ default=True,
)
default_account_id = fields.Many2one(
- comodel_name='account.account',
- string=u'Conta Padrão',
- help=u'Conta padrão para recebimentos'
+ comodel_name="account.account",
+ string=u"Conta Padrão",
+ help=u"Conta padrão para recebimentos",
)
default_tax_account_id = fields.Many2one(
- comodel_name='account.account',
- string=u'Conta Padrão para Taxas Bancárias',
- help=u'Conta padrão para recebimentos de Taxas Bancárias'
+ comodel_name="account.account",
+ string=u"Conta Padrão para Taxas Bancárias",
+ help=u"Conta padrão para recebimentos de Taxas Bancárias",
)
product_tax_id = fields.Many2one(
- comodel_name='product.product',
- string='Taxa Adicional',
+ comodel_name="product.product", string="Taxa Adicional"
)
tax_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão',
- help='Conta padrão para Taxa',
+ comodel_name="account.account",
+ string="Conta Padrão",
+ help="Conta padrão para Taxa",
)
- @api.onchange('product_tax_id')
+ @api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
if not self.product_tax_id:
self.tax_account_id = False
- @api.constrains('product_override')
+ @api.constrains("product_override")
def _constrains_product_override(self):
if self.product_override and self.product_override_value <= 0:
- raise ValidationError(
- u'O valor da Taxa deve ser maior que 0 (zero)')
+ raise ValidationError(u"O valor da Taxa deve ser maior que 0 (zero)")
- @api.constrains('boleto_type', 'boleto_carteira',
- 'boleto_modalidade', 'boleto_convenio',
- 'boleto_variacao', 'boleto_aceite')
+ @api.constrains(
+ "boleto_type",
+ "boleto_carteira",
+ "boleto_modalidade",
+ "boleto_convenio",
+ "boleto_variacao",
+ "boleto_aceite",
+ )
def boleto_restriction(self):
- if self.boleto_type == '6' and not self.boleto_carteira:
- raise ValidationError(u'Carteira no banco Itaú é obrigatória')
+ if self.boleto_type == "6" and not self.boleto_carteira:
+ raise ValidationError(u"Carteira no banco Itaú é obrigatória")
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 662f8054b99e..af828f7f8764 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Fernando Marcato
# @author Hendrix Costa
@@ -6,75 +5,67 @@
from __future__ import division, print_function, unicode_literals
-from odoo import api, models, fields
-from ..constantes import TIPO_SERVICO, FORMA_LANCAMENTO, \
- INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO, CODIGO_INSTRUCAO_MOVIMENTO
-
import logging
+from odoo import api, fields, models
+
+from ..constantes import (CODIGO_INSTRUCAO_MOVIMENTO, FORMA_LANCAMENTO,
+ INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO,
+ TIPO_SERVICO)
+
_logger = logging.getLogger(__name__)
class PaymentOrder(models.Model):
- _inherit = b'account.payment.order'
+ _inherit = b"account.payment.order"
- active = fields.Boolean(
- string=u'Ativo',
- default=True,
- )
+ active = fields.Boolean(string="Ativo", default=True)
- file_number = fields.Integer(
- string=u'Número sequencial do arquivo',
- )
+ file_number = fields.Integer(string="Número sequencial do arquivo")
- cnab_file = fields.Binary(
- string='CNAB File',
- readonly=True,
- )
+ cnab_file = fields.Binary(string="CNAB File", readonly=True)
cnab_filename = fields.Char("CNAB Filename")
tipo_servico = fields.Selection(
selection=TIPO_SERVICO,
- string=u'Tipo de Serviço',
- help=u'Campo G025 do CNAB',
- default='30',
+ string="Tipo de Serviço",
+ help="Campo G025 do CNAB",
+ default="30",
)
forma_lancamento = fields.Selection(
- selection=FORMA_LANCAMENTO,
- string=u'Forma Lançamento',
- help=u'Campo G029 do CNAB'
+ selection=FORMA_LANCAMENTO, string="Forma Lançamento", help="Campo G029 do CNAB"
)
codigo_convenio = fields.Char(
size=20,
- string=u'Código do Convênio no Banco',
- help=u'Campo G007 do CNAB',
- default=u'0001222130126',
+ string="Código do Convênio no Banco",
+ help="Campo G007 do CNAB",
+ default="0001222130126",
)
indicativo_forma_pagamento = fields.Selection(
selection=INDICATIVO_FORMA_PAGAMENTO,
- string=u'Indicativo de Forma de Pagamento',
- help='Campo P014 do CNAB',
- default='01'
+ string="Indicativo de Forma de Pagamento",
+ help="Campo P014 do CNAB",
+ default="01",
)
tipo_movimento = fields.Selection(
selection=TIPO_MOVIMENTO,
- string='Tipo de Movimento',
- help='Campo G060 do CNAB',
- default='0',
+ string="Tipo de Movimento",
+ help="Campo G060 do CNAB",
+ default="0",
)
codigo_instrucao_movimento = fields.Selection(
selection=CODIGO_INSTRUCAO_MOVIMENTO,
- string='Código da Instrução para Movimento',
- help='Campo G061 do CNAB',
- default='0',
+ string="Código da Instrução para Movimento",
+ help="Campo G061 do CNAB",
+ default="0",
)
bank_line_error_ids = fields.One2many(
- comodel_name='bank.payment.line',
- inverse_name='order_id',
+ comodel_name="bank.payment.line",
+ inverse_name="order_id",
string="Bank Payment Error Lines",
readonly=True,
- domain=[('is_erro_exportacao', '=', True)],
+ domain=[("is_erro_exportacao", "=", True)],
)
def _confirm_debit_orders_api(self):
@@ -84,11 +75,9 @@ def _confirm_debit_orders_api(self):
"""
_logger.info("_confirm_debit_orders_api()")
- order_ids = self.search([
- ('active', '=', False),
- ('state', '=', 'draft'),
- ('name', 'ilike', 'api')
- ])
+ order_ids = self.search(
+ [("active", "=", False), ("state", "=", "draft"), ("name", "ilike", "api")]
+ )
for order_id in order_ids:
try:
@@ -100,11 +89,10 @@ def _confirm_debit_orders_api(self):
@api.model
def _prepare_bank_payment_line(self, paylines):
result = super(PaymentOrder, self)._prepare_bank_payment_line(paylines)
- result['nosso_numero'] = paylines.nosso_numero
- result['numero_documento'] = paylines.numero_documento
- result['identificacao_titulo_empresa'] = \
- paylines.identificacao_titulo_empresa
- result['ultimo_estado_cnab'] = paylines.move_line_id.state_cnab
+ result["nosso_numero"] = paylines.nosso_numero
+ result["numero_documento"] = paylines.numero_documento
+ result["identificacao_titulo_empresa"] = paylines.identificacao_titulo_empresa
+ result["ultimo_estado_cnab"] = paylines.move_line_id.state_cnab
return result
@api.multi
@@ -113,8 +101,8 @@ def open2generated(self):
if self.bank_line_error_ids:
self.message_post(
- 'Erro ao gerar o arquivo,'
- ' verifique a aba "Linhas com problemas"')
+ "Erro ao gerar o arquivo," ' verifique a aba "Linhas com problemas"'
+ )
return False
- self.message_post('Arquivo gerado com sucesso')
- return result
\ No newline at end of file
+ self.message_post("Arquivo gerado com sucesso")
+ return result
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_term.py b/l10n_br_account_payment_cobranca/models/account_payment_term.py
index 352c26abf803..791879450acd 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_term.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_term.py
@@ -1,51 +1,41 @@
-# -*- coding: utf-8 -*-
# © 2019 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import openerp.addons.decimal_precision as dp
-
-from odoo import models, fields, api
+from odoo import api, fields, models
PAYMENT_SELECTION = [
- ('boleto', 'Boleto'),
- ('cartao', 'Cartão'),
- ('cheque', 'Cheque'),
- ('dinheiro', 'Dinheiro'),
- ('outros', 'Outros'),
+ ("boleto", "Boleto"),
+ ("cartao", "Cartão"),
+ ("cheque", "Cheque"),
+ ("dinheiro", "Dinheiro"),
+ ("outros", "Outros"),
]
class AccountPaymentTerm(models.Model):
- _inherit = 'account.payment.term'
+ _inherit = "account.payment.term"
payment_mode_selection = fields.Selection(
- selection=PAYMENT_SELECTION,
- string='Modo de Pagamento'
+ selection=PAYMENT_SELECTION, string="Modo de Pagamento"
)
- has_interest = fields.Boolean(
- string='Juros?',
- default=False,
- )
+ has_interest = fields.Boolean(string="Juros?", default=False)
interest_rate = fields.Float(
- string='Taxa de Juros(%)',
- digits=dp.get_precision('Account'),
- default=0.0,
+ string="Taxa de Juros(%)", digits=dp.get_precision("Account"), default=0.0
)
interest_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta',
- help='Conta padrão para Juros',
+ comodel_name="account.account", string="Conta", help="Conta padrão para Juros"
)
- @api.onchange('payment_mode_selection')
+ @api.onchange("payment_mode_selection")
def _onchange_payment_mode(self):
- if self.payment_mode_selection not in ['cartao']:
+ if self.payment_mode_selection not in ["cartao"]:
self.has_interest = False
- @api.onchange('has_interest')
+ @api.onchange("has_interest")
def _onchange_has_interest(self):
if not self.has_interest:
self.interest_rate = 0
diff --git a/l10n_br_account_payment_cobranca/models/bank_api_operation.py b/l10n_br_account_payment_cobranca/models/bank_api_operation.py
index dfa6ebe1a60a..d3c5e5620c95 100644
--- a/l10n_br_account_payment_cobranca/models/bank_api_operation.py
+++ b/l10n_br_account_payment_cobranca/models/bank_api_operation.py
@@ -1,113 +1,85 @@
-# -*- coding: utf-8 -*-
-
import json
from odoo import api, fields, models
SELECTION_OPERATION_TYPE = [
- ('post', 'Post'),
- ('token_request', 'Requisição de Token'),
- ('invoice_register', 'Registro de Fatura'),
- ('invoice_query', 'Consulta de Fatura'),
- ('invoice_update', 'Atualização de Fatura'),
- ('invoice_cancellation', 'Baixa de Fatura'),
+ ("post", "Post"),
+ ("token_request", "Requisição de Token"),
+ ("invoice_register", "Registro de Fatura"),
+ ("invoice_query", "Consulta de Fatura"),
+ ("invoice_update", "Atualização de Fatura"),
+ ("invoice_cancellation", "Baixa de Fatura"),
]
class BankAPIOperation(models.Model):
- _name = 'bank.api.operation'
- _rec_name = 'name'
+ _name = "bank.api.operation"
+ _rec_name = "name"
name = fields.Char(
- string='Nome',
- compute='_compute_name',
- readonly=True,
- store=True,
+ string="Nome", compute="_compute_name", readonly=True, store=True
)
environment = fields.Selection(
- string='Ambiente',
- selection=[
- ('1', 'Homologação'),
- ('2', 'Produção'),
- ],
+ string="Ambiente",
+ selection=[("1", "Homologação"), ("2", "Produção")],
readonly=True,
required=True,
)
@api.multi
- @api.depends('operation_datetime', 'operation_type')
+ @api.depends("operation_datetime", "operation_type")
def _compute_name(self):
for record in self:
name = record.operation_datetime
if record.operation_type:
- name += ' - ' + dict(
- self._fields['operation_type'].selection).get(
- record.operation_type)
+ name += " - " + dict(self._fields["operation_type"].selection).get(
+ record.operation_type
+ )
record.name = name
invoice_id = fields.Many2one(
- comodel_name='account.invoice',
- string='Fatura',
- readonly=True,
+ comodel_name="account.invoice", string="Fatura", readonly=True
)
operation_datetime = fields.Datetime(
- string='Data da Operação',
- default=fields.Datetime.now,
- readonly=True,
+ string="Data da Operação", default=fields.Datetime.now, readonly=True
)
user_id = fields.Many2one(
- comodel_name='res.users',
- string='Usuário',
+ comodel_name="res.users",
+ string="Usuário",
default=lambda self: self.env.uid,
readonly=True,
)
operation_type = fields.Selection(
- string='Tipo da Operação',
+ string="Tipo da Operação",
selection=SELECTION_OPERATION_TYPE,
required=True,
readonly=True,
)
- message_sent = fields.Text(
- string="Mensagem Enviada",
- readonly=True,
- )
+ message_sent = fields.Text(string="Mensagem Enviada", readonly=True)
- message_received = fields.Text(
- string="Mensagem Recebida",
- readonly=True,
- )
+ message_received = fields.Text(string="Mensagem Recebida", readonly=True)
- status = fields.Char(
- string="Estado",
- readonly=True,
- )
+ status = fields.Char(string="Estado", readonly=True)
- endpoint = fields.Char(
- string="Endpoint",
- readonly=True,
- )
+ endpoint = fields.Char(string="Endpoint", readonly=True)
operation_error_line_ids = fields.One2many(
- string='Linhas de Erro',
- comodel_name='bank.api.operation.error.line',
- inverse_name='operation_id',
+ string="Linhas de Erro",
+ comodel_name="bank.api.operation.error.line",
+ inverse_name="operation_id",
readonly=True,
)
- error_400 = fields.Boolean(
- string='Erro 400',
- default=False,
- readonly=True,
- )
+ error_400 = fields.Boolean(string="Erro 400", default=False, readonly=True)
def register_post(self, request):
self.endpoint = request.request.url
- self.status = '[%s] - %s' % (request.status_code, request.reason)
+ self.status = "[{}] - {}".format(request.status_code, request.reason)
self.message_sent = request.request.body
self.message_received = request.content
@@ -115,42 +87,33 @@ def register_post(self, request):
if request.status_code == 400:
self.error_400 = True
content_json = json.loads(request.content)
- operation_line_model = self.env['bank.api.operation.error.line']
- for campo in content_json.get('campos'):
+ operation_line_model = self.env["bank.api.operation.error.line"]
+ for campo in content_json.get("campos"):
data = {
- 'operation_id': self.id,
- 'field_name': campo.get('campo'),
- 'field_value': '%s (%s)' % (
- campo.get('valor'), type(campo.get('valor')).__name__),
- 'error_message': campo.get('mensagem'),
+ "operation_id": self.id,
+ "field_name": campo.get("campo"),
+ "field_value": "%s (%s)"
+ % (campo.get("valor"), type(campo.get("valor")).__name__),
+ "error_message": campo.get("mensagem"),
}
operation_line = operation_line_model.create(data)
self.operation_error_line_ids += operation_line
class BankAPIOperationErrorLine(models.Model):
- _name = 'bank.api.operation.error.line'
- _rec_name = 'field_name'
+ _name = "bank.api.operation.error.line"
+ _rec_name = "field_name"
operation_id = fields.Many2one(
- string='Operação Bancária',
- comodel_name='bank.api.operation',
+ string="Operação Bancária",
+ comodel_name="bank.api.operation",
required=True,
readonly=True,
)
- field_name = fields.Char(
- string='Nome do Campo',
- readonly=True,
- )
+ field_name = fields.Char(string="Nome do Campo", readonly=True)
- field_value = fields.Char(
- string='Valor do Campo',
- readonly=True,
- )
+ field_value = fields.Char(string="Valor do Campo", readonly=True)
- error_message = fields.Char(
- string='Mensagem de Erro',
- readonly=True,
- )
+ error_message = fields.Char(string="Mensagem de Erro", readonly=True)
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 6586f0721838..f8a556c46fee 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -1,116 +1,98 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, fields, api
-from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \
- AVISO_FAVORECIDO
+from odoo import api, fields, models
+from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO)
from .account_move_line import ESTADOS_CNAB
class BankPaymentLine(models.Model):
- _inherit = 'bank.payment.line'
+ _inherit = "bank.payment.line"
@api.model
def default_get(self, fields_list):
res = super(BankPaymentLine, self).default_get(fields_list)
- mode = self.env['account.payment.order'].browse(
- self.env.context.get('order_id')).payment_mode_id
+ mode = (
+ self.env["account.payment.order"]
+ .browse(self.env.context.get("order_id"))
+ .payment_mode_id
+ )
if mode.codigo_finalidade_doc:
- res.update({
- 'codigo_finalidade_doc': mode.codigo_finalidade_doc})
+ res.update({"codigo_finalidade_doc": mode.codigo_finalidade_doc})
if mode.codigo_finalidade_ted:
- res.update({
- 'codigo_finalidade_ted': mode.codigo_finalidade_ted
- })
+ res.update({"codigo_finalidade_ted": mode.codigo_finalidade_ted})
if mode.codigo_finalidade_complementar:
- res.update({
- 'codigo_finalidade_complementar':
- mode.codigo_finalidade_complementar
- })
+ res.update(
+ {"codigo_finalidade_complementar": mode.codigo_finalidade_complementar}
+ )
if mode.aviso_ao_favorecido:
- res.update({
- 'aviso_ao_favorecido': mode.aviso_ao_favorecido
- })
+ res.update({"aviso_ao_favorecido": mode.aviso_ao_favorecido})
return res
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u'Complemento do Tipo de Serviço',
- help=u'Campo P005 do CNAB'
+ string=u"Complemento do Tipo de Serviço",
+ help=u"Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u'Código Finalidade da TED',
- help=u'Campo P011 do CNAB'
+ string=u"Código Finalidade da TED",
+ help=u"Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2,
- string=u'Código de finalidade complementar',
- help=u'Campo P013 do CNAB'
+ size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u'Aviso ao Favorecido',
- help=u'Campo P006 do CNAB',
- default='0',
+ string=u"Aviso ao Favorecido",
+ help=u"Campo P006 do CNAB",
+ default="0",
)
abatimento = fields.Float(
digits=(13, 2),
- string=u'Valor do Abatimento',
- help=u'Campo G045 do CNAB',
- default=0.00
+ string=u"Valor do Abatimento",
+ help=u"Campo G045 do CNAB",
+ default=0.00,
)
desconto = fields.Float(
digits=(13, 2),
- string=u'Valor do Desconto',
- help=u'Campo G046 do CNAB',
- default=0.00
+ string=u"Valor do Desconto",
+ help=u"Campo G046 do CNAB",
+ default=0.00,
)
mora = fields.Float(
digits=(13, 2),
- string=u'Valor da Mora',
- help=u'Campo G047 do CNAB',
- default=0.00
+ string=u"Valor da Mora",
+ help=u"Campo G047 do CNAB",
+ default=0.00,
)
multa = fields.Float(
digits=(13, 2),
- string=u'Valor da Multa',
- help=u'Campo G048 do CNAB',
- default=0.00
+ string=u"Valor da Multa",
+ help=u"Campo G048 do CNAB",
+ default=0.00,
)
evento_id = fields.One2many(
string="Eventos CNAB",
comodel_name="l10n_br.cnab.evento",
inverse_name="bank_payment_line_id",
- readonly=True
+ readonly=True,
)
codigo_finalidade_complementar = fields.Char(
- size=2,
- string=u'Código de finalidade complementar',
- help=u'Campo P013 do CNAB',
- )
- nosso_numero = fields.Char(
- string=u'Nosso Numero',
- )
- numero_documento = fields.Char(
- string=u'Número documento'
- )
- identificacao_titulo_empresa = fields.Char(
- string=u'Identificação Titulo Empresa',
- )
- is_erro_exportacao = fields.Boolean(
- string=u'Contem erro de exportação',
- )
- mensagem_erro_exportacao = fields.Char(
- string=u'Mensagem de erro',
+ size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
)
+ nosso_numero = fields.Char(string=u"Nosso Numero")
+ numero_documento = fields.Char(string=u"Número documento")
+ identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
+ is_erro_exportacao = fields.Boolean(string=u"Contem erro de exportação")
+ mensagem_erro_exportacao = fields.Char(string=u"Mensagem de erro")
ultimo_estado_cnab = fields.Selection(
selection=ESTADOS_CNAB,
- string=u'Último Estado do CNAB',
- help=u'Último Estado do CNAB antes da confirmação de '
- u'pagamento nas Ordens de Pagamento',
+ string=u"Último Estado do CNAB",
+ help=u"Último Estado do CNAB antes da confirmação de "
+ u"pagamento nas Ordens de Pagamento",
)
@api.multi
@@ -118,13 +100,16 @@ def unlink(self):
for record in self:
if not record.ultimo_estado_cnab:
continue
-
- move_line_id = \
- self.env['account.move.line'].search(
- [('identificacao_titulo_empresa',
- '=',
- record.identificacao_titulo_empresa)]
- )
+
+ move_line_id = self.env["account.move.line"].search(
+ [
+ (
+ "identificacao_titulo_empresa",
+ "=",
+ record.identificacao_titulo_empresa,
+ )
+ ]
+ )
move_line_id.state_cnab = record.ultimo_estado_cnab
return super(BankPaymentLine, self).unlink()
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 5cb50d037319..0978e64ce4c4 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luiz Felipe do Divino Costa
# @author Luis Felipe Mileo
@@ -7,80 +6,73 @@
import logging
import re
from datetime import datetime
-from ..constantes import CODIGO_OCORRENCIAS
-from odoo import api, models, fields
+from odoo import api, fields, models
+
+from ..constantes import CODIGO_OCORRENCIAS
_logger = logging.getLogger(__name__)
-STATE = [
- ('draft', 'Novo'),
- ('done', 'Processado'),
- ('error', 'Erro no Processamento')
-]
+STATE = [("draft", "Novo"), ("done", "Processado"), ("error", "Erro no Processamento")]
TIPO_OPERACAO = {
- 'C': u'Lançamento a Crédito',
- 'D': u'Lançamento a Débito',
- 'E': u'Extrato para Conciliação',
- 'G': u'Extrato para Gestão de Caixa',
- 'I': u'Informações de Títulos Capturados do Próprio Banco',
- 'R': u'Arquivo Remessa',
- 'T': u'Arquivo Retorno',
+ "C": u"Lançamento a Crédito",
+ "D": u"Lançamento a Débito",
+ "E": u"Extrato para Conciliação",
+ "G": u"Extrato para Gestão de Caixa",
+ "I": u"Informações de Títulos Capturados do Próprio Banco",
+ "R": u"Arquivo Remessa",
+ "T": u"Arquivo Retorno",
}
TIPO_SERVICO = {
- '01': 'Cobrança',
- '03': 'Boleto de Pagamento Eletrônico',
- '04': 'Conciliação Bancária',
- '05': 'Débitos',
- '06': 'Custódia de Cheques',
- '07': 'Gestão de Caixa',
- '08': 'Consulta/Informação Margem',
- '09': 'Averbação da Consignação/Retenção',
- '10': 'Pagamento Dividendos',
- '11': 'Manutenção da Consignação',
- '12': 'Consignação de Parcelas',
- '13': 'Glosa da Consignação (INSS)',
- '14': 'Consulta de Tributos a pagar',
- '20': 'Pagamento Fornecedor',
- '22': 'Pagamento de Contas, Tributos e Impostos',
- '23': 'Interoperabilidade entre Contas de Instituições de Pagamentos',
- '25': 'Compror',
- '26': 'Compror Rotativo',
- '29': 'Alegação do Pagador',
- '30': 'Pagamento Salários',
- '32': 'Pagamento de honorários',
- '33': 'Pagamento de bolsa auxílio',
- '34': 'Pagamento de prebenda (remuneração a padres e sacerdotes)',
- '40': 'Vendor',
- '41': 'Vendor a Termo',
- '50': 'Pagamento Sinistros Segurados',
- '60': 'Pagamento Despesas Viajante em Trânsito',
- '70': 'Pagamento Autorizado',
- '75': 'Pagamento Credenciados',
- '77': 'Pagamento de Remuneração',
- '80': 'Pagamento Representantes / Vendedores Autorizados',
- '90': 'Pagamento Benefícios',
- '98': 'Pagamentos Diversos',
+ "01": "Cobrança",
+ "03": "Boleto de Pagamento Eletrônico",
+ "04": "Conciliação Bancária",
+ "05": "Débitos",
+ "06": "Custódia de Cheques",
+ "07": "Gestão de Caixa",
+ "08": "Consulta/Informação Margem",
+ "09": "Averbação da Consignação/Retenção",
+ "10": "Pagamento Dividendos",
+ "11": "Manutenção da Consignação",
+ "12": "Consignação de Parcelas",
+ "13": "Glosa da Consignação (INSS)",
+ "14": "Consulta de Tributos a pagar",
+ "20": "Pagamento Fornecedor",
+ "22": "Pagamento de Contas, Tributos e Impostos",
+ "23": "Interoperabilidade entre Contas de Instituições de Pagamentos",
+ "25": "Compror",
+ "26": "Compror Rotativo",
+ "29": "Alegação do Pagador",
+ "30": "Pagamento Salários",
+ "32": "Pagamento de honorários",
+ "33": "Pagamento de bolsa auxílio",
+ "34": "Pagamento de prebenda (remuneração a padres e sacerdotes)",
+ "40": "Vendor",
+ "41": "Vendor a Termo",
+ "50": "Pagamento Sinistros Segurados",
+ "60": "Pagamento Despesas Viajante em Trânsito",
+ "70": "Pagamento Autorizado",
+ "75": "Pagamento Credenciados",
+ "77": "Pagamento de Remuneração",
+ "80": "Pagamento Representantes / Vendedores Autorizados",
+ "90": "Pagamento Benefícios",
+ "98": "Pagamentos Diversos",
}
TIPO_INSCRICAO_EMPRESA = {
- 0: 'Isento / Não informado',
- 1: 'CPF',
- 2: 'CGC / CNPJ',
- 3: 'PIS / PASEP',
- 9: 'Outros',
+ 0: "Isento / Não informado",
+ 1: "CPF",
+ 2: "CGC / CNPJ",
+ 3: "PIS / PASEP",
+ 9: "Outros",
}
-RETORNO_400_CONFIRMADA = [
- 2,
-]
+RETORNO_400_CONFIRMADA = [2]
-RETORNO_400_REJEITADA = [
- 3,
-]
+RETORNO_400_REJEITADA = [3]
RETORNO_400_LIQUIDACAO = [
6,
@@ -88,157 +80,157 @@
8,
]
-RETORNO_400_BAIXA = [
- 9,
- 10,
-]
+RETORNO_400_BAIXA = [9, 10]
-RETORNOS_TRATADOS = \
- [RETORNO_400_CONFIRMADA, RETORNO_400_REJEITADA, RETORNO_400_LIQUIDACAO, RETORNO_400_BAIXA]
+RETORNOS_TRATADOS = [
+ RETORNO_400_CONFIRMADA,
+ RETORNO_400_REJEITADA,
+ RETORNO_400_LIQUIDACAO,
+ RETORNO_400_BAIXA,
+]
# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
COD_REGISTROS_REJEITADOS_CNAB400 = {
- 3: 'AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO',
- 4: 'ESTADO - SIGLA DO ESTADO INVÁLIDA',
- 5: 'DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO',
- 7: 'VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00',
- 8: 'NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO',
- 9: 'AGENCIA/CONTA - AGÊNCIA ENCERRADA',
- 10: 'LOGRADOURO - NÃO INFORMADO OU DESLOCADO',
- 11: 'CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO',
- 12: 'SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)',
- 13: 'ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO',
- 14: 'NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA',
- 15: 'NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO',
- 18: 'DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA',
- 19: 'OCORRÊNCIA - OCORRÊNCIA INVÁLIDA',
- 21: 'AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO',
- 22: 'CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)',
- 26: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA',
- 27: 'CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA',
- 29: 'CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA',
- 30: 'ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA',
- 31: 'AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)',
- 35: 'VALOR DO IOF - IOF MAIOR QUE 5%',
- 36: 'QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO',
- 37: 'CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS',
- 42: 'NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA',
- 52: 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE',
- 53: 'AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM',
- 54: 'DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS',
- 55: 'DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA',
- 56: 'DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA',
- 57: 'DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS',
- 60: 'ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO',
- 61: 'JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO',
- 62: 'DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO',
- 63: 'DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO',
- 64: 'DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA',
- 65: 'TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)',
- 66: 'DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)',
- 67: 'VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO',
- 68: 'CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA',
- 69: 'CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO',
- 70: 'AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO',
- 78: 'AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO',
- 80: 'AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)',
- 81: 'AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ',
- 82: 'DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO',
- 83: 'VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO',
- 84: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO',
- 85: 'AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO',
- 86: 'TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO',
- 87: 'AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO',
- 90: 'NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS',
- 97: 'SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8',
- 98: 'FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO',
- 99: 'FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE',
+ 3: "AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO",
+ 4: "ESTADO - SIGLA DO ESTADO INVÁLIDA",
+ 5: "DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO",
+ 7: "VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00",
+ 8: "NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO",
+ 9: "AGENCIA/CONTA - AGÊNCIA ENCERRADA",
+ 10: "LOGRADOURO - NÃO INFORMADO OU DESLOCADO",
+ 11: "CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO",
+ 12: "SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)",
+ 13: "ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO",
+ 14: "NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA",
+ 15: "NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO",
+ 18: "DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA",
+ 19: "OCORRÊNCIA - OCORRÊNCIA INVÁLIDA",
+ 21: "AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO",
+ 22: "CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)",
+ 26: "AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA",
+ 27: "CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA",
+ 29: "CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA",
+ 30: "ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA",
+ 31: "AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)",
+ 35: "VALOR DO IOF - IOF MAIOR QUE 5%",
+ 36: "QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO",
+ 37: "CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS",
+ 42: "NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA",
+ 52: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE",
+ 53: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM",
+ 54: "DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS",
+ 55: "DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA",
+ 56: "DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA",
+ 57: "DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS",
+ 60: "ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO",
+ 61: "JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO",
+ 62: "DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO",
+ 63: "DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO",
+ 64: "DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA",
+ 65: "TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)",
+ 66: "DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)",
+ 67: "VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO",
+ 68: "CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA",
+ 69: "CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO",
+ 70: "AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO",
+ 78: "AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO",
+ 80: "AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)",
+ 81: "AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ",
+ 82: "DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO",
+ 83: "VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO",
+ 84: "AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO",
+ 85: "AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO",
+ 86: "TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO",
+ 87: "AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO",
+ 90: "NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS",
+ 97: "SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8",
+ 98: "FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO",
+ 99: "FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE",
}
-
CODIGO_OCORRENCIAS_CNAB200 = {
- 2: 'ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)', # noqa
- 3: 'ENTRADA REJEITADA (NOTA 20 – TABELA 1)', # noqa
- 4: 'ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA', # noqa
- 5: 'ALTERAÇÃO DE DADOS – BAIXA',
- 6: 'LIQUIDAÇÃO NORMAL',
- 7: 'LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)',
- 8: 'LIQUIDAÇÃO EM CARTÓRIO',
- 9: 'BAIXA SIMPLES',
- 10: 'BAIXA POR TER SIDO LIQUIDADO',
- 11: 'EM SER (SÓ NO RETORNO MENSAL)',
- 12: 'ABATIMENTO CONCEDIDO',
- 13: 'ABATIMENTO CANCELADO',
- 14: 'VENCIMENTO ALTERADO',
- 15: 'BAIXAS REJEITADAS (NOTA 20 – TABELA 4)',
- 16: 'INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)',
- 17: 'ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)',
- 18: 'COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)', # noqa
- 19: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO',
- 20: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA',
- 21: 'CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR',
- 23: 'TÍTULO ENVIADO A CARTÓRIO/TARIFA',
- 24: 'INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)', # noqa
- 25: 'ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)',
- 26: 'TARIFA DE AVISO DE COBRANÇA',
- 27: 'TARIFA DE EXTRATO POSIÇÃO (B40X)',
- 28: 'TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES',
- 29: 'TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS',
- 30: 'DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)',
- 32: 'BAIXA POR TER SIDO PROTESTADO',
- 33: 'CUSTAS DE PROTESTO',
- 34: 'CUSTAS DE SUSTAÇÃO',
- 35: 'CUSTAS DE CARTÓRIO DISTRIBUIDOR',
- 36: 'CUSTAS DE EDITAL',
- 37: 'TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA',
- 38: 'TARIFA DE INSTRUÇÃO',
- 39: 'TARIFA DE OCORRÊNCIAS',
- 40: 'TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA', # noqa
- 41: 'DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)',
- 42: 'DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES',
- 43: 'DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS',
- 44: 'DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS',
- 45: 'DÉBITO MENSAL DE TARIFAS – PROTESTO',
- 46: 'DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO',
- 47: 'BAIXA COM TRANSFERÊNCIA PARA DESCONTO',
- 48: 'CUSTAS DE SUSTAÇÃO JUDICIAL',
- 51: 'TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA',
- 52: 'TARIFA MENSAL BAIXAS NA CARTEIRA',
- 53: 'TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA',
- 54: 'TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA',
- 55: 'TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA',
- 56: 'CUSTAS DE IRREGULARIDADE',
- 57: 'INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)',
- 59: 'BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG',
- 60: 'ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)',
- 61: 'TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)',
- 62: 'DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)',
- 63: 'TÍTULO SUSTADO JUDICIALMENTE',
- 64: 'ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO',
- 65: 'PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO',
- 69: 'CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)',
- 71: 'ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO',
- 72: 'BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE',
- 73: 'CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL', # noqa
- 74: 'INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)',
- 75: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA', # noqa
- 76: 'CHEQUE COMPENSADO',
- 77: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA', # noqa
- 78: 'CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA', # noqa
- 79: 'NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)',
- 80: 'CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA',
- 82: 'CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA',
- 83: 'CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA', # noqa
- 85: 'TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA',
- 86: 'TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA',
- 87: 'TARIFA SMS COBRANÇA ATIVA ELETRÔNICA',
- 88: 'TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA',
- 89: 'TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA',
- 90: 'TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA',
- 91: 'TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA',
- 92: 'TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA',
- 93: 'TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO',
+ 2: "ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)", # noqa
+ 3: "ENTRADA REJEITADA (NOTA 20 – TABELA 1)", # noqa
+ 4: "ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA", # noqa
+ 5: "ALTERAÇÃO DE DADOS – BAIXA",
+ 6: "LIQUIDAÇÃO NORMAL",
+ 7: "LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)",
+ 8: "LIQUIDAÇÃO EM CARTÓRIO",
+ 9: "BAIXA SIMPLES",
+ 10: "BAIXA POR TER SIDO LIQUIDADO",
+ 11: "EM SER (SÓ NO RETORNO MENSAL)",
+ 12: "ABATIMENTO CONCEDIDO",
+ 13: "ABATIMENTO CANCELADO",
+ 14: "VENCIMENTO ALTERADO",
+ 15: "BAIXAS REJEITADAS (NOTA 20 – TABELA 4)",
+ 16: "INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)",
+ 17: "ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)",
+ 18: "COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)", # noqa
+ 19: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO",
+ 20: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA",
+ 21: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR",
+ 23: "TÍTULO ENVIADO A CARTÓRIO/TARIFA",
+ 24: "INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)", # noqa
+ 25: "ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)",
+ 26: "TARIFA DE AVISO DE COBRANÇA",
+ 27: "TARIFA DE EXTRATO POSIÇÃO (B40X)",
+ 28: "TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES",
+ 29: "TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS",
+ 30: "DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)",
+ 32: "BAIXA POR TER SIDO PROTESTADO",
+ 33: "CUSTAS DE PROTESTO",
+ 34: "CUSTAS DE SUSTAÇÃO",
+ 35: "CUSTAS DE CARTÓRIO DISTRIBUIDOR",
+ 36: "CUSTAS DE EDITAL",
+ 37: "TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA",
+ 38: "TARIFA DE INSTRUÇÃO",
+ 39: "TARIFA DE OCORRÊNCIAS",
+ 40: "TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA", # noqa
+ 41: "DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)",
+ 42: "DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES",
+ 43: "DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS",
+ 44: "DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS",
+ 45: "DÉBITO MENSAL DE TARIFAS – PROTESTO",
+ 46: "DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO",
+ 47: "BAIXA COM TRANSFERÊNCIA PARA DESCONTO",
+ 48: "CUSTAS DE SUSTAÇÃO JUDICIAL",
+ 51: "TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA",
+ 52: "TARIFA MENSAL BAIXAS NA CARTEIRA",
+ 53: "TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA",
+ 54: "TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA",
+ 55: "TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA",
+ 56: "CUSTAS DE IRREGULARIDADE",
+ 57: "INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)",
+ 59: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG",
+ 60: "ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)",
+ 61: "TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
+ 62: "DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
+ 63: "TÍTULO SUSTADO JUDICIALMENTE",
+ 64: "ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO",
+ 65: "PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO",
+ 69: "CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)",
+ 71: "ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO",
+ 72: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE",
+ 73: "CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL", # noqa
+ 74: "INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)",
+ 75: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
+ 76: "CHEQUE COMPENSADO",
+ 77: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
+ 78: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA", # noqa
+ 79: "NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)",
+ 80: "CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA",
+ 82: "CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA",
+ 83: "CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA", # noqa
+ 85: "TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
+ 86: "TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA",
+ 87: "TARIFA SMS COBRANÇA ATIVA ELETRÔNICA",
+ 88: "TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
+ 89: "TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA",
+ 90: "TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA",
+ 91: "TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA",
+ 92: "TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA",
+ 93: "TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO",
}
STR_EVENTO_FORMAT = "%d%m%y"
@@ -248,67 +240,42 @@ class L10nBrHrCnab(models.Model):
_name = "l10n_br.cnab"
_rec_name = "display_name"
- display_name = fields.Char(
- compute='_compute_display_name',
- store=True,
- index=True
- )
+ display_name = fields.Char(compute="_compute_display_name", store=True, index=True)
- arquivo_retorno = fields.Binary(
- string='Arquivo Retorno'
- )
- filename = fields.Char(
- string="Filename"
- )
+ arquivo_retorno = fields.Binary(string="Arquivo Retorno")
+ filename = fields.Char(string="Filename")
bank_account_id = fields.Many2one(
- string="Conta cedente",
- comodel_name="res.partner.bank",
- )
- data = fields.Date(
- string="Data CNAB",
- required=True,
- default=datetime.now()
- )
- data_arquivo = fields.Date(
- string="Data Criação no Banco",
- )
- sequencial_arquivo = fields.Char(
- string="Sequencial do Arquivo",
- )
- motivo_erro = fields.Char(
- string="Motivo do Erro",
+ string="Conta cedente", comodel_name="res.partner.bank"
)
+ data = fields.Date(string="Data CNAB", required=True, default=datetime.now())
+ data_arquivo = fields.Date(string="Data Criação no Banco")
+ sequencial_arquivo = fields.Char(string="Sequencial do Arquivo")
+ motivo_erro = fields.Char(string="Motivo do Erro")
lote_id = fields.One2many(
- string="Lotes",
- comodel_name="l10n_br.cnab.lote",
- inverse_name="cnab_id"
- )
- name = fields.Char(
- string="Name",
- )
- num_eventos = fields.Integer(
- string=u"Número de Eventos",
- )
- num_lotes = fields.Integer(
- string=u"Número de Lotes",
- )
- state = fields.Selection(
- string=u"Estágio",
- selection=STATE,
- default="draft",
+ string="Lotes", comodel_name="l10n_br.cnab.lote", inverse_name="cnab_id"
)
+ name = fields.Char(string="Name")
+ num_eventos = fields.Integer(string=u"Número de Eventos")
+ num_lotes = fields.Integer(string=u"Número de Lotes")
+ state = fields.Selection(string=u"Estágio", selection=STATE, default="draft")
@api.one
- @api.depends('name')
+ @api.depends("name")
def _compute_display_name(self):
self.display_name = self.name
def _busca_conta(self, banco, agencia, conta):
- return self.env['res.partner.bank'].search([
- # ('acc_number', '=', str(banco)),
- ('bra_number', '=', str(agencia)),
- ('acc_number', '=', str(conta))
- ]).id
+ return (
+ self.env["res.partner.bank"]
+ .search(
+ [
+ # ('acc_number', '=', str(banco)),
+ ("bra_number", "=", str(agencia)),
+ ("acc_number", "=", str(conta)),
+ ]
+ )
+ .id
+ )
def _cria_lote(self, header, lote, evento, trailer):
@@ -322,66 +289,67 @@ def _cria_lote(self, header, lote, evento, trailer):
lote_bank_account_id = self.bank_account_id
vals = {
- 'account_bank_id': lote_bank_account_id.id,
- 'servico_operacao': header.literal_retorno,
- 'tipo_servico': header.literal_servico,
- 'qtd_registros': trailer.totais_quantidade_registros,
- 'total_valores': float(trailer.valor_total_titulos) / 100,
- 'cnab_id': self.id,
+ "account_bank_id": lote_bank_account_id.id,
+ "servico_operacao": header.literal_retorno,
+ "tipo_servico": header.literal_servico,
+ "qtd_registros": trailer.totais_quantidade_registros,
+ "total_valores": float(trailer.valor_total_titulos) / 100,
+ "cnab_id": self.id,
}
- lote_id = self.env['l10n_br.cnab.lote'].create(vals)
+ lote_id = self.env["l10n_br.cnab.lote"].create(vals)
return lote_id, lote_bank_account_id
def _lote_400(self, evento, lote_id):
- bank_payment_line_id = self.env['bank.payment.line'].search([(
- 'nosso_numero', '=', evento.nosso_numero
- )], limit=1)
+ bank_payment_line_id = self.env["bank.payment.line"].search(
+ [("nosso_numero", "=", evento.nosso_numero)], limit=1
+ )
vals_evento = {
- 'bank_payment_line_id': bank_payment_line_id.id,
- 'data_ocorrencia':
- datetime.strptime(
- str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT)
- if evento.data_ocorrencia else '',
- 'data_real_pagamento':
- datetime.strptime(
- str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
- if evento.data_credito else '',
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- 'invoice_id': bank_payment_line_id.
- payment_line_ids[:1].move_line_id.invoice_id.id,
- 'juros_mora_multa': float(evento.juros_mora_multa) / 100,
- 'lote_id': lote_id.id,
- 'nosso_numero': str(evento.nosso_numero),
- 'ocorrencias':
- CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
- 'outros_creditos': float(evento.outros_creditos) / 100,
- 'partner_id': bank_payment_line_id.partner_id.id,
- 'seu_numero': evento.numero_documento,
- 'str_motiv_a':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
- if evento.erros[0:2] else '',
- 'str_motiv_b':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
- if evento.erros[2:4] else '',
- 'str_motiv_c':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
- if evento.erros[4:6] else '',
- 'str_motiv_d':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
- if evento.erros[6:8] else '',
- 'tarifa_cobranca': float(evento.tarifa_cobranca),
- 'valor': float(evento.valor) / 100,
- 'valor_abatimento': float(evento.valor_abatimento) / 100,
- 'valor_desconto': float(evento.valor_desconto) / 100,
- 'valor_iof': float(evento.valor_iof) / 100,
- 'valor_pagamento': evento.valor_principal,
+ "bank_payment_line_id": bank_payment_line_id.id,
+ "data_ocorrencia": datetime.strptime(
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_ocorrencia
+ else "",
+ "data_real_pagamento": datetime.strptime(
+ str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_credito
+ else "",
+ "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "invoice_id": bank_payment_line_id.payment_line_ids[
+ :1
+ ].move_line_id.invoice_id.id,
+ "juros_mora_multa": float(evento.juros_mora_multa) / 100,
+ "lote_id": lote_id.id,
+ "nosso_numero": str(evento.nosso_numero),
+ "ocorrencias": CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ "outros_creditos": float(evento.outros_creditos) / 100,
+ "partner_id": bank_payment_line_id.partner_id.id,
+ "seu_numero": evento.numero_documento,
+ "str_motiv_a": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
+ if evento.erros[0:2]
+ else "",
+ "str_motiv_b": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
+ if evento.erros[2:4]
+ else "",
+ "str_motiv_c": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
+ if evento.erros[4:6]
+ else "",
+ "str_motiv_d": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
+ if evento.erros[6:8]
+ else "",
+ "tarifa_cobranca": float(evento.tarifa_cobranca),
+ "valor": float(evento.valor) / 100,
+ "valor_abatimento": float(evento.valor_abatimento) / 100,
+ "valor_desconto": float(evento.valor_desconto) / 100,
+ "valor_iof": float(evento.valor_iof) / 100,
+ "valor_pagamento": evento.valor_principal,
}
- cnab_event_id = self.env['l10n_br.cnab.evento'].create(vals_evento)
+ cnab_event_id = self.env["l10n_br.cnab.evento"].create(vals_evento)
amount = 0.0
line_values = []
@@ -391,23 +359,24 @@ def _lote_400(self, evento, lote_id):
cnab_state = False
bank_state = False
if codigo_ocorrencia in RETORNO_400_CONFIRMADA:
- cnab_state = 'accepted'
- bank_state = 'aberta'
+ cnab_state = "accepted"
+ bank_state = "aberta"
elif codigo_ocorrencia in RETORNO_400_REJEITADA:
- cnab_state = 'not_accepted'
- bank_state = 'inicial'
+ cnab_state = "not_accepted"
+ bank_state = "inicial"
elif codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
- cnab_state = 'accepted'
- bank_state = 'liquidada'
+ cnab_state = "accepted"
+ bank_state = "liquidada"
elif codigo_ocorrencia in RETORNO_400_BAIXA:
- cnab_state = 'accepted'
+ cnab_state = "accepted"
if codigo_ocorrencia == 9:
- bank_state = 'baixa'
+ bank_state = "baixa"
else:
- bank_state = 'baixa_liquidacao'
+ bank_state = "baixa_liquidacao"
else:
- cnab_event_id.str_motiv_e = str(codigo_ocorrencia) + \
- ': Ocorrência não tratada'
+ cnab_event_id.str_motiv_e = (
+ str(codigo_ocorrencia) + ": Ocorrência não tratada"
+ )
if cnab_state:
@@ -418,55 +387,50 @@ def _lote_400(self, evento, lote_id):
)
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
- if bank_state == 'liquidada' and invoice.state == 'open':
+ if bank_state == "liquidada" and invoice.state == "open":
line_dict = {
- 'name': evento.nosso_numero,
- 'nosso_numero': evento.nosso_numero,
- 'numero_documento': evento.numero_documento,
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- 'credit': float(evento.valor_principal) +
- float(evento.tarifa_cobranca),
- 'account_id': invoice.payment_mode_id.
- default_account_id.id or
- invoice.account_id.id,
- 'journal_id':
- bank_payment_line_id.order_id.\
- journal_id.id,
- 'date_maturity':
- datetime.strptime(
- str(evento.vencimento).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.vencimento else '',
- 'date':
- datetime.strptime(
- str(evento.data_ocorrencia).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.data_ocorrencia else '',
- 'partner_id': bank_payment_line_id.\
- partner_id.id
- }
+ "name": evento.nosso_numero,
+ "nosso_numero": evento.nosso_numero,
+ "numero_documento": evento.numero_documento,
+ "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "credit": float(evento.valor_principal)
+ + float(evento.tarifa_cobranca),
+ "account_id": invoice.payment_mode_id.default_account_id.id
+ or invoice.account_id.id,
+ "journal_id": bank_payment_line_id.order_id.journal_id.id,
+ "date_maturity": datetime.strptime(
+ str(evento.vencimento).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.vencimento
+ else "",
+ "date": datetime.strptime(
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_ocorrencia
+ else "",
+ "partner_id": bank_payment_line_id.partner_id.id,
+ }
line_values.append((0, 0, line_dict))
amount += float(evento.valor_principal)
invoices.append(invoice)
- invoice_line_tax_id = \
- invoice.invoice_line_ids.filtered(
- lambda i: i.price_subtotal == float(
- evento.tarifa_cobranca))
+ invoice_line_tax_id = invoice.invoice_line_ids.filtered(
+ lambda i: i.price_subtotal == float(evento.tarifa_cobranca)
+ )
if invoice_line_tax_id:
# amount += float(evento.tarifa_cobranca)
line_dict_tarifa = dict(line_dict)
- line_dict_tarifa.update({
- 'name': str(evento.nosso_numero) + ' - Tarifa',
- 'credit': 0,
- 'debit': float(evento.tarifa_cobranca),
- 'account_id': invoice.payment_mode_id.
- default_tax_account_id.id or
- invoice.account_id.id,
- })
+ line_dict_tarifa.update(
+ {
+ "name": str(evento.nosso_numero) + " - Tarifa",
+ "credit": 0,
+ "debit": float(evento.tarifa_cobranca),
+ "account_id": invoice.payment_mode_id.default_tax_account_id.id
+ or invoice.account_id.id,
+ }
+ )
line_values.append((0, 0, line_dict_tarifa))
# TODO: Juros / iof / Desconto / Abatimento /
@@ -489,71 +453,65 @@ def _lote_400(self, evento, lote_id):
return line_values, amount, invoices
def _lote_240(self, evento, lote_id):
- data_evento = str(
- evento.credito_data_real)
+ data_evento = str(evento.credito_data_real)
data_evento = fields.Date.from_string(
- data_evento[4:] + "-" + data_evento[2:4] + "-" +
- data_evento[0:2]
- )
- lote_bank_account_id = self.env['res.partner.bank'].search(
- [
- ('bra_number', '=', evento.favorecido_agencia),
- ('bra_number_dig', '=', evento.favorecido_agencia_dv),
- ('acc_number', '=', evento.favorecido_conta),
- ('acc_number_dig', '=', evento.favorecido_conta_dv)
- ])
- lote_bank_account_id = lote_bank_account_id.ids[0] \
- if lote_bank_account_id else False
- favorecido_partner = self.env['res.partner.bank'].search(
- [('owner_name', 'ilike', evento.favorecido_nome)]
+ data_evento[4:] + "-" + data_evento[2:4] + "-" + data_evento[0:2]
)
- favorecido_partner = favorecido_partner[0].partner_id.id \
- if favorecido_partner else False
- bank_payment_line_id = self.env['bank.payment.line'].search(
+ lote_bank_account_id = self.env["res.partner.bank"].search(
[
- ('name', '=', evento.credito_seu_numero)
+ ("bra_number", "=", evento.favorecido_agencia),
+ ("bra_number_dig", "=", evento.favorecido_agencia_dv),
+ ("acc_number", "=", evento.favorecido_conta),
+ ("acc_number_dig", "=", evento.favorecido_conta_dv),
]
)
+ lote_bank_account_id = (
+ lote_bank_account_id.ids[0] if lote_bank_account_id else False
+ )
+ favorecido_partner = self.env["res.partner.bank"].search(
+ [("owner_name", "ilike", evento.favorecido_nome)]
+ )
+ favorecido_partner = (
+ favorecido_partner[0].partner_id.id if favorecido_partner else False
+ )
+ bank_payment_line_id = self.env["bank.payment.line"].search(
+ [("name", "=", evento.credito_seu_numero)]
+ )
ocorrencias_dic = dict(CODIGO_OCORRENCIAS)
ocorrencias = [
evento.ocorrencias[0:2],
evento.ocorrencias[2:4],
evento.ocorrencias[4:6],
evento.ocorrencias[6:8],
- evento.ocorrencias[8:10]
+ evento.ocorrencias[8:10],
]
vals_evento = {
- 'data_real_pagamento': data_evento,
- 'segmento': evento.servico_segmento,
- 'favorecido_nome': favorecido_partner,
- 'favorecido_conta_bancaria': lote_bank_account_id,
- 'nosso_numero': str(evento.credito_nosso_numero),
- 'seu_numero': evento.credito_seu_numero,
- 'tipo_moeda': evento.credito_moeda_tipo,
- 'valor_pagamento': evento.credito_valor_pagamento,
- 'ocorrencias': evento.ocorrencias,
- 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if
- ocorrencias[0] else '',
- 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if
- ocorrencias[1] else '',
- 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if
- ocorrencias[2] else '',
- 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if
- ocorrencias[3] else '',
- 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if
- ocorrencias[4] else '',
- 'lote_id': lote_id.id,
- 'bank_payment_line_id': bank_payment_line_id.id,
+ "data_real_pagamento": data_evento,
+ "segmento": evento.servico_segmento,
+ "favorecido_nome": favorecido_partner,
+ "favorecido_conta_bancaria": lote_bank_account_id,
+ "nosso_numero": str(evento.credito_nosso_numero),
+ "seu_numero": evento.credito_seu_numero,
+ "tipo_moeda": evento.credito_moeda_tipo,
+ "valor_pagamento": evento.credito_valor_pagamento,
+ "ocorrencias": evento.ocorrencias,
+ "str_motiv_a": ocorrencias_dic[ocorrencias[0]] if ocorrencias[0] else "",
+ "str_motiv_b": ocorrencias_dic[ocorrencias[1]] if ocorrencias[1] else "",
+ "str_motiv_c": ocorrencias_dic[ocorrencias[2]] if ocorrencias[2] else "",
+ "str_motiv_d": ocorrencias_dic[ocorrencias[3]] if ocorrencias[3] else "",
+ "str_motiv_e": ocorrencias_dic[ocorrencias[4]] if ocorrencias[4] else "",
+ "lote_id": lote_id.id,
+ "bank_payment_line_id": bank_payment_line_id.id,
}
- self.env['l10n_br.cnab.evento'].create(vals_evento)
+ self.env["l10n_br.cnab.evento"].create(vals_evento)
if evento.ocorrencias and bank_payment_line_id:
- if '00' in ocorrencias:
- bank_state = 'paid'
- cnab_state = 'accepted'
+ if "00" in ocorrencias:
+ bank_state = "paid"
+ cnab_state = "accepted"
else:
- bank_state = 'exception'
- cnab_state = 'not_accepted'
+ bank_state = "exception"
+ cnab_state = "not_accepted"
bank_payment_line_id.state2 = bank_state
for payment_line in bank_payment_line_id.payment_line_ids:
@@ -563,67 +521,71 @@ def _reprocessa_lote_240(self, evento, lote_id):
raise NotImplementedError("FALTA FAZER")
def _reprocessa_lote_400(self, evento, lote_id):
- bank_payment_line_id = self.env['bank.payment.line'].search([(
- 'identificacao_titulo_empresa', '=',
- evento.identificacao_titulo_empresa
- )], limit=1)
+ bank_payment_line_id = self.env["bank.payment.line"].search(
+ [
+ (
+ "identificacao_titulo_empresa",
+ "=",
+ evento.identificacao_titulo_empresa,
+ )
+ ],
+ limit=1,
+ )
- cnab_event_id = self.env['l10n_br.cnab.evento'].search([
- ('lote_id', '=', lote_id.id),
- ('bank_payment_line_id', '!=', False),
- ('bank_payment_line_id', '=', bank_payment_line_id.id),
- ])
+ cnab_event_id = self.env["l10n_br.cnab.evento"].search(
+ [
+ ("lote_id", "=", lote_id.id),
+ ("bank_payment_line_id", "!=", False),
+ ("bank_payment_line_id", "=", bank_payment_line_id.id),
+ ]
+ )
vals_evento = {
- 'bank_payment_line_id':
- cnab_event_id.bank_payment_line_id.id or
- bank_payment_line_id.id,
- 'data_ocorrencia':
- datetime.strptime(
- str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT)
- if evento.data_ocorrencia else '',
- 'data_real_pagamento':
- datetime.strptime(
- str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT)
- if evento.data_credito else '',
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- 'invoice_id': cnab_event_id.invoice_id.id or
- bank_payment_line_id.payment_line_ids[:1].
- move_line_id.invoice_id.id,
- 'juros_mora_multa': cnab_event_id.juros_mora_multa or
- float(evento.juros_mora_multa) / 100,
- 'lote_id': cnab_event_id.lote_id.id or lote_id.id,
- 'nosso_numero': str(evento.nosso_numero),
- 'ocorrencias':
- CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
- 'outros_creditos': cnab_event_id.outros_creditos or
- float(evento.outros_creditos) / 100,
- 'partner_id': bank_payment_line_id.partner_id.id,
- 'seu_numero': evento.numero_documento,
- 'str_motiv_a':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
- if evento.erros[0:2] else '',
- 'str_motiv_b':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
- if evento.erros[2:4] else '',
- 'str_motiv_c':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
- if evento.erros[4:6] else '',
- 'str_motiv_d':
- COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
- if evento.erros[6:8] else '',
- 'tarifa_cobranca': cnab_event_id.tarifa_cobranca or
- float(evento.tarifa_cobranca),
- 'valor': cnab_event_id.valor or float(evento.valor) / 100,
- 'valor_abatimento': cnab_event_id.valor_abatimento or
- float(evento.valor_abatimento) / 100,
- 'valor_desconto': cnab_event_id.valor_desconto or
- float(evento.valor_desconto) / 100,
- 'valor_iof': cnab_event_id.valor_iof or
- float(evento.valor_iof) / 100,
- 'valor_pagamento': cnab_event_id.valor_pagamento or
- evento.valor_principal,
+ "bank_payment_line_id": cnab_event_id.bank_payment_line_id.id
+ or bank_payment_line_id.id,
+ "data_ocorrencia": datetime.strptime(
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_ocorrencia
+ else "",
+ "data_real_pagamento": datetime.strptime(
+ str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_credito
+ else "",
+ "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "invoice_id": cnab_event_id.invoice_id.id
+ or bank_payment_line_id.payment_line_ids[:1].move_line_id.invoice_id.id,
+ "juros_mora_multa": cnab_event_id.juros_mora_multa
+ or float(evento.juros_mora_multa) / 100,
+ "lote_id": cnab_event_id.lote_id.id or lote_id.id,
+ "nosso_numero": str(evento.nosso_numero),
+ "ocorrencias": CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ "outros_creditos": cnab_event_id.outros_creditos
+ or float(evento.outros_creditos) / 100,
+ "partner_id": bank_payment_line_id.partner_id.id,
+ "seu_numero": evento.numero_documento,
+ "str_motiv_a": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
+ if evento.erros[0:2]
+ else "",
+ "str_motiv_b": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
+ if evento.erros[2:4]
+ else "",
+ "str_motiv_c": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
+ if evento.erros[4:6]
+ else "",
+ "str_motiv_d": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
+ if evento.erros[6:8]
+ else "",
+ "tarifa_cobranca": cnab_event_id.tarifa_cobranca
+ or float(evento.tarifa_cobranca),
+ "valor": cnab_event_id.valor or float(evento.valor) / 100,
+ "valor_abatimento": cnab_event_id.valor_abatimento
+ or float(evento.valor_abatimento) / 100,
+ "valor_desconto": cnab_event_id.valor_desconto
+ or float(evento.valor_desconto) / 100,
+ "valor_iof": cnab_event_id.valor_iof or float(evento.valor_iof) / 100,
+ "valor_pagamento": cnab_event_id.valor_pagamento or evento.valor_principal,
}
if not cnab_event_id:
@@ -636,27 +598,29 @@ def _reprocessa_lote_400(self, evento, lote_id):
if codigo_ocorrencia and bank_payment_line_id:
if not any(codigo_ocorrencia in x for x in RETORNOS_TRATADOS):
- cnab_event_id.str_motiv_e = str(codigo_ocorrencia) + \
- ': Ocorrência não tratada'
+ cnab_event_id.str_motiv_e = (
+ str(codigo_ocorrencia) + ": Ocorrência não tratada"
+ )
bank_payment_line_id.nosso_numero = str(evento.nosso_numero)
for pay_order_line_id in bank_payment_line_id.payment_line_ids:
- pay_order_line_id.move_line_id.nosso_numero = str(
- evento.nosso_numero
- )
+ pay_order_line_id.move_line_id.nosso_numero = str(evento.nosso_numero)
pay_order_line_id.nosso_numero = str(evento.nosso_numero)
debit_move_line = pay_order_line_id.move_line_id
- credit_move_line = self.env['account.move.line'].search([
- '|',
- ('nosso_numero', '=', evento.nosso_numero),
- ('name', '=', evento.nosso_numero),
- ('credit', '>', 0),
- ])
+ credit_move_line = self.env["account.move.line"].search(
+ [
+ "|",
+ ("nosso_numero", "=", evento.nosso_numero),
+ ("name", "=", evento.nosso_numero),
+ ("credit", ">", 0),
+ ]
+ )
if not credit_move_line and debit_move_line.full_reconcile_id:
- credit_move_line = \
- debit_move_line.full_reconcile_id.\
- reconciled_line_ids - debit_move_line
+ credit_move_line = (
+ debit_move_line.full_reconcile_id.reconciled_line_ids
+ - debit_move_line
+ )
if not credit_move_line:
return
@@ -665,32 +629,30 @@ def _reprocessa_lote_400(self, evento, lote_id):
# "linha de nosso_numero: %s" % evento.nosso_numero)
line_values = {
- 'name': evento.nosso_numero,
- 'nosso_numero': evento.nosso_numero,
- 'numero_documento': evento.numero_documento,
- 'identificacao_titulo_empresa':
- evento.identificacao_titulo_empresa,
- 'date_maturity':
- datetime.strptime(
- str(evento.vencimento).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.vencimento else '',
- 'date':
- datetime.strptime(
- str(evento.data_ocorrencia).zfill(6),
- STR_EVENTO_FORMAT)
- if evento.data_ocorrencia else '',
+ "name": evento.nosso_numero,
+ "nosso_numero": evento.nosso_numero,
+ "numero_documento": evento.numero_documento,
+ "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "date_maturity": datetime.strptime(
+ str(evento.vencimento).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.vencimento
+ else "",
+ "date": datetime.strptime(
+ str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
+ )
+ if evento.data_ocorrencia
+ else "",
}
- credit_move_line.with_context(
- reprocessing=True).write(line_values)
+ credit_move_line.with_context(reprocessing=True).write(line_values)
@api.model
def processar_retorno_multi(self):
active_ids = self._context.get("active_ids")
for cnab_id in self.browse(active_ids):
- if cnab_id.state in ['draft']:
+ if cnab_id.state in ["draft"]:
cnab_id.processar_arquivo_retorno()
@api.model
@@ -698,7 +660,7 @@ def reprocessar_retorno_multi(self):
active_ids = self._context.get("active_ids")
for cnab_id in self.browse(active_ids):
- if cnab_id.state in ['done']:
+ if cnab_id.state in ["done"]:
cnab_id.reprocessar_arquivo_retorno()
def reprocessar_arquivo_retorno(self):
@@ -708,35 +670,38 @@ def processar_arquivo_retorno(self):
raise NotImplementedError
def _get_name(self, data, filename):
- cnab_ids = self.search([('data', '=', data)], order='id desc')
+ cnab_ids = self.search([("data", "=", data)], order="id desc")
cnab_idx = 1
if cnab_ids:
- search_result = \
- filter(lambda x: x is not None,
- [re.search(r'\((\d)\)', name) for name in self.search(
- [('data', '=', data), ('id', '!=', self.id)],
- order='id desc'
- ).mapped('name')])
+ search_result = filter(
+ lambda x: x is not None,
+ [
+ re.search(r"\((\d)\)", name)
+ for name in self.search(
+ [("data", "=", data), ("id", "!=", self.id)], order="id desc"
+ ).mapped("name")
+ ],
+ )
if search_result:
- cnab_idx = max(int(result.group(1))
- for result in search_result) + 1
+ cnab_idx = max(int(result.group(1)) for result in search_result) + 1
cnab_name = "{}({}){}".format(
- data, cnab_idx, ' - ' + filename if filename else '')
+ data, cnab_idx, " - " + filename if filename else ""
+ )
return cnab_name
@api.multi
def write(self, vals):
- if any(v in vals for v in ['data', 'filename']):
- data = vals.get('data') or self.data
- filename = vals.get('filename') or self.filename
+ if any(v in vals for v in ["data", "filename"]):
+ data = vals.get("data") or self.data
+ filename = vals.get("filename") or self.filename
name = self._get_name(data, filename)
- vals.update({'name': name})
+ vals.update({"name": name})
return super(L10nBrHrCnab, self).write(vals)
@api.model
def create(self, vals):
- name = self._get_name(vals.get('data'), vals.get('filename'))
- vals.update({'name': name})
+ name = self._get_name(vals.get("data"), vals.get("filename"))
+ vals.update({"name": name})
return super(L10nBrHrCnab, self).create(vals)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 5b3e62b6e79c..166e84a4034f 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -1,10 +1,11 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luiz Felipe do Divino Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import models, fields
+
+from odoo import fields, models
+
from .l10n_br_cnab import STATE
_logger = logging.getLogger(__name__)
@@ -14,113 +15,60 @@ class L10nBrCnabEvento(models.Model):
_name = "l10n_br.cnab.evento"
bank_payment_line_id = fields.Many2one(
- string="Bank Payment Line",
- comodel_name="bank.payment.line",
- )
- data_real_pagamento = fields.Date(
- string="Data do Crédito"
- )
- data_ocorrencia = fields.Date(
- string="Data da Ocorrência"
+ string="Bank Payment Line", comodel_name="bank.payment.line"
)
+ data_real_pagamento = fields.Date(string="Data do Crédito")
+ data_ocorrencia = fields.Date(string="Data da Ocorrência")
favorecido_conta_bancaria_id = fields.Many2one(
- string=u"Conta Bancária",
- comodel_name="res.partner.bank",
- )
- favorecido_id = fields.Many2one(
- string="Favorecido",
- comodel_name="res.partner"
+ string=u"Conta Bancária", comodel_name="res.partner.bank"
)
+ favorecido_id = fields.Many2one(string="Favorecido", comodel_name="res.partner")
identificacao_titulo_empresa = fields.Char(
- string="Identificação do Título da Empresa",
- required=False,
- )
- invoice_id = fields.Many2one(
- comodel_name='account.invoice',
- string='Fatura',
- )
- juros_mora_multa = fields.Float(
- string=u"Juros de Mora/Multa"
+ string="Identificação do Título da Empresa", required=False
)
+ invoice_id = fields.Many2one(comodel_name="account.invoice", string="Fatura")
+ juros_mora_multa = fields.Float(string=u"Juros de Mora/Multa")
lote_id = fields.Many2one(
- string="Lote",
- comodel_name="l10n_br.cnab.lote",
- ondelete='cascade',
- )
- nosso_numero = fields.Char(
- string=u"Nosso Número"
- )
- ocorrencias = fields.Char(
- string=u"Ocorrências"
- )
- outros_creditos = fields.Float(
- string=u"Outros Créditos"
- )
- partner_id = fields.Many2one(
- comodel_name='res.partner',
- string='Associado',
- )
- segmento = fields.Char(
- string="Segmento"
- )
- seu_numero = fields.Char(
- string=u"Seu Número"
- )
+ string="Lote", comodel_name="l10n_br.cnab.lote", ondelete="cascade"
+ )
+ nosso_numero = fields.Char(string=u"Nosso Número")
+ ocorrencias = fields.Char(string=u"Ocorrências")
+ outros_creditos = fields.Float(string=u"Outros Créditos")
+ partner_id = fields.Many2one(comodel_name="res.partner", string="Associado")
+ segmento = fields.Char(string="Segmento")
+ seu_numero = fields.Char(string=u"Seu Número")
state = fields.Selection(
- string="State",
- related="lote_id.state",
- selection=STATE,
- default="draft",
- )
- str_motiv_a = fields.Char(
- u'Motivo da ocorrência 01'
- )
- str_motiv_b = fields.Char(
- u'Motivo de ocorrência 02'
- )
- str_motiv_c = fields.Char(
- u'Motivo de ocorrência 03'
- )
- str_motiv_d = fields.Char(
- u'Motivo de ocorrência 04'
- )
- str_motiv_e = fields.Char(
- u'Motivo de ocorrência 05'
- )
- tipo_moeda = fields.Char(
- string=u"Tipo de Moeda"
- )
- tarifa_cobranca = fields.Float(
- string=u'Tarifa',
- )
- valor = fields.Float(
- string="Valor da Linha"
- )
+ string="State", related="lote_id.state", selection=STATE, default="draft"
+ )
+ str_motiv_a = fields.Char(u"Motivo da ocorrência 01")
+ str_motiv_b = fields.Char(u"Motivo de ocorrência 02")
+ str_motiv_c = fields.Char(u"Motivo de ocorrência 03")
+ str_motiv_d = fields.Char(u"Motivo de ocorrência 04")
+ str_motiv_e = fields.Char(u"Motivo de ocorrência 05")
+ tipo_moeda = fields.Char(string=u"Tipo de Moeda")
+ tarifa_cobranca = fields.Float(string=u"Tarifa")
+ valor = fields.Float(string="Valor da Linha")
valor_abatimento = fields.Float(
string="Valor do Abatimento",
- help="""Se o desconto ou abatimento é concedido na entrada do boleto
- estes campos são retornados zerados(apesar de corretamente registrados
+ help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ estes campos são retornados zerados(apesar de corretamente registrados
no Itaú). Se concedidos após a entrada, retornam com os valores
do desconto ou abatimento.
- Na liquidação, desconto e abatimento retornam somados no campo
- desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
- estes valores poderão retornar separados, conforme mostra o
- indicador 36.4 do Item 5 - Condições Personalizadas."""
+ Na liquidação, desconto e abatimento retornam somados no campo
+ desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
+ estes valores poderão retornar separados, conforme mostra o
+ indicador 36.4 do Item 5 - Condições Personalizadas.""",
)
valor_desconto = fields.Float(
string="Valor do Desconto",
- help="""Se o desconto ou abatimento é concedido na entrada do boleto
- estes campos são retornados zerados(apesar de corretamente registrados
+ help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ estes campos são retornados zerados(apesar de corretamente registrados
no Itaú). Se concedidos após a entrada, retornam com os valores
do desconto ou abatimento.
- Na liquidação, desconto e abatimento retornam somados no campo
- desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
- estes valores poderão retornar separados, conforme mostra o
- indicador 36.4 do Item 5 - Condições Personalizadas."""
- )
- valor_iof = fields.Float(
- string="Valor do IOF"
- )
- valor_pagamento = fields.Float(
- string="Valor do Pagamento"
+ Na liquidação, desconto e abatimento retornam somados no campo
+ desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
+ estes valores poderão retornar separados, conforme mostra o
+ indicador 36.4 do Item 5 - Condições Personalizadas.""",
)
+ valor_iof = fields.Float(string="Valor do IOF")
+ valor_pagamento = fields.Float(string="Valor do Pagamento")
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index f1e329440bff..5bacac9ef730 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -1,11 +1,13 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luiz Felipe do Divino Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
-from odoo import models, fields
+
+from odoo import fields, models
+
from .l10n_br_cnab import STATE
+
_logger = logging.getLogger(__name__)
@@ -14,43 +16,21 @@ class L10nBrCnabLote(models.Model):
_name = "l10n_br.cnab.lote"
account_bank_id = fields.Many2one(
- string=u"Conta Bancária",
- comodel_name="res.partner.bank",
+ string=u"Conta Bancária", comodel_name="res.partner.bank"
)
cnab_id = fields.Many2one(
- string="CNAB",
- comodel_name="l10n_br.cnab",
- ondelete='cascade',
- )
- empresa_inscricao_numero = fields.Char(
- string=u"Número de Inscrição"
- )
- empresa_inscricao_tipo = fields.Char(
- string=u"Tipo de Inscrição"
+ string="CNAB", comodel_name="l10n_br.cnab", ondelete="cascade"
)
+ empresa_inscricao_numero = fields.Char(string=u"Número de Inscrição")
+ empresa_inscricao_tipo = fields.Char(string=u"Tipo de Inscrição")
evento_id = fields.One2many(
- string="Eventos",
- comodel_name="l10n_br.cnab.evento",
- inverse_name="lote_id",
- )
- mensagem = fields.Char(
- string="Mensagem"
- )
- qtd_registros = fields.Integer(
- string="Quantidade de Registros"
- )
- servico_operacao = fields.Char(
- string=u"Tipo de Operação"
+ string="Eventos", comodel_name="l10n_br.cnab.evento", inverse_name="lote_id"
)
+ mensagem = fields.Char(string="Mensagem")
+ qtd_registros = fields.Integer(string="Quantidade de Registros")
+ servico_operacao = fields.Char(string=u"Tipo de Operação")
state = fields.Selection(
- string="State",
- related="cnab_id.state",
- selection=STATE,
- default="draft",
- )
- tipo_servico = fields.Char(
- string=u"Tipo do Serviço"
- )
- total_valores = fields.Float(
- string="Valor Total"
+ string="State", related="cnab_id.state", selection=STATE, default="draft"
)
+ tipo_servico = fields.Char(string=u"Tipo do Serviço")
+ total_valores = fields.Float(string="Valor Total")
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index 24c776888918..83f40b841c65 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -1,69 +1,50 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, models, fields
+from odoo import api, fields, models
-from ..constantes import (
- SEQUENCIAL_EMPRESA, SEQUENCIAL_FATURA, SEQUENCIAL_CARTEIRA
-)
+from ..constantes import (SEQUENCIAL_CARTEIRA, SEQUENCIAL_EMPRESA,
+ SEQUENCIAL_FATURA)
class ResCompany(models.Model):
- _inherit = 'res.company'
+ _inherit = "res.company"
own_number_type = fields.Selection(
selection=[
- (SEQUENCIAL_EMPRESA, u'Sequêncial único por empresa'),
- (SEQUENCIAL_FATURA, u'Numero sequêncial da Fatura'),
- (SEQUENCIAL_CARTEIRA, u'Sequêncial único por carteira'), ],
- string=u'Tipo de nosso número',
- default='2'
+ (SEQUENCIAL_EMPRESA, u"Sequêncial único por empresa"),
+ (SEQUENCIAL_FATURA, u"Numero sequêncial da Fatura"),
+ (SEQUENCIAL_CARTEIRA, u"Sequêncial único por carteira"),
+ ],
+ string=u"Tipo de nosso número",
+ default="2",
)
own_number_sequence = fields.Many2one(
- comodel_name='ir.sequence',
- string=u'Sequência do Nosso Número'
+ comodel_name="ir.sequence", string=u"Sequência do Nosso Número"
)
environment = fields.Selection(
- string=u'Ambiente',
- selection=[
- ('1', 'HOMOLOGAÇÃO'),
- ('2', 'PRODUÇÃO'),
- ],
- default='1',
+ string=u"Ambiente",
+ selection=[("1", "HOMOLOGAÇÃO"), ("2", "PRODUÇÃO")],
+ default="1",
)
- client_id = fields.Char(
- string=u'ID do Cliente',
- )
+ client_id = fields.Char(string=u"ID do Cliente")
- client_secret = fields.Char(
- string=u'Segredo',
- )
+ client_secret = fields.Char(string=u"Segredo")
- itau_key = fields.Char(
- string=u'Chave',
- )
+ itau_key = fields.Char(string=u"Chave")
- api_endpoint = fields.Char(
- string=u'API ENDPOINT',
- )
+ api_endpoint = fields.Char(string=u"API ENDPOINT")
- raiz_endpoint = fields.Char(
- string=u'RAIZ ENDPOINT',
- )
+ raiz_endpoint = fields.Char(string=u"RAIZ ENDPOINT")
- api_itau_token = fields.Char(
- string=u'Itaú API Token',
- readonly=True,
- )
+ api_itau_token = fields.Char(string=u"Itaú API Token", readonly=True)
api_itau_token_due_datetime = fields.Datetime(
- string=u'Validade do Token',
- readonly=True,
+ string=u"Validade do Token", readonly=True
)
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/res_partner.py b/l10n_br_account_payment_cobranca/models/res_partner.py
index c738ed64b3f4..443e31f696c2 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner.py
@@ -1,14 +1,11 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, fields
+from odoo import fields, models
class ResPartner(models.Model):
- _inherit = 'res.partner'
+ _inherit = "res.partner"
- type = fields.Selection(selection_add=[
- ('cnab_cobranca', u'Cobrança CNAB'),
- ])
+ type = fields.Selection(selection_add=[("cnab_cobranca", u"Cobrança CNAB")])
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
index 89a431b8b07d..70280ee257b6 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner_bank.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
@@ -1,37 +1,34 @@
-# -*- coding: utf-8 -*-
# Copyright 2012 KMEE - Fernando Marcato Rodrigues
# Copyright 2017 KMEE - Hendrix Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, fields
+from odoo import fields, models
class ResPartnerBank(models.Model):
""" Adiciona campos necessários para o cadastramentos de contas
bancárias no Brasil."""
- _inherit = 'res.partner.bank'
+
+ _inherit = "res.partner.bank"
codigo_da_empresa = fields.Integer(
- u'Código da empresa',
+ u"Código da empresa",
size=20,
help=u"Será informado pelo banco depois do cadastro do beneficiário "
- u"na agência"
+ u"na agência",
)
tipo_de_conta = fields.Selection(
selection=[
- ('01', u'Conta corrente individual'),
- ('02', u'Conta poupança individual'),
- ('03', u'Conta depósito judicial/Depósito em consignação '
- u'individual'),
- ('11', u'Conta corrente conjunta'),
- ('12', u'Conta poupança conjunta'),
- ('13', u'Conta depósito judicial/Depósito em consignação '
- u'conjunta')],
- string=u'Tipo de Conta',
- default='01'
+ ("01", u"Conta corrente individual"),
+ ("02", u"Conta poupança individual"),
+ ("03", u"Conta depósito judicial/Depósito em consignação " u"individual"),
+ ("11", u"Conta corrente conjunta"),
+ ("12", u"Conta poupança conjunta"),
+ ("13", u"Conta depósito judicial/Depósito em consignação " u"conjunta"),
+ ],
+ string=u"Tipo de Conta",
+ default="01",
)
- bra_number = fields.Char(
- size=5,
- )
+ bra_number = fields.Char(size=5)
diff --git a/l10n_br_account_payment_cobranca/reports/__init__.py b/l10n_br_account_payment_cobranca/reports/__init__.py
index 6e8d5f05a099..75f46ebc3d19 100644
--- a/l10n_br_account_payment_cobranca/reports/__init__.py
+++ b/l10n_br_account_payment_cobranca/reports/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index 7141da4ae397..1b3d05745418 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -1,9 +1,7 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from __future__ import with_statement
from odoo.api import Environment
from odoo.report.interface import report_int
@@ -11,11 +9,10 @@
class ExternalPdf(render):
-
def __init__(self, pdf):
render.__init__(self)
self.pdf = pdf
- self.output_type = 'pdf'
+ self.output_type = "pdf"
def _render(self):
return self.pdf
@@ -32,18 +29,18 @@ def create(self, cr, uid, ids, datas, context=False):
env = Environment(cr, uid, {})
- active_ids = context.get('active_ids')
- active_model = context.get('active_model')
+ active_ids = context.get("active_ids")
+ active_model = context.get("active_model")
ids_move_lines = []
- if active_model == 'account.invoice':
- for invoices in env['account.invoice'].browse(active_ids):
- receivable_ids = invoices.mapped('move_line_receivable_id')
+ if active_model == "account.invoice":
+ for invoices in env["account.invoice"].browse(active_ids):
+ receivable_ids = invoices.mapped("move_line_receivable_id")
if receivable_ids:
ids_move_lines = receivable_ids
- elif active_model == 'account.move.line':
- ids_move_lines = env['account.move.line'].browse(active_ids)
+ elif active_model == "account.move.line":
+ ids_move_lines = env["account.move.line"].browse(active_ids)
if not ids_move_lines:
return False
@@ -51,7 +48,7 @@ def create(self, cr, uid, ids, datas, context=False):
pdf_string = ids_move_lines.generate_boleto()
self.obj = ExternalPdf(pdf_string)
self.obj.render()
- return self.obj.pdf, 'pdf'
+ return self.obj.pdf, "pdf"
-ReportCustom('report.l10n_br_account_payment_boleto.report')
+ReportCustom("report.l10n_br_account_payment_boleto.report")
diff --git a/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml b/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
index 6ab8f352211d..8265fa33db05 100644
--- a/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
+++ b/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
@@ -8,4 +8,4 @@
name="l10n_br_account_payment_boleto.report"
model="account.invoice"
string="Boleto"/>
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
index b9064447c86f..4ac02592c50e 100644
--- a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
+++ b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
@@ -7,4 +7,4 @@
ref="base.module_category_accounting_and_finance"/>
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/tests/test_remessa.REM b/l10n_br_account_payment_cobranca/tests/test_remessa.REM
index 6d4ba831f212..98e34ca146f4 100644
--- a/l10n_br_account_payment_cobranca/tests/test_remessa.REM
+++ b/l10n_br_account_payment_cobranca/tests/test_remessa.REM
@@ -1,6 +1,6 @@
-23100000 281583054000129 01611000000000039500Sua Empresa BANCO BRADESCO S.A. 11303201712000000000108400000
-23100011R01 042 2081583054000129 01611000000000039500Sua Empresa 000001011303201700000000
-2310001300001P 01016110000000000395000000000000000000000030 0 001 0503201700000000010000000000 01A130320170050320170000000000000000000000000000000000000000000000000000000000000000000001 00020 000000000000
-2310001300002Q 012081493979000189Cliente 1 SP Rua Samuel Morse 135 Brooklin 04576060Sao Paulo SP0000000000000000 000
-23100015 00000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000
-23199999 000001000006000000
+23100000 281583054000129 01611000000000039500Sua Empresa BANCO BRADESCO S.A. 11303201712000000000108400000
+23100011R01 042 2081583054000129 01611000000000039500Sua Empresa 000001011303201700000000
+2310001300001P 01016110000000000395000000000000000000000030 0 001 0503201700000000010000000000 01A130320170050320170000000000000000000000000000000000000000000000000000000000000000000001 00020 000000000000
+2310001300002Q 012081493979000189Cliente 1 SP Rua Samuel Morse 135 Brooklin 04576060Sao Paulo SP0000000000000000 000
+23100015 00000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000
+23199999 000001000006000000
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
index dab2602d8930..d832b59bf956 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -26,4 +26,4 @@
-
\ No newline at end of file
+
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_cobranca/wizard/__init__.py
index 9740fbe3f316..a6fa4dddced1 100644
--- a/l10n_br_account_payment_cobranca/wizard/__init__.py
+++ b/l10n_br_account_payment_cobranca/wizard/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# @author Daniel Sadamo
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 7b02dcf6fce7..482dbe173bae 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# © 2012 KMEE INFORMATICA LTDA
# @author Luis Felipe Mileo
# @author Daniel Sadamo
@@ -6,19 +5,17 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models, api, fields
+from odoo import api, fields, models
class AccountPaymentLineCreate(models.TransientModel):
- _inherit = 'account.payment.line.create'
+ _inherit = "account.payment.line.create"
allow_error = fields.Boolean(
string=u"Permitir linhas com erro na exportação, "
- u"já incluidas em outras ordens"
- )
- allow_rejected = fields.Boolean(
- string="Permitir linhas com retorno rejeitado"
+ u"já incluidas em outras ordens"
)
+ allow_rejected = fields.Boolean(string="Permitir linhas com retorno rejeitado")
@api.multi
def _prepare_move_line_domain(self):
@@ -30,36 +27,41 @@ def _prepare_move_line_domain(self):
# TODO: Refactory this to call super!
self.ensure_one()
- domain = [('reconciled', '=', False),
- ('company_id', '=', self.order_id.company_id.id)]
+ domain = [
+ ("reconciled", "=", False),
+ ("company_id", "=", self.order_id.company_id.id),
+ ]
if self.journal_ids:
- domain += [('journal_id', 'in', self.journal_ids.ids)]
+ domain += [("journal_id", "in", self.journal_ids.ids)]
if self.partner_ids:
- domain += [('partner_id', 'in', self.partner_ids.ids)]
- if self.target_move == 'posted':
- domain += [('move_id.state', '=', 'posted')]
+ domain += [("partner_id", "in", self.partner_ids.ids)]
+ if self.target_move == "posted":
+ domain += [("move_id.state", "=", "posted")]
if not self.allow_blocked:
- domain += [('blocked', '!=', True)]
- if self.date_type == 'due':
+ domain += [("blocked", "!=", True)]
+ if self.date_type == "due":
domain += [
- '|',
- ('date_maturity', '<=', self.due_date),
- ('date_maturity', '=', False)]
- elif self.date_type == 'move':
- domain.append(('date', '<=', self.move_date))
+ "|",
+ ("date_maturity", "<=", self.due_date),
+ ("date_maturity", "=", False),
+ ]
+ elif self.date_type == "move":
+ domain.append(("date", "<=", self.move_date))
if self.invoice:
- domain.append(('invoice_id', '!=', False))
+ domain.append(("invoice_id", "!=", False))
if self.payment_mode:
- if self.payment_mode == 'same':
+ if self.payment_mode == "same":
domain.append(
- ('payment_mode_id', '=', self.order_id.payment_mode_id.id))
- elif self.payment_mode == 'same_or_null':
+ ("payment_mode_id", "=", self.order_id.payment_mode_id.id)
+ )
+ elif self.payment_mode == "same_or_null":
domain += [
- '|',
- ('payment_mode_id', '=', False),
- ('payment_mode_id', '=', self.order_id.payment_mode_id.id)]
+ "|",
+ ("payment_mode_id", "=", False),
+ ("payment_mode_id", "=", self.order_id.payment_mode_id.id),
+ ]
- if self.order_id.payment_type == 'outbound':
+ if self.order_id.payment_type == "outbound":
# For payables, propose all unreconciled credit lines,
# including partially reconciled ones.
# If they are partially reconciled with a supplier refund,
@@ -71,38 +73,37 @@ def _prepare_move_line_domain(self):
# as they are deducted from a customer invoice, and
# will not be refunded with a payment.
domain += [
- ('credit', '>', 0),
+ ("credit", ">", 0),
# '|',
- ('account_id.internal_type', '=', 'payable'),
+ ("account_id.internal_type", "=", "payable"),
# '&',
# ('account_id.internal_type', '=', 'receivable'),
# ('reconcile_partial_id', '=', False), # TODO uncomment
]
- elif self.order_id.payment_type == 'inbound':
+ elif self.order_id.payment_type == "inbound":
domain += [
- ('debit', '>', 0),
- ('account_id.internal_type', '=', 'receivable'),
+ ("debit", ">", 0),
+ ("account_id.internal_type", "=", "receivable"),
]
# Exclude lines that are already in a non-cancelled
# and non-uploaded payment order; lines that are in a
# uploaded payment order are proposed if they are not reconciled,
- paylines = self.env['account.payment.line'].search([
- ('state', 'in', ('draft', 'open', 'generated', 'uploaded')),
- ('move_line_id', '!=', False)])
+ paylines = self.env["account.payment.line"].search(
+ [
+ ("state", "in", ("draft", "open", "generated", "uploaded")),
+ ("move_line_id", "!=", False),
+ ]
+ )
- move_line_domain = ['draft']
+ move_line_domain = ["draft"]
if self.allow_error:
- move_line_domain.append('exporting_error')
+ move_line_domain.append("exporting_error")
if self.allow_rejected:
- move_line_domain.append('not_accepted')
+ move_line_domain.append("not_accepted")
- domain += [
- ('bank_payment_line_id', '=', False),
- ]
+ domain += [("bank_payment_line_id", "=", False)]
- domain += [
- ('state_cnab', 'in', move_line_domain),
- ]
+ domain += [("state_cnab", "in", move_line_domain)]
# if paylines:
# move_lines_ids = [
From 71862fb4d0b2317baba9ca4d3c780517e05487c8 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 19 Dec 2019 10:40:21 -0300
Subject: [PATCH 180/612] [IMP] black, isort
---
.../models/account_move_line.py | 14 +++++++-------
.../models/account_payment_mode.py | 19 ++++++++++---------
.../models/res_partner_bank.py | 18 ++++++++++--------
.../readme/CONTRIBUTORS.rst | 1 -
.../readme/CREDITS.rst | 4 ++++
.../readme/HISTORY.rst | 2 +-
6 files changed, 32 insertions(+), 26 deletions(-)
create mode 100644 l10n_br_account_payment_order/readme/CREDITS.rst
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 737c890bb073..143949a6b026 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -2,15 +2,15 @@
# Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, fields, api
+from odoo import api, fields, models
class AccountMoveLine(models.Model):
- _inherit = 'account.move.line'
+ _inherit = "account.move.line"
- date_scheduled = fields.Date(string='Data Prevista')
+ date_scheduled = fields.Date(string="Data Prevista")
- @api.depends('move_id')
+ @api.depends("move_id")
def _compute_journal_entry_ref(self):
for record in self:
if record.name:
@@ -20,11 +20,11 @@ def _compute_journal_entry_ref(self):
elif record.invoice_id and record.invoice_id.number:
record.journal_entry_ref = record.invoice_id.number
else:
- record.journal_entry_ref = '*' + str(record.move_id.id)
+ record.journal_entry_ref = "*" + str(record.move_id.id)
journal_entry_ref = fields.Char(
- compute='_compute_journal_entry_ref',
- string='Journal Entry Ref', store=True)
+ compute="_compute_journal_entry_ref", string="Journal Entry Ref", store=True
+ )
@api.multi
def get_balance(self):
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 15889cb7b52a..928076066422 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -2,7 +2,7 @@
# @author Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, fields
+from odoo import fields, models
OPERATION_TYPE = [
('1', 'Pagamento'),
@@ -11,12 +11,11 @@
class AccountPaymentMode(models.Model):
- _inherit = 'account.payment.mode'
+ _inherit = "account.payment.mode"
- internal_sequence_id = fields.Many2one('ir.sequence', 'Sequência')
- instrucoes = fields.Text('Instruções de cobrança')
- invoice_print = fields.Boolean(
- 'Gerar relatorio na conclusão da fatura?')
+ internal_sequence_id = fields.Many2one("ir.sequence", "Sequência")
+ instrucoes = fields.Text("Instruções de cobrança")
+ invoice_print = fields.Boolean("Gerar relatorio na conclusão da fatura?")
operation_type = fields.Selection(
selection=OPERATION_TYPE,
@@ -24,7 +23,9 @@ class AccountPaymentMode(models.Model):
)
_sql_constraints = [
- ('internal_sequence_id_unique',
- 'unique(internal_sequence_id)',
- 'Sequência já usada! Crie uma sequência unica para cada modo')
+ (
+ "internal_sequence_id_unique",
+ "unique(internal_sequence_id)",
+ "Sequência já usada! Crie uma sequência unica para cada modo",
+ )
]
diff --git a/l10n_br_account_payment_order/models/res_partner_bank.py b/l10n_br_account_payment_order/models/res_partner_bank.py
index 5c275ba410aa..87d7b594726d 100644
--- a/l10n_br_account_payment_order/models/res_partner_bank.py
+++ b/l10n_br_account_payment_order/models/res_partner_bank.py
@@ -2,20 +2,22 @@
# Magno Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-from odoo import models, api, _
+from odoo import _, api, models
from odoo.exceptions import Warning as UserError
class ResPartnerBank(models.Model):
- _inherit = 'res.partner.bank'
+ _inherit = "res.partner.bank"
@api.multi
- @api.constrains('bra_number')
+ @api.constrains("bra_number")
def check_bra_number(self):
for record in self:
- if record.bank_id.code_bc == '033':
+ if record.bank_id.code_bc == "033":
if len(record.bra_number) > 4:
- raise UserError(_(
- u'O cógido da Agencia Bancaria do Santander'
- u' deve ter no máximo quatro caracteres.'
- ))
+ raise UserError(
+ _(
+ u"O cógido da Agencia Bancaria do Santander"
+ u" deve ter no máximo quatro caracteres."
+ )
+ )
diff --git a/l10n_br_account_payment_order/readme/CONTRIBUTORS.rst b/l10n_br_account_payment_order/readme/CONTRIBUTORS.rst
index 87a88f53e92c..15e157d0dc85 100644
--- a/l10n_br_account_payment_order/readme/CONTRIBUTORS.rst
+++ b/l10n_br_account_payment_order/readme/CONTRIBUTORS.rst
@@ -2,4 +2,3 @@
* Fernando Marcato
* Hendrix Costa
* Magno Costa
-
diff --git a/l10n_br_account_payment_order/readme/CREDITS.rst b/l10n_br_account_payment_order/readme/CREDITS.rst
new file mode 100644
index 000000000000..a9acbd0203b2
--- /dev/null
+++ b/l10n_br_account_payment_order/readme/CREDITS.rst
@@ -0,0 +1,4 @@
+The development of this module has been financially supported by:
+
+* KMEE INFORMATICA LTDA - www.kmee.com.br
+* AKRETION LTDA - www.akretion.com
diff --git a/l10n_br_account_payment_order/readme/HISTORY.rst b/l10n_br_account_payment_order/readme/HISTORY.rst
index f9edf64f0b04..495eb888ddb3 100644
--- a/l10n_br_account_payment_order/readme/HISTORY.rst
+++ b/l10n_br_account_payment_order/readme/HISTORY.rst
@@ -27,4 +27,4 @@
12.0.1.0.0 (2019-06-06)
~~~~~~~~~~~~~~~~~~~~~~~
-* [MIG] Migração para a versão 12.0.
\ No newline at end of file
+* [MIG] Migração para a versão 12.0.
From 74eec29534f587ee70ba1c4bed2ffcdc362da0f2 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Thu, 19 Dec 2019 16:12:25 -0300
Subject: [PATCH 181/612] [REM] openerp from .isort.cfg file
---
.isort.cfg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.isort.cfg b/.isort.cfg
index 08469fcdb7ab..d89a563f407f 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,2 +1,2 @@
[settings]
-known_third_party = OpenSSL,dateutil,erpbrasil,lxml,odoo,openupgradelib,requests,setuptools
+known_third_party = OpenSSL,dateutil,erpbrasil,lxml,odoo,pytz,requests,setuptools,workalendar
From 0572a3db399ab45e2ba947fc32db91d6a51e8e48 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Thu, 19 Dec 2019 16:12:54 -0300
Subject: [PATCH 182/612] [MIG] Bump version to 12.0.1.0.0
---
l10n_br_account_payment_cobranca/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 594584835762..57f6d0bc5f58 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -7,7 +7,7 @@
{
"name": "Account Payment CNAB",
- "version": "10.0.1.0.0",
+ "version": "12.0.1.0.0",
"category": "Banking addons",
"license": "AGPL-3",
"author": "KMEE, Odoo Community Association (OCA)",
From 9ceabb9b62799bd759c5e6bfdb00bbcbef4dee8d Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 Jan 2020 17:42:57 -0300
Subject: [PATCH 183/612] [FIX] Typo
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_order/views/account_payment_mode.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 41df40ee268b..31ce39e1e7aa 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -2,7 +2,7 @@
-
+
payment.mode.l10n_br_payment.form.inherit
account.payment.mode
From bb61aec31dcf2d7185cc94d33733aa81c97a743c Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 30 Jan 2020 17:43:11 -0300
Subject: [PATCH 184/612] [MIG] Make module installable
Signed-off-by: Luis Felipe Mileo
---
.../constantes.py | 512 +++++++++---------
.../data/ir_cron.xml | 20 +-
.../models/account_invoice.py | 44 +-
.../models/account_move_line.py | 34 +-
.../models/account_payment_line.py | 36 +-
.../models/account_payment_mode.py | 88 +--
.../models/account_payment_order.py | 3 +-
.../models/bank_payment_line.py | 48 +-
.../models/l10n_br_cnab.py | 24 +-
.../models/l10n_br_cnab_evento.py | 26 +-
.../models/l10n_br_cnab_lote.py | 10 +-
.../models/res_company.py | 26 +-
.../models/res_partner.py | 2 +-
.../models/res_partner_bank.py | 20 +-
.../reports/report.py | 100 ++--
.../views/account_invoice.xml | 146 ++---
.../views/account_payment_mode.xml | 2 +-
.../views/bank_api_operation_views.xml | 106 ++--
.../views/l10n_br_cnab_evento_views.xml | 84 +--
.../views/l10n_br_cnab_retorno_view.xml | 24 +-
.../views/res_company.xml | 60 +-
.../wizard/payment_order_create.py | 4 +-
22 files changed, 709 insertions(+), 710 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 2d4340c7ae2c..d13a26370513 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -42,117 +42,117 @@
PAGAMENTOS_DIVERSOS = "98"
TIPO_SERVICO = [
- (COBRANCA, COBRANCA + u" - Cobrança"),
+ (COBRANCA, COBRANCA + " - Cobrança"),
(
BOLETO_PAGAMENTO_ELETRONICO,
- BOLETO_PAGAMENTO_ELETRONICO + u" - Boleto de Pagamento Eletrônico",
+ BOLETO_PAGAMENTO_ELETRONICO + " - Boleto de Pagamento Eletrônico",
),
- (CONCILIACAO_BANCARIA, CONCILIACAO_BANCARIA + u" - Conciliação Bancária"),
- (DEBITOS, DEBITOS + u" - Débitos"),
- (CUSTODIA_CHEQUES, CUSTODIA_CHEQUES + u" - Custódia de Cheques"),
- (GESTAO_CAIXA, GESTAO_CAIXA + u" - Gestão de Caixa"),
+ (CONCILIACAO_BANCARIA, CONCILIACAO_BANCARIA + " - Conciliação Bancária"),
+ (DEBITOS, DEBITOS + " - Débitos"),
+ (CUSTODIA_CHEQUES, CUSTODIA_CHEQUES + " - Custódia de Cheques"),
+ (GESTAO_CAIXA, GESTAO_CAIXA + " - Gestão de Caixa"),
(
CONSULTA_INFORMACAO_MARGEM,
- CONSULTA_INFORMACAO_MARGEM + u" - Consulta/Informação Margem",
+ CONSULTA_INFORMACAO_MARGEM + " - Consulta/Informação Margem",
),
(
AVERBACAO_CONSIGNACAO_RETENCAO,
- AVERBACAO_CONSIGNACAO_RETENCAO + u" - Averbação da Consignação/Retenção",
+ AVERBACAO_CONSIGNACAO_RETENCAO + " - Averbação da Consignação/Retenção",
),
- (PAGAMENTO_DIVIDENDOS, PAGAMENTO_DIVIDENDOS + u" - Pagamento Dividendos"),
- (MANUTENCAO_CONSIGNACAO, MANUTENCAO_CONSIGNACAO + u" - Manutenção da Consignação"),
- (CONSIGNACAO_PARCELAS, CONSIGNACAO_PARCELAS + u" - Consignação de Parcelas"),
- (GLOSA_CONSIGNACAO, GLOSA_CONSIGNACAO + u" - Glosa da Consignação (INSS)"),
+ (PAGAMENTO_DIVIDENDOS, PAGAMENTO_DIVIDENDOS + " - Pagamento Dividendos"),
+ (MANUTENCAO_CONSIGNACAO, MANUTENCAO_CONSIGNACAO + " - Manutenção da Consignação"),
+ (CONSIGNACAO_PARCELAS, CONSIGNACAO_PARCELAS + " - Consignação de Parcelas"),
+ (GLOSA_CONSIGNACAO, GLOSA_CONSIGNACAO + " - Glosa da Consignação (INSS)"),
(
CONSULTA_TRIBUTOS_PAGAR,
- CONSULTA_TRIBUTOS_PAGAR + u" - Consulta de Tributos a pagar",
+ CONSULTA_TRIBUTOS_PAGAR + " - Consulta de Tributos a pagar",
),
- (PAGAMENTO_FORNECEDOR, PAGAMENTO_FORNECEDOR + u" - Pagamento Fornecedor"),
+ (PAGAMENTO_FORNECEDOR, PAGAMENTO_FORNECEDOR + " - Pagamento Fornecedor"),
(
PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS,
PAGAMENTO_CONTAS_TRIBUTOS_IMPOSTOS
- + u" - Pagamento de Contas, Tributos e Impostos",
+ + " - Pagamento de Contas, Tributos e Impostos",
),
(
INTEROPERABILIDADE_CONTAS,
INTEROPERABILIDADE_CONTAS
- + u" - Interoperabilidade entre Contas de Instituições de Pagamentos",
+ + " - Interoperabilidade entre Contas de Instituições de Pagamentos",
),
- (COMPROR, COMPROR + u" - Compror"),
- (COMPROR_ROTATIVO, COMPROR_ROTATIVO + u" - Compror Rotativo"),
- (ALEGACAO_PAGADOR, ALEGACAO_PAGADOR + u" - Alegação do Pagador"),
- (PAGAMENTO_SALARIOS, PAGAMENTO_SALARIOS + u" - Pagamento Salários"),
- (PAGAMENTO_HONORARIOS, PAGAMENTO_HONORARIOS + u" - Pagamento de honorários"),
+ (COMPROR, COMPROR + " - Compror"),
+ (COMPROR_ROTATIVO, COMPROR_ROTATIVO + " - Compror Rotativo"),
+ (ALEGACAO_PAGADOR, ALEGACAO_PAGADOR + " - Alegação do Pagador"),
+ (PAGAMENTO_SALARIOS, PAGAMENTO_SALARIOS + " - Pagamento Salários"),
+ (PAGAMENTO_HONORARIOS, PAGAMENTO_HONORARIOS + " - Pagamento de honorários"),
(
PAGAMENTO_BOLSA_AUXILIO,
- PAGAMENTO_BOLSA_AUXILIO + u" - Pagamento de bolsa auxílio",
+ PAGAMENTO_BOLSA_AUXILIO + " - Pagamento de bolsa auxílio",
),
(
PAGAMENTO_PREBENDA,
PAGAMENTO_PREBENDA
- + u" - Pagamento de prebenda (remuneração a padres e sacerdotes)",
+ + " - Pagamento de prebenda (remuneração a padres e sacerdotes)",
),
- (VENDOR, VENDOR + u" - Vendor"),
- (VENDOR_TERMO, VENDOR_TERMO + u" - Vendor a Termo"),
+ (VENDOR, VENDOR + " - Vendor"),
+ (VENDOR_TERMO, VENDOR_TERMO + " - Vendor a Termo"),
(
PAGAMENTO_SINISTROS_SEGURADOS,
- PAGAMENTO_SINISTROS_SEGURADOS + u" - Pagamento Sinistros Segurados",
+ PAGAMENTO_SINISTROS_SEGURADOS + " - Pagamento Sinistros Segurados",
),
(
PAGAMENTO_DESPESAS_VIAJANTE,
- PAGAMENTO_DESPESAS_VIAJANTE + u" - Pagamento Despesas Viajante em Trânsito",
+ PAGAMENTO_DESPESAS_VIAJANTE + " - Pagamento Despesas Viajante em Trânsito",
),
- (PAGAMENTO_AUTORIZADO, PAGAMENTO_AUTORIZADO + u" - Pagamento Autorizado"),
- (PAGAMENTO_CREDENCIADOS, PAGAMENTO_CREDENCIADOS + u" - Pagamento Credenciados"),
- (PAGAMENTO_REMUNERACAO, PAGAMENTO_REMUNERACAO + u" - Pagamento de Remuneração"),
+ (PAGAMENTO_AUTORIZADO, PAGAMENTO_AUTORIZADO + " - Pagamento Autorizado"),
+ (PAGAMENTO_CREDENCIADOS, PAGAMENTO_CREDENCIADOS + " - Pagamento Credenciados"),
+ (PAGAMENTO_REMUNERACAO, PAGAMENTO_REMUNERACAO + " - Pagamento de Remuneração"),
(
PAGAMENTO_REPRESENTANTES,
PAGAMENTO_REPRESENTANTES
- + u" - Pagamento Representantes / Vendedores Autorizados",
+ + " - Pagamento Representantes / Vendedores Autorizados",
),
- (PAGAMENTO_BENEFICIOS, PAGAMENTO_BENEFICIOS + u" - Pagamento Benefícios"),
- (PAGAMENTOS_DIVERSOS, PAGAMENTOS_DIVERSOS + u" - Pagamentos Diversos"),
+ (PAGAMENTO_BENEFICIOS, PAGAMENTO_BENEFICIOS + " - Pagamento Benefícios"),
+ (PAGAMENTOS_DIVERSOS, PAGAMENTOS_DIVERSOS + " - Pagamentos Diversos"),
]
-CREDITO_CONTA_CORRENTE_SALARIO = ("01", u"01 - Crédito em Conta Corrente/Salário")
-CHEQUE_PAGAMENTO_ADMINISTRATIVO = ("02", u"02 - Cheque Pagamento / Administrativo")
-DOC_TED = ("03", u"03 - DOC/TED (1) (2)")
-CARTAO_SALARIO = ("04", u"04 - Cartão Salário (somente para Tipo de Serviço = '30')")
-CREDITO_CONTA_POUPANCA = ("05", u"05 - Crédito em Conta Poupança")
-OP_A_DISPOSICAO = ("10", u"10 - OP à Disposição")
+CREDITO_CONTA_CORRENTE_SALARIO = ("01", "01 - Crédito em Conta Corrente/Salário")
+CHEQUE_PAGAMENTO_ADMINISTRATIVO = ("02", "02 - Cheque Pagamento / Administrativo")
+DOC_TED = ("03", "03 - DOC/TED (1) (2)")
+CARTAO_SALARIO = ("04", "04 - Cartão Salário (somente para Tipo de Serviço = '30')")
+CREDITO_CONTA_POUPANCA = ("05", "05 - Crédito em Conta Poupança")
+OP_A_DISPOSICAO = ("10", "10 - OP à Disposição")
PAGAMENTO_CONTAS_TRIBUTOS_CODIGO_BARRAS = (
"11",
- u"11 - Pagamento de Contas e Tributos com Código de Barras",
+ "11 - Pagamento de Contas e Tributos com Código de Barras",
)
-TRIBUTO_DARF_NORMAL = ("16", u"16 - Tributo - DARF Normal")
-TRIBUTO_GPS = ("17", u"17 - Tributo - GPS (Guia da Previdência Social)")
-TRIBUTO_DARF_SIMPLES = ("18", u"18 - Tributo - DARF Simples")
-TRIBUTO_IPTU_PREFEITURAS = ("19", u"19 - Tributo - IPTU – Prefeituras")
-PAGAMENTO_AUTENTICACAO = ("20", u"20 - Pagamento com Autenticação")
-TRIBUTO_DARJ = ("21", u"21 - Tributo – DARJ")
-TRIBUTO_GARE_SP_ICMS = ("22", u"22 - Tributo - GARE-SP ICMS")
-TRIBUTO_GARE_SP_DR = ("23", u"23 - Tributo - GARE-SP DR")
-TRIBUTO_GARE_SP_ITCMD = ("24", u"24 - Tributo - GARE-SP ITCMD")
-TRIBUTO_IPVA = ("25", u"25 - Tributo - IPVA")
-TRIBUTO_LICENCIAMENTO = ("26", u"26 - Tributo - Licenciamento")
-TRIBUTO_DPVAT = ("27", u"27 - Tributo – DPVAT")
+TRIBUTO_DARF_NORMAL = ("16", "16 - Tributo - DARF Normal")
+TRIBUTO_GPS = ("17", "17 - Tributo - GPS (Guia da Previdência Social)")
+TRIBUTO_DARF_SIMPLES = ("18", "18 - Tributo - DARF Simples")
+TRIBUTO_IPTU_PREFEITURAS = ("19", "19 - Tributo - IPTU – Prefeituras")
+PAGAMENTO_AUTENTICACAO = ("20", "20 - Pagamento com Autenticação")
+TRIBUTO_DARJ = ("21", "21 - Tributo – DARJ")
+TRIBUTO_GARE_SP_ICMS = ("22", "22 - Tributo - GARE-SP ICMS")
+TRIBUTO_GARE_SP_DR = ("23", "23 - Tributo - GARE-SP DR")
+TRIBUTO_GARE_SP_ITCMD = ("24", "24 - Tributo - GARE-SP ITCMD")
+TRIBUTO_IPVA = ("25", "25 - Tributo - IPVA")
+TRIBUTO_LICENCIAMENTO = ("26", "26 - Tributo - Licenciamento")
+TRIBUTO_DPVAT = ("27", "27 - Tributo – DPVAT")
LIQUIDACAO_TITULOS_PROPRIO_BANCO = (
"30",
- u"30 - Liquidação de Títulos do Próprio Banco",
+ "30 - Liquidação de Títulos do Próprio Banco",
)
-PAGAMENTO_TITULOS_OUTROS_BANCOS = ("31", u"31 - Pagamento de Títulos de Outros Bancos")
-EXTRATO_CONTA_CORRENTE = ("40", u"40 - Extrato de Conta Corrente")
-TED_OUTRA_TITULARIDADE = ("41", u"41 - TED – Outra Titularidade (1)")
-TED_MESMA_TITULARIDADE = ("43", u"43 - TED – Mesma Titularidade (1)")
+PAGAMENTO_TITULOS_OUTROS_BANCOS = ("31", "31 - Pagamento de Títulos de Outros Bancos")
+EXTRATO_CONTA_CORRENTE = ("40", "40 - Extrato de Conta Corrente")
+TED_OUTRA_TITULARIDADE = ("41", "41 - TED – Outra Titularidade (1)")
+TED_MESMA_TITULARIDADE = ("43", "43 - TED – Mesma Titularidade (1)")
TED_TRANSFERENCIA_CONTA_INVESTIMENTO = (
"44",
- u"44 - TED para Transferência de Conta Investimento",
+ "44 - TED para Transferência de Conta Investimento",
)
-DEBITO_CONTA_CORRENTE = ("50", u"50 - Débito em Conta Corrente")
-EXTRATO_GESTAO_CAIXA = ("70", u"70 - Extrato para Gestão de Caixa")
-DEPOSITO_JUDICIAL_CONTA_CORRENTE = ("71", u"71 - Depósito Judicial em Conta Corrente")
-DEPOSITO_JUDICIAL_POUPANCA = ("72", u"72 - Depósito Judicial em Poupança")
-EXTRATO_CONTA_INVESTIMENTO = ("73", u"73 - Extrato de Conta Investimento")
+DEBITO_CONTA_CORRENTE = ("50", "50 - Débito em Conta Corrente")
+EXTRATO_GESTAO_CAIXA = ("70", "70 - Extrato para Gestão de Caixa")
+DEPOSITO_JUDICIAL_CONTA_CORRENTE = ("71", "71 - Depósito Judicial em Conta Corrente")
+DEPOSITO_JUDICIAL_POUPANCA = ("72", "72 - Depósito Judicial em Poupança")
+EXTRATO_CONTA_INVESTIMENTO = ("73", "73 - Extrato de Conta Investimento")
FORMA_LANCAMENTO = [
CREDITO_CONTA_CORRENTE_SALARIO,
@@ -187,28 +187,28 @@
EXTRATO_CONTA_INVESTIMENTO,
]
-CREDITO_EM_CONTA = ("01", u"01 - Crédito em Conta")
-PAGAMENTO_ALUGUEL = ("02", u"02 - Pagamento de Aluguel/Condomínio")
-PAGAMENTO_DUPLICATA_TITULOS = ("03", u"03 - Pagamento de Duplicata/Títulos")
-PAGAMENTO_DIVIDENDOS_C = ("04", u"04 - Pagamento de Dividendos")
-PAGAMENTO_MENSALIDADE_ESCOLAR = ("05", u"05 - Pagamento de Mensalidade Escolar")
-PAGAMENTO_SALARIOS_C = ("06", u"06 - Pagamento de Salários")
-PAGAMENTO_FORNECEDORES = ("07", u"07 - Pagamento a Fornecedores")
+CREDITO_EM_CONTA = ("01", "01 - Crédito em Conta")
+PAGAMENTO_ALUGUEL = ("02", "02 - Pagamento de Aluguel/Condomínio")
+PAGAMENTO_DUPLICATA_TITULOS = ("03", "03 - Pagamento de Duplicata/Títulos")
+PAGAMENTO_DIVIDENDOS_C = ("04", "04 - Pagamento de Dividendos")
+PAGAMENTO_MENSALIDADE_ESCOLAR = ("05", "05 - Pagamento de Mensalidade Escolar")
+PAGAMENTO_SALARIOS_C = ("06", "06 - Pagamento de Salários")
+PAGAMENTO_FORNECEDORES = ("07", "07 - Pagamento a Fornecedores")
OPERACOES_CAMBIOS_FUNDOS_BOLSA = (
"08",
- u"08 - Operações de Câmbios/Fundos/Bolsa de Valores",
+ "08 - Operações de Câmbios/Fundos/Bolsa de Valores",
)
-REPASSE_ARRECADACAO = ("09", u"09 - Repasse de Arrecadação/Pagamento de Tributos")
-TRANSFERECIA_INTERNACIONAL_EM_REAL = ("10", u"10 - Transferência Internacional em Real")
-DOC_POUPANCA = ("11", u"11 - DOC para Poupança")
-DOC_DEPOSITO_JUDICIAL = ("12", u"12 - DOC para Depósito Judicial")
-OUTROS = ("13", u"13 - Outros")
-PAGAMENTO_BOLSA_AUXILIO_C = ("16", u"16 - Pagamento de bolsa auxílio")
-REMUNERACAO_COOPERADO = ("17", u"17 - Remuneração à cooperado")
-PAGAMENTO_HONORARIOS_C = ("18", u"18 - Pagamento de honorários")
+REPASSE_ARRECADACAO = ("09", "09 - Repasse de Arrecadação/Pagamento de Tributos")
+TRANSFERECIA_INTERNACIONAL_EM_REAL = ("10", "10 - Transferência Internacional em Real")
+DOC_POUPANCA = ("11", "11 - DOC para Poupança")
+DOC_DEPOSITO_JUDICIAL = ("12", "12 - DOC para Depósito Judicial")
+OUTROS = ("13", "13 - Outros")
+PAGAMENTO_BOLSA_AUXILIO_C = ("16", "16 - Pagamento de bolsa auxílio")
+REMUNERACAO_COOPERADO = ("17", "17 - Remuneração à cooperado")
+PAGAMENTO_HONORARIOS_C = ("18", "18 - Pagamento de honorários")
PAGAMENTO_PREBENDA_C = (
"19",
- u"19 - Pagamento de prebenda (Remuneração a padres e sacerdotes)",
+ "19 - Pagamento de prebenda (Remuneração a padres e sacerdotes)",
)
COMPLEMENTO_TIPO_SERVICO = [
@@ -237,18 +237,18 @@
# (www.bcb.gov.br), Sistema de Pagamentos Brasileiro,
# Transferência de Arquivos,
# Dicionários de Domínios para o SPB.
-CODIGO_FINALIDADE_TED = [(" ", u"Padrão")]
+CODIGO_FINALIDADE_TED = [(" ", "Padrão")]
-NAO_EMITE_AVISO = ("0", u"0 - Não Emite Aviso")
-EMITE_AVISO_REMETENTE = ("2", u"2 - Emite Aviso Somente para o Remetente")
-EMITE_AVISO_FAVORECIDO = ("5", u"5 - Emite Aviso Somente para o Favorecido")
+NAO_EMITE_AVISO = ("0", "0 - Não Emite Aviso")
+EMITE_AVISO_REMETENTE = ("2", "2 - Emite Aviso Somente para o Remetente")
+EMITE_AVISO_FAVORECIDO = ("5", "5 - Emite Aviso Somente para o Favorecido")
EMITE_AVISO_REMETENTE_FAVORECIDO = (
"6",
- u"6 - Emite Aviso para o Remetente e Favorecido",
+ "6 - Emite Aviso para o Remetente e Favorecido",
)
EMITE_AVISO_FAVORECIDO_2_VIAS_REMETENTE = (
"7",
- u"7 - Emite Aviso para o Favorecido e 2 Vias para o Remetente",
+ "7 - Emite Aviso para o Favorecido e 2 Vias para o Remetente",
)
AVISO_FAVORECIDO = [
@@ -260,213 +260,213 @@
]
INDICATIVO_FORMA_PAGAMENTO = [
- ("01", u"01 - Débito em Conta Corrente"),
- ("02", u"02 - Débito Empréstimo/Financiamento"),
- ("03", u"03 - Débito Cartão de Crédito"),
+ ("01", "01 - Débito em Conta Corrente"),
+ ("02", "02 - Débito Empréstimo/Financiamento"),
+ ("03", "03 - Débito Cartão de Crédito"),
]
TIPO_MOVIMENTO = [
- ("0", u"0 - Indica INCLUSÃO"),
- ("1", u"1 - Indica CONSULTA"),
- ("2", u"2 - Indica SUSPENSÃO"),
- ("3", u"3 - Indica ESTORNO (somente para retorno)"),
- ("4", u"4 - Indica REATIVAÇÃO"),
- ("5", u"5 - Indica ALTERAÇÃO"),
- ("7", u"7 - Indica LIQUIDAÇAO"),
- ("9", u"9 - Indica EXCLUSÃO"),
+ ("0", "0 - Indica INCLUSÃO"),
+ ("1", "1 - Indica CONSULTA"),
+ ("2", "2 - Indica SUSPENSÃO"),
+ ("3", "3 - Indica ESTORNO (somente para retorno)"),
+ ("4", "4 - Indica REATIVAÇÃO"),
+ ("5", "5 - Indica ALTERAÇÃO"),
+ ("7", "7 - Indica LIQUIDAÇAO"),
+ ("9", "9 - Indica EXCLUSÃO"),
]
CODIGO_INSTRUCAO_MOVIMENTO = [
- ("0", u"00 - Inclusão de Registro Detalhe Liberado"),
- ("9", u"09 - Inclusão do Registro Detalhe Bloqueado"),
- ("10", u"10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)"),
- ("11", u"11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)"),
- ("17", u"17 - Alteração do Valor do Título"),
- ("19", u"19 - Alteração da Data de Pagamento"),
- ("23", u"23 - Pagamento Direto ao Fornecedor - Baixar"),
- ("25", u"25 - Manutenção em Carteira - Não Pagar"),
- ("27", u"27 - Retirada de Carteira - Não Pagar"),
+ ("0", "00 - Inclusão de Registro Detalhe Liberado"),
+ ("9", "09 - Inclusão do Registro Detalhe Bloqueado"),
+ ("10", "10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)"),
+ ("11", "11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)"),
+ ("17", "17 - Alteração do Valor do Título"),
+ ("19", "19 - Alteração da Data de Pagamento"),
+ ("23", "23 - Pagamento Direto ao Fornecedor - Baixar"),
+ ("25", "25 - Manutenção em Carteira - Não Pagar"),
+ ("27", "27 - Retirada de Carteira - Não Pagar"),
(
"33",
- u"33 - Estorno por Devolução da Câmara Centralizadora "
- u"(somente para Tipo de Movimento = '3')",
+ "33 - Estorno por Devolução da Câmara Centralizadora "
+ "(somente para Tipo de Movimento = '3')",
),
- ("40", u"40 - Alegação do Pagador"),
- ("99", u"99 - Exclusão do Registro Detalhe Incluído Anteriormente"),
+ ("40", "40 - Alegação do Pagador"),
+ ("99", "99 - Exclusão do Registro Detalhe Incluído Anteriormente"),
]
CODIGO_OCORRENCIAS = [
- ("00", u"00 - Crédito ou Débito Efetivado"),
- ("01", u"01 - Insuficiência de Fundos - Débito Não Efetuado"),
- ("02", u"02 - Crédito ou Débito Cancelado pelo Pagador/Credor"),
- ("03", u"03 - Débito Autorizado pela Agência - Efetuado"),
- ("AA", u"AA - Controle Inválido"),
- ("AB", u"AB - Tipo de Operação Inválido"),
- ("AC", u"AC - Tipo de Serviço Inválido"),
- ("AD", u"AD - Forma de Lançamento Inválida"),
- ("AE", u"AE - Tipo/Número de Inscrição Inválido"),
- ("AF", u"AF - Código de Convênio Inválido"),
- ("AG", u"AG - Agência/Conta Corrente/DV Inválido"),
- ("AH", u"AH - Nº Seqüencial do Registro no Lote Inválido"),
- ("AI", u"AI - Código de Segmento de Detalhe Inválido"),
- ("AJ", u"AJ - Tipo de Movimento Inválido"),
+ ("00", "00 - Crédito ou Débito Efetivado"),
+ ("01", "01 - Insuficiência de Fundos - Débito Não Efetuado"),
+ ("02", "02 - Crédito ou Débito Cancelado pelo Pagador/Credor"),
+ ("03", "03 - Débito Autorizado pela Agência - Efetuado"),
+ ("AA", "AA - Controle Inválido"),
+ ("AB", "AB - Tipo de Operação Inválido"),
+ ("AC", "AC - Tipo de Serviço Inválido"),
+ ("AD", "AD - Forma de Lançamento Inválida"),
+ ("AE", "AE - Tipo/Número de Inscrição Inválido"),
+ ("AF", "AF - Código de Convênio Inválido"),
+ ("AG", "AG - Agência/Conta Corrente/DV Inválido"),
+ ("AH", "AH - Nº Seqüencial do Registro no Lote Inválido"),
+ ("AI", "AI - Código de Segmento de Detalhe Inválido"),
+ ("AJ", "AJ - Tipo de Movimento Inválido"),
(
"AK",
- u"AK - Código da Câmara de Compensação do Banco"
- u" Favorecido/Depositário Inválido",
+ "AK - Código da Câmara de Compensação do Banco"
+ " Favorecido/Depositário Inválido",
),
(
"AL",
- u"AL - Código do Banco Favorecido, Instituição de Pagamento"
- u" ou Depositário Inválido",
+ "AL - Código do Banco Favorecido, Instituição de Pagamento"
+ " ou Depositário Inválido",
),
- ("AM", u"AM - Agência Mantenedora da Conta Corrente do" u" Favorecido Inválida"),
- ("AN", u"AN - Conta Corrente/DV/Conta de Pagamento do" u" Favorecido Inválido"),
- ("AO", u"AO - Nome do Favorecido Não Informado"),
- ("AP", u"AP - Data Lançamento Inválido"),
- ("AQ", u"AQ - Tipo/Quantidade da Moeda Inválido"),
- ("AR", u"AR - Valor do Lançamento Inválido"),
- ("AS", u"AS - Aviso ao Favorecido - Identificação Inválida"),
- ("AT", u"AT - Tipo/Número de Inscrição do Favorecido Inválido"),
- ("AU", u"AU - Logradouro do Favorecido Não Informado"),
- ("AV", u"AV - Nº do Local do Favorecido Não Informado"),
- ("AW", u"AW - Cidade do Favorecido Não Informada"),
- ("AX", u"AX - CEP/Complemento do Favorecido Inválido"),
- ("AY", u"AY - Sigla do Estado do Favorecido Inválida"),
- ("AZ", u"AZ - Código/Nome do Banco Depositário Inválido"),
- ("BA", u"BA - Código/Nome da Agência Depositária Não Informado"),
- ("BB", u"BB - Seu Número Inválido"),
- ("BC", u"BC - Nosso Número Inválido"),
- ("BD", u"BD - Inclusão Efetuada com Sucesso"),
- ("BE", u"BE - Alteração Efetuada com Sucesso"),
- ("BF", u"BF - Exclusão Efetuada com Sucesso"),
- ("BG", u"BG - Agência/Conta Impedida Legalmente"),
- ("BH", u"BH - Empresa não pagou salário"),
- ("BI", u"BI - Falecimento do mutuário"),
- ("BJ", u"BJ - Empresa não enviou remessa do mutuário"),
- ("BK", u"BK - Empresa não enviou remessa no vencimento"),
- ("BL", u"BL - Valor da parcela inválida"),
- ("BM", u"BM - Identificação do contrato inválida"),
- ("BN", u"BN - Operação de Consignação Incluída com Sucesso"),
- ("BO", u"BO - Operação de Consignação Alterada com Sucesso"),
- ("BP", u"BP - Operação de Consignação Excluída com Sucesso"),
- ("BQ", u"BQ - Operação de Consignação Liquidada com Sucesso"),
- ("BR", u"BR - Reativação Efetuada com Sucesso"),
- ("BS", u"BS - Suspensão Efetuada com Sucesso"),
- ("CA", u"CA - Código de Barras - Código do Banco Inválido"),
- ("CB", u"CB - Código de Barras - Código da Moeda Inválido"),
- ("CC", u"CC - Código de Barras - Dígito Verificador Geral Inválido"),
- ("CD", u"CD - Código de Barras - Valor do Título Inválido"),
- ("CE", u"CE - Código de Barras - Campo Livre Inválido"),
- ("CF", u"CF - Valor do Documento Inválido"),
- ("CG", u"CG - Valor do Abatimento Inválido"),
- ("CH", u"CH - Valor do Desconto Inválido"),
- ("CI", u"CI - Valor de Mora Inválido"),
- ("CJ", u"CJ - Valor da Multa Inválido"),
- ("CK", u"CK - Valor do IR Inválido"),
- ("CL", u"CL - Valor do ISS Inválido"),
- ("CM", u"CM - Valor do IOF Inválido"),
- ("CN", u"CN - Valor de Outras Deduções Inválido"),
- ("CO", u"CO - Valor de Outros Acréscimos Inválido"),
- ("CP", u"CP - Valor do INSS Inválido"),
- ("HA", u"HA - Lote Não Aceito"),
- ("HB", u"HB - Inscrição da Empresa Inválida para o Contrato"),
- ("HC", u"HC - Convênio com a Empresa Inexistente/Inválido" u" para o Contrato"),
+ ("AM", "AM - Agência Mantenedora da Conta Corrente do" " Favorecido Inválida"),
+ ("AN", "AN - Conta Corrente/DV/Conta de Pagamento do" " Favorecido Inválido"),
+ ("AO", "AO - Nome do Favorecido Não Informado"),
+ ("AP", "AP - Data Lançamento Inválido"),
+ ("AQ", "AQ - Tipo/Quantidade da Moeda Inválido"),
+ ("AR", "AR - Valor do Lançamento Inválido"),
+ ("AS", "AS - Aviso ao Favorecido - Identificação Inválida"),
+ ("AT", "AT - Tipo/Número de Inscrição do Favorecido Inválido"),
+ ("AU", "AU - Logradouro do Favorecido Não Informado"),
+ ("AV", "AV - Nº do Local do Favorecido Não Informado"),
+ ("AW", "AW - Cidade do Favorecido Não Informada"),
+ ("AX", "AX - CEP/Complemento do Favorecido Inválido"),
+ ("AY", "AY - Sigla do Estado do Favorecido Inválida"),
+ ("AZ", "AZ - Código/Nome do Banco Depositário Inválido"),
+ ("BA", "BA - Código/Nome da Agência Depositária Não Informado"),
+ ("BB", "BB - Seu Número Inválido"),
+ ("BC", "BC - Nosso Número Inválido"),
+ ("BD", "BD - Inclusão Efetuada com Sucesso"),
+ ("BE", "BE - Alteração Efetuada com Sucesso"),
+ ("BF", "BF - Exclusão Efetuada com Sucesso"),
+ ("BG", "BG - Agência/Conta Impedida Legalmente"),
+ ("BH", "BH - Empresa não pagou salário"),
+ ("BI", "BI - Falecimento do mutuário"),
+ ("BJ", "BJ - Empresa não enviou remessa do mutuário"),
+ ("BK", "BK - Empresa não enviou remessa no vencimento"),
+ ("BL", "BL - Valor da parcela inválida"),
+ ("BM", "BM - Identificação do contrato inválida"),
+ ("BN", "BN - Operação de Consignação Incluída com Sucesso"),
+ ("BO", "BO - Operação de Consignação Alterada com Sucesso"),
+ ("BP", "BP - Operação de Consignação Excluída com Sucesso"),
+ ("BQ", "BQ - Operação de Consignação Liquidada com Sucesso"),
+ ("BR", "BR - Reativação Efetuada com Sucesso"),
+ ("BS", "BS - Suspensão Efetuada com Sucesso"),
+ ("CA", "CA - Código de Barras - Código do Banco Inválido"),
+ ("CB", "CB - Código de Barras - Código da Moeda Inválido"),
+ ("CC", "CC - Código de Barras - Dígito Verificador Geral Inválido"),
+ ("CD", "CD - Código de Barras - Valor do Título Inválido"),
+ ("CE", "CE - Código de Barras - Campo Livre Inválido"),
+ ("CF", "CF - Valor do Documento Inválido"),
+ ("CG", "CG - Valor do Abatimento Inválido"),
+ ("CH", "CH - Valor do Desconto Inválido"),
+ ("CI", "CI - Valor de Mora Inválido"),
+ ("CJ", "CJ - Valor da Multa Inválido"),
+ ("CK", "CK - Valor do IR Inválido"),
+ ("CL", "CL - Valor do ISS Inválido"),
+ ("CM", "CM - Valor do IOF Inválido"),
+ ("CN", "CN - Valor de Outras Deduções Inválido"),
+ ("CO", "CO - Valor de Outros Acréscimos Inválido"),
+ ("CP", "CP - Valor do INSS Inválido"),
+ ("HA", "HA - Lote Não Aceito"),
+ ("HB", "HB - Inscrição da Empresa Inválida para o Contrato"),
+ ("HC", "HC - Convênio com a Empresa Inexistente/Inválido" " para o Contrato"),
(
"HD",
- u"HD - Agência/Conta Corrente da Empresa Inexistente/Inválido"
- u" para o Contrato",
+ "HD - Agência/Conta Corrente da Empresa Inexistente/Inválido"
+ " para o Contrato",
),
- ("HE", u"HE - Tipo de Serviço Inválido para o Contrato"),
- ("HF", u"HF - Conta Corrente da Empresa com Saldo Insuficiente"),
- ("HG", u"HG - Lote de Serviço Fora de Seqüência"),
- ("HH", u"HH - Lote de Serviço Inválido"),
- ("HI", u"HI - Arquivo não aceito"),
- ("HJ", u"HJ - Tipo de Registro Inválido"),
- ("HK", u"HK - Código Remessa / Retorno Inválido"),
- ("HL", u"HL - Versão de layout inválida"),
- ("HM", u"HM - Mutuário não identificado"),
- ("HN", u"HN - Tipo do beneficio não permite empréstimo"),
- ("HO", u"HO - Beneficio cessado/suspenso"),
- ("HP", u"HP - Beneficio possui representante legal"),
- ("HQ", u"HQ - Beneficio é do tipo PA (Pensão alimentícia)"),
- ("HR", u"HR - Quantidade de contratos permitida excedida"),
- ("HS", u"HS - Beneficio não pertence ao Banco informado"),
- ("HT", u"HT - Início do desconto informado já ultrapassado"),
- ("HU", u"HU - Número da parcela inválida"),
- ("HV", u"HV - Quantidade de parcela inválida"),
+ ("HE", "HE - Tipo de Serviço Inválido para o Contrato"),
+ ("HF", "HF - Conta Corrente da Empresa com Saldo Insuficiente"),
+ ("HG", "HG - Lote de Serviço Fora de Seqüência"),
+ ("HH", "HH - Lote de Serviço Inválido"),
+ ("HI", "HI - Arquivo não aceito"),
+ ("HJ", "HJ - Tipo de Registro Inválido"),
+ ("HK", "HK - Código Remessa / Retorno Inválido"),
+ ("HL", "HL - Versão de layout inválida"),
+ ("HM", "HM - Mutuário não identificado"),
+ ("HN", "HN - Tipo do beneficio não permite empréstimo"),
+ ("HO", "HO - Beneficio cessado/suspenso"),
+ ("HP", "HP - Beneficio possui representante legal"),
+ ("HQ", "HQ - Beneficio é do tipo PA (Pensão alimentícia)"),
+ ("HR", "HR - Quantidade de contratos permitida excedida"),
+ ("HS", "HS - Beneficio não pertence ao Banco informado"),
+ ("HT", "HT - Início do desconto informado já ultrapassado"),
+ ("HU", "HU - Número da parcela inválida"),
+ ("HV", "HV - Quantidade de parcela inválida"),
(
"HW",
- u"HW - Margem consignável excedida para o mutuário dentro"
- u" do prazo do contrato",
+ "HW - Margem consignável excedida para o mutuário dentro"
+ " do prazo do contrato",
),
- ("HX", u"HX - Empréstimo já cadastrado"),
- ("HY", u"HY - Empréstimo inexistente"),
- ("HZ", u"HZ - Empréstimo já encerrado"),
- ("H1", u"H1 - Arquivo sem trailer"),
- ("H2", u"H2 - Mutuário sem crédito na competência"),
- ("H3", u"H3 - Não descontado – outros motivos"),
- ("H4", u"H4 - Retorno de Crédito não pago"),
- ("H5", u"H5 - Cancelamento de empréstimo retroativo"),
- ("H6", u"H6 - Outros Motivos de Glosa"),
+ ("HX", "HX - Empréstimo já cadastrado"),
+ ("HY", "HY - Empréstimo inexistente"),
+ ("HZ", "HZ - Empréstimo já encerrado"),
+ ("H1", "H1 - Arquivo sem trailer"),
+ ("H2", "H2 - Mutuário sem crédito na competência"),
+ ("H3", "H3 - Não descontado – outros motivos"),
+ ("H4", "H4 - Retorno de Crédito não pago"),
+ ("H5", "H5 - Cancelamento de empréstimo retroativo"),
+ ("H6", "H6 - Outros Motivos de Glosa"),
(
"H7",
- u"H7 - Margem consignável excedida para o mutuário acima"
- u" do prazo do contrato",
+ "H7 - Margem consignável excedida para o mutuário acima"
+ " do prazo do contrato",
),
- ("H8", u"H8 - Mutuário desligado do empregador"),
- ("H9", u"H9 - Mutuário afastado por licença"),
+ ("H8", "H8 - Mutuário desligado do empregador"),
+ ("H9", "H9 - Mutuário afastado por licença"),
(
"IA",
- u"IA - Primeiro nome do mutuário diferente do primeiro nome"
- u" do movimento do censo ou diferente da base de Titular"
- u" do Benefício",
+ "IA - Primeiro nome do mutuário diferente do primeiro nome"
+ " do movimento do censo ou diferente da base de Titular"
+ " do Benefício",
),
- ("IB", u"IB - Benefício suspenso/cessado pela APS ou Sisobi"),
- ("IC", u"IC - Benefício suspenso por dependência de cálculo"),
- ("ID", u"ID - Benefício suspenso/cessado pela inspetoria/auditoria"),
- ("IE", u"IE - Benefício bloqueado para empréstimo pelo beneficiário"),
- ("IF", u"IF - Benefício bloqueado para empréstimo por TBM"),
- ("IG", u"IG - Benefício está em fase de concessão de PA ou desdobramento"),
- ("IH", u"IH - Benefício cessado por óbito"),
- ("II", u"II - Benefício cessado por fraude"),
- ("IJ", u"IJ - Benefício cessado por concessão de outro benefício"),
- ("IK", u"IK - Benefício cessado: estatutário transferido" u" para órgão de origem"),
- ("IL", u"IL - Empréstimo suspenso pela APS"),
- ("IM", u"IM - Empréstimo cancelado pelo banco"),
- ("IN", u"IN - Crédito transformado em PAB"),
- ("IO", u"IO - Término da consignação foi alterado"),
+ ("IB", "IB - Benefício suspenso/cessado pela APS ou Sisobi"),
+ ("IC", "IC - Benefício suspenso por dependência de cálculo"),
+ ("ID", "ID - Benefício suspenso/cessado pela inspetoria/auditoria"),
+ ("IE", "IE - Benefício bloqueado para empréstimo pelo beneficiário"),
+ ("IF", "IF - Benefício bloqueado para empréstimo por TBM"),
+ ("IG", "IG - Benefício está em fase de concessão de PA ou desdobramento"),
+ ("IH", "IH - Benefício cessado por óbito"),
+ ("II", "II - Benefício cessado por fraude"),
+ ("IJ", "IJ - Benefício cessado por concessão de outro benefício"),
+ ("IK", "IK - Benefício cessado: estatutário transferido" " para órgão de origem"),
+ ("IL", "IL - Empréstimo suspenso pela APS"),
+ ("IM", "IM - Empréstimo cancelado pelo banco"),
+ ("IN", "IN - Crédito transformado em PAB"),
+ ("IO", "IO - Término da consignação foi alterado"),
(
"IP",
- u"IP - Fim do empréstimo ocorreu durante período" u" de suspensão ou concessão",
+ "IP - Fim do empréstimo ocorreu durante período" " de suspensão ou concessão",
),
- ("IQ", u"IQ - Empréstimo suspenso pelo banco"),
+ ("IQ", "IQ - Empréstimo suspenso pelo banco"),
(
"IR",
- u"IR - Não averbação de contrato – quantidade de"
- u" parcelas/competências informadas ultrapassou a data limite"
- u" da extinção de cota do dependente titular de benefícios",
+ "IR - Não averbação de contrato – quantidade de"
+ " parcelas/competências informadas ultrapassou a data limite"
+ " da extinção de cota do dependente titular de benefícios",
),
- ("TA", u"TA - Lote Não Aceito - Totais do Lote com Diferença"),
- ("YA", u"YA - Título Não Encontrado"),
- ("YB", u"YB - Identificador Registro Opcional Inválido"),
- ("YC", u"YC - Código Padrão Inválido"),
- ("YD", u"YD - Código de Ocorrência Inválido"),
- ("YE", u"YE - Complemento de Ocorrência Inválido"),
- ("YF", u"YF - Alegação já Informada"),
- ("ZA", u"ZA - Agência / Conta do Favorecido Substituída"),
+ ("TA", "TA - Lote Não Aceito - Totais do Lote com Diferença"),
+ ("YA", "YA - Título Não Encontrado"),
+ ("YB", "YB - Identificador Registro Opcional Inválido"),
+ ("YC", "YC - Código Padrão Inválido"),
+ ("YD", "YD - Código de Ocorrência Inválido"),
+ ("YE", "YE - Complemento de Ocorrência Inválido"),
+ ("YF", "YF - Alegação já Informada"),
+ ("ZA", "ZA - Agência / Conta do Favorecido Substituída"),
(
"ZB",
- u"ZB - Divergência entre o primeiro e último nome do beneficiário"
- u" versus primeiro e último nome na Receita Federal",
+ "ZB - Divergência entre o primeiro e último nome do beneficiário"
+ " versus primeiro e último nome na Receita Federal",
),
- ("ZC", u"ZC - Confirmação de Antecipação de Valor"),
- ("ZD", u"ZD - Antecipação parcial de valor"),
- ("ZE", u"ZE - Título bloqueado na base"),
- ("ZF", u"ZF - Sistema em contingência" u" – título valor maior que referência"),
- ("ZG", u"ZG - Sistema em contingência – título vencido"),
- ("ZH", u"ZH - Sistema em contingência – título indexado"),
- ("ZI", u"ZI - Beneficiário divergente"),
- ("ZJ", u"ZJ - Limite de pagamentos parciais excedido"),
- ("ZK", u"ZK - Boleto já liquidado"),
+ ("ZC", "ZC - Confirmação de Antecipação de Valor"),
+ ("ZD", "ZD - Antecipação parcial de valor"),
+ ("ZE", "ZE - Título bloqueado na base"),
+ ("ZF", "ZF - Sistema em contingência" " – título valor maior que referência"),
+ ("ZG", "ZG - Sistema em contingência – título vencido"),
+ ("ZH", "ZH - Sistema em contingência – título indexado"),
+ ("ZI", "ZI - Beneficiário divergente"),
+ ("ZJ", "ZJ - Limite de pagamentos parciais excedido"),
+ ("ZK", "ZK - Boleto já liquidado"),
]
diff --git a/l10n_br_account_payment_cobranca/data/ir_cron.xml b/l10n_br_account_payment_cobranca/data/ir_cron.xml
index e66e6d737919..e183757e1cea 100644
--- a/l10n_br_account_payment_cobranca/data/ir_cron.xml
+++ b/l10n_br_account_payment_cobranca/data/ir_cron.xml
@@ -1,15 +1,15 @@
-
- Confirma Ordens de Débito API
- 1
- days
- -1
-
- True
- account.payment.order
- _confirm_debit_orders_api
-
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index bf248da25b68..6eba1f71c6c6 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -17,31 +17,31 @@
class AccountInvoice(models.Model):
_inherit = "account.invoice"
- active = fields.Boolean(string=u"Ativo", default=True)
-
- eval_state_cnab = fields.Selection(
- string=u"Estado CNAB",
- related="move_line_receivable_id.state_cnab",
- readonly=True,
- store=True,
- index=True,
- )
-
- eval_situacao_pagamento = fields.Selection(
- string=u"Situação do Pagamento",
- related="move_line_receivable_id.situacao_pagamento",
- readonly=True,
- store=True,
- index=True,
- )
+ active = fields.Boolean(string="Ativo", default=True)
+
+ # eval_state_cnab = fields.Selection(
+ # string=u"Estado CNAB",
+ # related="move_line_receivable_id.state_cnab",
+ # readonly=True,
+ # store=True,
+ # index=True,
+ # )
+ #
+ # eval_situacao_pagamento = fields.Selection(
+ # string=u"Situação do Pagamento",
+ # related="move_line_receivable_id.situacao_pagamento",
+ # readonly=True,
+ # store=True,
+ # index=True,
+ # )
eval_payment_mode_instrucoes = fields.Text(
- string=u"Instruções de Cobrança do Modo de Pagamento",
+ string="Instruções de Cobrança do Modo de Pagamento",
related="payment_mode_id.instrucoes",
readonly=True,
)
- instrucoes = fields.Text(string=u"Instruções de cobrança")
+ instrucoes = fields.Text(string="Instruções de cobrança")
bank_api_operation_ids = fields.One2many(
string="Operações Realizadas",
@@ -298,9 +298,9 @@ def _pos_action_move_create(self):
else:
raise UserError(
_(
- u"Favor acessar aba Cobrança da configuração da"
- u" sua empresa para determinar o tipo de "
- u"sequencia utilizada nas cobrancas"
+ "Favor acessar aba Cobrança da configuração da"
+ " sua empresa para determinar o tipo de "
+ "sequencia utilizada nas cobrancas"
)
)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index f4fc6a028fe3..f3329b32fd6b 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -11,15 +11,15 @@
ESTADOS_CNAB = [
- ("draft", u"Inicial"),
- ("added", u"Adicionada à ordem de pagamento"),
- ("added_paid", u"Adicionada para Baixa"),
- ("exported", u"Exportada"),
- ("exporting_error", u"Erro ao exportar"),
- ("accepted", u"Aceita"),
- ("accepted_hml", u"Aceita em Homologação"),
- ("not_accepted", u"Não aceita pelo banco"),
- ("done", u"Concluído"),
+ ("draft", "Inicial"),
+ ("added", "Adicionada à ordem de pagamento"),
+ ("added_paid", "Adicionada para Baixa"),
+ ("exported", "Exportada"),
+ ("exporting_error", "Erro ao exportar"),
+ ("accepted", "Aceita"),
+ ("accepted_hml", "Aceita em Homologação"),
+ ("not_accepted", "Não aceita pelo banco"),
+ ("done", "Concluído"),
]
SITUACAO_PAGAMENTO = [
@@ -35,18 +35,18 @@
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
- state_cnab = fields.Selection(ESTADOS_CNAB, u"Estados CNAB", default="draft")
- date_payment_created = fields.Date(u"Data da criação do pagamento", readonly=True)
- nosso_numero = fields.Char(string=u"Nosso Numero")
- numero_documento = fields.Char(string=u"Número documento")
- identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
+ state_cnab = fields.Selection(ESTADOS_CNAB, "Estados CNAB", default="draft")
+ date_payment_created = fields.Date("Data da criação do pagamento", readonly=True)
+ nosso_numero = fields.Char(string="Nosso Numero")
+ numero_documento = fields.Char(string="Número documento")
+ identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
situacao_pagamento = fields.Selection(
- selection=SITUACAO_PAGAMENTO, string=u"Situação do Pagamento", default="inicial"
+ selection=SITUACAO_PAGAMENTO, string="Situação do Pagamento", default="inicial"
)
- instrucoes = fields.Text(string=u"Instruções de cobrança", readonly=True)
+ instrucoes = fields.Text(string="Instruções de cobrança", readonly=True)
residual = fields.Monetary(
- string=u"Valor Residual", default=0.0, currency_field="company_currency_id"
+ string="Valor Residual", default=0.0, currency_field="company_currency_id"
)
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index 3377a7f620ed..b1113e0092ad 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -31,49 +31,49 @@ def default_get(self, fields_list):
res.update({"aviso_ao_favorecido": mode.aviso_ao_favorecido})
return res
- nosso_numero = fields.Char(string=u"Nosso Numero")
- numero_documento = fields.Char(string=u"Número documento")
- identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
+ nosso_numero = fields.Char(string="Nosso Numero")
+ numero_documento = fields.Char(string="Número documento")
+ identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u"Complemento do Tipo de Serviço",
- help=u"Campo P005 do CNAB",
+ string="Complemento do Tipo de Serviço",
+ help="Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u"Código Finalidade da TED",
- help=u"Campo P011 do CNAB",
+ string="Código Finalidade da TED",
+ help="Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
+ size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u"Aviso ao Favorecido",
- help=u"Campo P006 do CNAB",
+ string="Aviso ao Favorecido",
+ help="Campo P006 do CNAB",
default="0",
)
abatimento = fields.Float(
digits=(13, 2),
- string=u"Valor do Abatimento",
- help=u"Campo G045 do CNAB",
+ string="Valor do Abatimento",
+ help="Campo G045 do CNAB",
default=0.00,
)
desconto = fields.Float(
digits=(13, 2),
- string=u"Valor do Desconto",
- help=u"Campo G046 do CNAB",
+ string="Valor do Desconto",
+ help="Campo G046 do CNAB",
default=0.00,
)
mora = fields.Float(
digits=(13, 2),
- string=u"Valor da Mora",
- help=u"Campo G047 do CNAB",
+ string="Valor da Mora",
+ help="Campo G047 do CNAB",
default=0.00,
)
multa = fields.Float(
digits=(13, 2),
- string=u"Valor da Multa",
- help=u"Campo G048 do CNAB",
+ string="Valor da Multa",
+ help="Campo G048 do CNAB",
default=0.00,
)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index ead569c1dbe6..c4a8163fd03e 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -16,75 +16,75 @@ class PaymentMode(models.Model):
condicao_emissao_papeleta = fields.Selection(
[("1", "Banco emite e Processa"), ("2", "Cliente emite e banco processa")],
- u"Condição Emissão de Papeleta",
+ "Condição Emissão de Papeleta",
default="1",
)
cnab_percent_interest = fields.Float(
- string=u"Percentual de Juros", digits=dp.get_precision("Account")
+ string="Percentual de Juros", digits=dp.get_precision("Account")
)
comunicacao_2 = fields.Char("Comunicação para o sacador avalista")
tipo_servico = fields.Selection(
- selection=TIPO_SERVICO, string=u"Tipo de Serviço", help=u"Campo G025 do CNAB"
+ selection=TIPO_SERVICO, string="Tipo de Serviço", help="Campo G025 do CNAB"
)
forma_lancamento = fields.Selection(
selection=FORMA_LANCAMENTO,
- string=u"Forma Lançamento",
- help=u"Campo G029 do CNAB",
+ string="Forma Lançamento",
+ help="Campo G029 do CNAB",
)
codigo_convenio = fields.Char(
size=20,
- string=u"Código do Convênio no Banco",
- help=u"Campo G007 do CNAB",
- default=u"0001222130126",
+ string="Código do Convênio no Banco",
+ help="Campo G007 do CNAB",
+ default="0001222130126",
)
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u"Complemento do Tipo de Serviço",
- help=u"Campo P005 do CNAB",
+ string="Complemento do Tipo de Serviço",
+ help="Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u"Código Finalidade da TED",
- help=u"Campo P011 do CNAB",
+ string="Código Finalidade da TED",
+ help="Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
+ size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u"Aviso ao Favorecido",
- help=u"Campo P006 do CNAB",
+ string="Aviso ao Favorecido",
+ help="Campo P006 do CNAB",
default=0,
)
# A exportação CNAB não se encaixa somente nos parâmetros de
# débito e crédito.
boleto_carteira = fields.Char("Carteira", size=3)
boleto_modalidade = fields.Char("Modalidade", size=2)
- boleto_convenio = fields.Char(u"Codigo convênio", size=10)
- boleto_variacao = fields.Char(u"Variação", size=2)
- boleto_cnab_code = fields.Char(u"Código Cnab", size=20)
+ boleto_convenio = fields.Char("Codigo convênio", size=10)
+ boleto_variacao = fields.Char("Variação", size=2)
+ boleto_cnab_code = fields.Char("Código Cnab", size=20)
boleto_aceite = fields.Selection(
[("S", "Sim"), ("N", "Não")], string="Aceite", default="N"
)
boleto_type = fields.Selection(selection=[], string="Boleto")
boleto_especie = fields.Selection(
[
- ("01", u"DUPLICATA MERCANTIL"),
- ("02", u"NOTA PROMISSÓRIA"),
- ("03", u"NOTA DE SEGURO"),
- ("04", u"MENSALIDADE ESCOLAR"),
- ("05", u"RECIBO"),
- ("06", u"CONTRATO"),
- ("07", u"COSSEGUROS"),
- ("08", u"DUPLICATA DE SERVIÇO"),
- ("09", u"LETRA DE CÂMBIO"),
- ("13", u"NOTA DE DÉBITOS"),
- ("15", u"DOCUMENTO DE DÍVIDA"),
- ("16", u"ENCARGOS CONDOMINIAIS"),
- ("17", u"CONTA DE PRESTAÇÃO DE SERVIÇOS"),
- ("99", u"DIVERSOS"),
+ ("01", "DUPLICATA MERCANTIL"),
+ ("02", "NOTA PROMISSÓRIA"),
+ ("03", "NOTA DE SEGURO"),
+ ("04", "MENSALIDADE ESCOLAR"),
+ ("05", "RECIBO"),
+ ("06", "CONTRATO"),
+ ("07", "COSSEGUROS"),
+ ("08", "DUPLICATA DE SERVIÇO"),
+ ("09", "LETRA DE CÂMBIO"),
+ ("13", "NOTA DE DÉBITOS"),
+ ("15", "DOCUMENTO DE DÍVIDA"),
+ ("16", "ENCARGOS CONDOMINIAIS"),
+ ("17", "CONTA DE PRESTAÇÃO DE SERVIÇOS"),
+ ("99", "DIVERSOS"),
],
- string=u"Espécie do Título",
+ string="Espécie do Título",
default="01",
)
boleto_protesto = fields.Char(
@@ -96,25 +96,25 @@ class PaymentMode(models.Model):
# ('7', u'Negativar (Dias Corridos)'),
# ('8', u'Não Negativar')
# ]
- string=u"Códigos de Protesto",
+ string="Códigos de Protesto",
default="0",
)
- boleto_protesto_prazo = fields.Char(u"Prazo protesto", size=2)
+ boleto_protesto_prazo = fields.Char("Prazo protesto", size=2)
gera_nosso_numero = fields.Boolean(
- string=u"Gerar nosso número?",
- help=u"Dependendo da carteira, banco, etc. "
- u"O nosso número pode ser gerado pelo banco.",
+ string="Gerar nosso número?",
+ help="Dependendo da carteira, banco, etc. "
+ "O nosso número pode ser gerado pelo banco.",
default=True,
)
default_account_id = fields.Many2one(
comodel_name="account.account",
- string=u"Conta Padrão",
- help=u"Conta padrão para recebimentos",
+ string="Conta Padrão",
+ help="Conta padrão para recebimentos",
)
default_tax_account_id = fields.Many2one(
comodel_name="account.account",
- string=u"Conta Padrão para Taxas Bancárias",
- help=u"Conta padrão para recebimentos de Taxas Bancárias",
+ string="Conta Padrão para Taxas Bancárias",
+ help="Conta padrão para recebimentos de Taxas Bancárias",
)
product_tax_id = fields.Many2one(
comodel_name="product.product", string="Taxa Adicional"
@@ -133,7 +133,7 @@ def _onchange_product_tax_id(self):
@api.constrains("product_override")
def _constrains_product_override(self):
if self.product_override and self.product_override_value <= 0:
- raise ValidationError(u"O valor da Taxa deve ser maior que 0 (zero)")
+ raise ValidationError("O valor da Taxa deve ser maior que 0 (zero)")
@api.constrains(
"boleto_type",
@@ -145,4 +145,4 @@ def _constrains_product_override(self):
)
def boleto_restriction(self):
if self.boleto_type == "6" and not self.boleto_carteira:
- raise ValidationError(u"Carteira no banco Itaú é obrigatória")
+ raise ValidationError("Carteira no banco Itaú é obrigatória")
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index af828f7f8764..1c07ed91ce97 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -3,7 +3,6 @@
# @author Hendrix Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from __future__ import division, print_function, unicode_literals
import logging
@@ -17,7 +16,7 @@
class PaymentOrder(models.Model):
- _inherit = b"account.payment.order"
+ _inherit = "account.payment.order"
active = fields.Boolean(string="Ativo", default=True)
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index f8a556c46fee..8c4a9f92b6a1 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -33,45 +33,45 @@ def default_get(self, fields_list):
codigo_finalidade_doc = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string=u"Complemento do Tipo de Serviço",
- help=u"Campo P005 do CNAB",
+ string="Complemento do Tipo de Serviço",
+ help="Campo P005 do CNAB",
)
codigo_finalidade_ted = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string=u"Código Finalidade da TED",
- help=u"Campo P011 do CNAB",
+ string="Código Finalidade da TED",
+ help="Campo P011 do CNAB",
)
codigo_finalidade_complementar = fields.Char(
- size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
+ size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
)
aviso_ao_favorecido = fields.Selection(
selection=AVISO_FAVORECIDO,
- string=u"Aviso ao Favorecido",
- help=u"Campo P006 do CNAB",
+ string="Aviso ao Favorecido",
+ help="Campo P006 do CNAB",
default="0",
)
abatimento = fields.Float(
digits=(13, 2),
- string=u"Valor do Abatimento",
- help=u"Campo G045 do CNAB",
+ string="Valor do Abatimento",
+ help="Campo G045 do CNAB",
default=0.00,
)
desconto = fields.Float(
digits=(13, 2),
- string=u"Valor do Desconto",
- help=u"Campo G046 do CNAB",
+ string="Valor do Desconto",
+ help="Campo G046 do CNAB",
default=0.00,
)
mora = fields.Float(
digits=(13, 2),
- string=u"Valor da Mora",
- help=u"Campo G047 do CNAB",
+ string="Valor da Mora",
+ help="Campo G047 do CNAB",
default=0.00,
)
multa = fields.Float(
digits=(13, 2),
- string=u"Valor da Multa",
- help=u"Campo G048 do CNAB",
+ string="Valor da Multa",
+ help="Campo G048 do CNAB",
default=0.00,
)
evento_id = fields.One2many(
@@ -81,18 +81,18 @@ def default_get(self, fields_list):
readonly=True,
)
codigo_finalidade_complementar = fields.Char(
- size=2, string=u"Código de finalidade complementar", help=u"Campo P013 do CNAB"
+ size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
)
- nosso_numero = fields.Char(string=u"Nosso Numero")
- numero_documento = fields.Char(string=u"Número documento")
- identificacao_titulo_empresa = fields.Char(string=u"Identificação Titulo Empresa")
- is_erro_exportacao = fields.Boolean(string=u"Contem erro de exportação")
- mensagem_erro_exportacao = fields.Char(string=u"Mensagem de erro")
+ nosso_numero = fields.Char(string="Nosso Numero")
+ numero_documento = fields.Char(string="Número documento")
+ identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
+ is_erro_exportacao = fields.Boolean(string="Contem erro de exportação")
+ mensagem_erro_exportacao = fields.Char(string="Mensagem de erro")
ultimo_estado_cnab = fields.Selection(
selection=ESTADOS_CNAB,
- string=u"Último Estado do CNAB",
- help=u"Último Estado do CNAB antes da confirmação de "
- u"pagamento nas Ordens de Pagamento",
+ string="Último Estado do CNAB",
+ help="Último Estado do CNAB antes da confirmação de "
+ "pagamento nas Ordens de Pagamento",
)
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 0978e64ce4c4..e80f7f3ce417 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -16,13 +16,13 @@
STATE = [("draft", "Novo"), ("done", "Processado"), ("error", "Erro no Processamento")]
TIPO_OPERACAO = {
- "C": u"Lançamento a Crédito",
- "D": u"Lançamento a Débito",
- "E": u"Extrato para Conciliação",
- "G": u"Extrato para Gestão de Caixa",
- "I": u"Informações de Títulos Capturados do Próprio Banco",
- "R": u"Arquivo Remessa",
- "T": u"Arquivo Retorno",
+ "C": "Lançamento a Crédito",
+ "D": "Lançamento a Débito",
+ "E": "Extrato para Conciliação",
+ "G": "Extrato para Gestão de Caixa",
+ "I": "Informações de Títulos Capturados do Próprio Banco",
+ "R": "Arquivo Remessa",
+ "T": "Arquivo Retorno",
}
TIPO_SERVICO = {
@@ -255,9 +255,9 @@ class L10nBrHrCnab(models.Model):
string="Lotes", comodel_name="l10n_br.cnab.lote", inverse_name="cnab_id"
)
name = fields.Char(string="Name")
- num_eventos = fields.Integer(string=u"Número de Eventos")
- num_lotes = fields.Integer(string=u"Número de Lotes")
- state = fields.Selection(string=u"Estágio", selection=STATE, default="draft")
+ num_eventos = fields.Integer(string="Número de Eventos")
+ num_lotes = fields.Integer(string="Número de Lotes")
+ state = fields.Selection(string="Estágio", selection=STATE, default="draft")
@api.one
@api.depends("name")
@@ -673,7 +673,7 @@ def _get_name(self, data, filename):
cnab_ids = self.search([("data", "=", data)], order="id desc")
cnab_idx = 1
if cnab_ids:
- search_result = filter(
+ search_result = list(filter(
lambda x: x is not None,
[
re.search(r"\((\d)\)", name)
@@ -681,7 +681,7 @@ def _get_name(self, data, filename):
[("data", "=", data), ("id", "!=", self.id)], order="id desc"
).mapped("name")
],
- )
+ ))
if search_result:
cnab_idx = max(int(result.group(1)) for result in search_result) + 1
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index 166e84a4034f..dd29d64a2fc4 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -20,33 +20,33 @@ class L10nBrCnabEvento(models.Model):
data_real_pagamento = fields.Date(string="Data do Crédito")
data_ocorrencia = fields.Date(string="Data da Ocorrência")
favorecido_conta_bancaria_id = fields.Many2one(
- string=u"Conta Bancária", comodel_name="res.partner.bank"
+ string="Conta Bancária", comodel_name="res.partner.bank"
)
favorecido_id = fields.Many2one(string="Favorecido", comodel_name="res.partner")
identificacao_titulo_empresa = fields.Char(
string="Identificação do Título da Empresa", required=False
)
invoice_id = fields.Many2one(comodel_name="account.invoice", string="Fatura")
- juros_mora_multa = fields.Float(string=u"Juros de Mora/Multa")
+ juros_mora_multa = fields.Float(string="Juros de Mora/Multa")
lote_id = fields.Many2one(
string="Lote", comodel_name="l10n_br.cnab.lote", ondelete="cascade"
)
- nosso_numero = fields.Char(string=u"Nosso Número")
- ocorrencias = fields.Char(string=u"Ocorrências")
- outros_creditos = fields.Float(string=u"Outros Créditos")
+ nosso_numero = fields.Char(string="Nosso Número")
+ ocorrencias = fields.Char(string="Ocorrências")
+ outros_creditos = fields.Float(string="Outros Créditos")
partner_id = fields.Many2one(comodel_name="res.partner", string="Associado")
segmento = fields.Char(string="Segmento")
- seu_numero = fields.Char(string=u"Seu Número")
+ seu_numero = fields.Char(string="Seu Número")
state = fields.Selection(
string="State", related="lote_id.state", selection=STATE, default="draft"
)
- str_motiv_a = fields.Char(u"Motivo da ocorrência 01")
- str_motiv_b = fields.Char(u"Motivo de ocorrência 02")
- str_motiv_c = fields.Char(u"Motivo de ocorrência 03")
- str_motiv_d = fields.Char(u"Motivo de ocorrência 04")
- str_motiv_e = fields.Char(u"Motivo de ocorrência 05")
- tipo_moeda = fields.Char(string=u"Tipo de Moeda")
- tarifa_cobranca = fields.Float(string=u"Tarifa")
+ str_motiv_a = fields.Char("Motivo da ocorrência 01")
+ str_motiv_b = fields.Char("Motivo de ocorrência 02")
+ str_motiv_c = fields.Char("Motivo de ocorrência 03")
+ str_motiv_d = fields.Char("Motivo de ocorrência 04")
+ str_motiv_e = fields.Char("Motivo de ocorrência 05")
+ tipo_moeda = fields.Char(string="Tipo de Moeda")
+ tarifa_cobranca = fields.Float(string="Tarifa")
valor = fields.Float(string="Valor da Linha")
valor_abatimento = fields.Float(
string="Valor do Abatimento",
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index 5bacac9ef730..3f2d3148dbe1 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -16,21 +16,21 @@ class L10nBrCnabLote(models.Model):
_name = "l10n_br.cnab.lote"
account_bank_id = fields.Many2one(
- string=u"Conta Bancária", comodel_name="res.partner.bank"
+ string="Conta Bancária", comodel_name="res.partner.bank"
)
cnab_id = fields.Many2one(
string="CNAB", comodel_name="l10n_br.cnab", ondelete="cascade"
)
- empresa_inscricao_numero = fields.Char(string=u"Número de Inscrição")
- empresa_inscricao_tipo = fields.Char(string=u"Tipo de Inscrição")
+ empresa_inscricao_numero = fields.Char(string="Número de Inscrição")
+ empresa_inscricao_tipo = fields.Char(string="Tipo de Inscrição")
evento_id = fields.One2many(
string="Eventos", comodel_name="l10n_br.cnab.evento", inverse_name="lote_id"
)
mensagem = fields.Char(string="Mensagem")
qtd_registros = fields.Integer(string="Quantidade de Registros")
- servico_operacao = fields.Char(string=u"Tipo de Operação")
+ servico_operacao = fields.Char(string="Tipo de Operação")
state = fields.Selection(
string="State", related="cnab_id.state", selection=STATE, default="draft"
)
- tipo_servico = fields.Char(string=u"Tipo do Serviço")
+ tipo_servico = fields.Char(string="Tipo do Serviço")
total_valores = fields.Float(string="Valor Total")
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index 83f40b841c65..406cc346f7e1 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -13,38 +13,38 @@ class ResCompany(models.Model):
own_number_type = fields.Selection(
selection=[
- (SEQUENCIAL_EMPRESA, u"Sequêncial único por empresa"),
- (SEQUENCIAL_FATURA, u"Numero sequêncial da Fatura"),
- (SEQUENCIAL_CARTEIRA, u"Sequêncial único por carteira"),
+ (SEQUENCIAL_EMPRESA, "Sequêncial único por empresa"),
+ (SEQUENCIAL_FATURA, "Numero sequêncial da Fatura"),
+ (SEQUENCIAL_CARTEIRA, "Sequêncial único por carteira"),
],
- string=u"Tipo de nosso número",
+ string="Tipo de nosso número",
default="2",
)
own_number_sequence = fields.Many2one(
- comodel_name="ir.sequence", string=u"Sequência do Nosso Número"
+ comodel_name="ir.sequence", string="Sequência do Nosso Número"
)
environment = fields.Selection(
- string=u"Ambiente",
+ string="Ambiente",
selection=[("1", "HOMOLOGAÇÃO"), ("2", "PRODUÇÃO")],
default="1",
)
- client_id = fields.Char(string=u"ID do Cliente")
+ client_id = fields.Char(string="ID do Cliente")
- client_secret = fields.Char(string=u"Segredo")
+ client_secret = fields.Char(string="Segredo")
- itau_key = fields.Char(string=u"Chave")
+ itau_key = fields.Char(string="Chave")
- api_endpoint = fields.Char(string=u"API ENDPOINT")
+ api_endpoint = fields.Char(string="API ENDPOINT")
- raiz_endpoint = fields.Char(string=u"RAIZ ENDPOINT")
+ raiz_endpoint = fields.Char(string="RAIZ ENDPOINT")
- api_itau_token = fields.Char(string=u"Itaú API Token", readonly=True)
+ api_itau_token = fields.Char(string="Itaú API Token", readonly=True)
api_itau_token_due_datetime = fields.Datetime(
- string=u"Validade do Token", readonly=True
+ string="Validade do Token", readonly=True
)
@api.multi
diff --git a/l10n_br_account_payment_cobranca/models/res_partner.py b/l10n_br_account_payment_cobranca/models/res_partner.py
index 443e31f696c2..2e7c8736bd14 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner.py
@@ -8,4 +8,4 @@
class ResPartner(models.Model):
_inherit = "res.partner"
- type = fields.Selection(selection_add=[("cnab_cobranca", u"Cobrança CNAB")])
+ type = fields.Selection(selection_add=[("cnab_cobranca", "Cobrança CNAB")])
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
index 70280ee257b6..b8c0f9a08e85 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner_bank.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
@@ -12,22 +12,22 @@ class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"
codigo_da_empresa = fields.Integer(
- u"Código da empresa",
+ "Código da empresa",
size=20,
- help=u"Será informado pelo banco depois do cadastro do beneficiário "
- u"na agência",
+ help="Será informado pelo banco depois do cadastro do beneficiário "
+ "na agência",
)
tipo_de_conta = fields.Selection(
selection=[
- ("01", u"Conta corrente individual"),
- ("02", u"Conta poupança individual"),
- ("03", u"Conta depósito judicial/Depósito em consignação " u"individual"),
- ("11", u"Conta corrente conjunta"),
- ("12", u"Conta poupança conjunta"),
- ("13", u"Conta depósito judicial/Depósito em consignação " u"conjunta"),
+ ("01", "Conta corrente individual"),
+ ("02", "Conta poupança individual"),
+ ("03", "Conta depósito judicial/Depósito em consignação " "individual"),
+ ("11", "Conta corrente conjunta"),
+ ("12", "Conta poupança conjunta"),
+ ("13", "Conta depósito judicial/Depósito em consignação " "conjunta"),
],
- string=u"Tipo de Conta",
+ string="Tipo de Conta",
default="01",
)
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index 1b3d05745418..ccc7669ce917 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -2,53 +2,53 @@
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo.api import Environment
-from odoo.report.interface import report_int
-from odoo.report.render import render
-
-
-class ExternalPdf(render):
- def __init__(self, pdf):
- render.__init__(self)
- self.pdf = pdf
- self.output_type = "pdf"
-
- def _render(self):
- return self.pdf
-
-
-class ReportCustom(report_int):
- """
- Custom report for return boletos
- """
-
- def create(self, cr, uid, ids, datas, context=False):
- if not context:
- context = {}
-
- env = Environment(cr, uid, {})
-
- active_ids = context.get("active_ids")
- active_model = context.get("active_model")
-
- ids_move_lines = []
-
- if active_model == "account.invoice":
- for invoices in env["account.invoice"].browse(active_ids):
- receivable_ids = invoices.mapped("move_line_receivable_id")
- if receivable_ids:
- ids_move_lines = receivable_ids
- elif active_model == "account.move.line":
- ids_move_lines = env["account.move.line"].browse(active_ids)
-
- if not ids_move_lines:
- return False
-
- pdf_string = ids_move_lines.generate_boleto()
- self.obj = ExternalPdf(pdf_string)
- self.obj.render()
- return self.obj.pdf, "pdf"
-
-
-ReportCustom("report.l10n_br_account_payment_boleto.report")
+#
+# from odoo.api import Environment
+# from odoo.report.interface import report_int
+# from odoo.report.render import render
+#
+#
+# class ExternalPdf(render):
+# def __init__(self, pdf):
+# render.__init__(self)
+# self.pdf = pdf
+# self.output_type = "pdf"
+#
+# def _render(self):
+# return self.pdf
+#
+#
+# class ReportCustom(report_int):
+# """
+# Custom report for return boletos
+# """
+#
+# def create(self, cr, uid, ids, datas, context=False):
+# if not context:
+# context = {}
+#
+# env = Environment(cr, uid, {})
+#
+# active_ids = context.get("active_ids")
+# active_model = context.get("active_model")
+#
+# ids_move_lines = []
+#
+# if active_model == "account.invoice":
+# for invoices in env["account.invoice"].browse(active_ids):
+# receivable_ids = invoices.mapped("move_line_receivable_id")
+# if receivable_ids:
+# ids_move_lines = receivable_ids
+# elif active_model == "account.move.line":
+# ids_move_lines = env["account.move.line"].browse(active_ids)
+#
+# if not ids_move_lines:
+# return False
+#
+# pdf_string = ids_move_lines.generate_boleto()
+# self.obj = ExternalPdf(pdf_string)
+# self.obj.render()
+# return self.obj.pdf, "pdf"
+#
+#
+# ReportCustom("report.l10n_br_account_payment_boleto.report")
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 50037a9824f6..362eaeafeba4 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -42,41 +42,41 @@
- view.l10n_br_account.invoice.form.form.inherit
-
+ view.l10n_br_account.invoice.form.form.inherit
account.invoice
+ ref="account.invoice_supplier_form"/>
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+ />
+
@@ -89,17 +89,17 @@
-
- invoice.tree.inherit
- account.invoice
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
view.account.invoice.filter.inherit
@@ -113,53 +113,53 @@
[('state','!=','paid')]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index e79c150ae780..775dc09022d2 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -6,7 +6,7 @@
account.payment.mode
+ ref="l10n_br_account_payment_order.l10n_br_account_payment_mode_form"/>
diff --git a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
index b3d91f5c0160..75e5f73001be 100644
--- a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
@@ -16,59 +16,59 @@
-
- bank.api.operation.search.view
- bank.api.operation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
bank.api.operation.form.view
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
index d3fa950f8ee6..7797910a5931 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
@@ -18,48 +18,48 @@
sequence="2"
/>
-
-
- view.l10n_br.cnab.evento.search
- l10n_br.cnab.evento
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index ecec3453124d..854b8a6f157d 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -214,12 +214,12 @@
action = env.get('l10n_br.cnab').processar_retorno_multi()
-
- Processar Retorno
- client_action_multi
- l10n_br.cnab
-
-
+
+
+
+
+
+
Reprocessar Retorno
@@ -228,12 +228,12 @@
action = env.get('l10n_br.cnab').reprocessar_retorno_multi()
-
- Reprocessar Retorno
- client_action_multi
- l10n_br.cnab
-
-
+
+
+
+
+
+
Importar Retorno Bancário CNAB
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index c5221cf69746..ecfb9762951b 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -1,33 +1,33 @@
-
- l10n_br_account_payment_boleto.res.company.form
-
- res.company
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 482dbe173bae..3aabeccbd778 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -12,8 +12,8 @@ class AccountPaymentLineCreate(models.TransientModel):
_inherit = "account.payment.line.create"
allow_error = fields.Boolean(
- string=u"Permitir linhas com erro na exportação, "
- u"já incluidas em outras ordens"
+ string="Permitir linhas com erro na exportação, "
+ "já incluidas em outras ordens"
)
allow_rejected = fields.Boolean(string="Permitir linhas com retorno rejeitado")
From 05921cd7a9b5b794dfe83ca989f768b5835ca24e Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 6 Feb 2020 08:38:52 -0300
Subject: [PATCH 185/612] [NEW] README files
Signed-off-by: Luis Felipe Mileo
Signed-off-by: Luis Felipe Mileo
---
.../readme/CONFIGURE.rst | 10 ++++++++
.../readme/CONTRIBUTORS.rst | 2 ++
.../readme/CREDITS.rst | 7 ++++++
.../readme/DESCRIPTION.rst | 5 ++++
.../readme/HISTORY.rst | 24 +++++++++++++++++++
.../readme/INSTALL.rst | 7 ++++++
.../readme/ROADMAP.rst | 5 ++++
.../readme/USAGE.rst | 11 +++++++++
8 files changed, 71 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/CREDITS.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/HISTORY.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/INSTALL.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/ROADMAP.rst
create mode 100644 l10n_br_account_payment_cobranca/readme/USAGE.rst
diff --git a/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst b/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
new file mode 100644
index 000000000000..754e51aeff53
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
@@ -0,0 +1,10 @@
+[ This file is optional, it should explain how to configure
+ the module before using it; it is aimed at advanced users. ]
+
+To configure this module, you need to:
+
+#. Go to ...
+
+.. figure:: ../static/description/image.png
+ :alt: alternative description
+ :width: 600 px
diff --git a/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst b/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000000..786f0d6dc9ba
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
@@ -0,0 +1,2 @@
+* Firstname Lastname (optional company website url)
+* Second Person (optional company website url)
diff --git a/l10n_br_account_payment_cobranca/readme/CREDITS.rst b/l10n_br_account_payment_cobranca/readme/CREDITS.rst
new file mode 100644
index 000000000000..505af5aae590
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/CREDITS.rst
@@ -0,0 +1,7 @@
+[ This file is optional and contains additional credits, other than
+ authors, contributors, and maintainers. ]
+
+The development of this module has been financially supported by:
+
+* Company 1 name
+* Company 2 name
diff --git a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
new file mode 100644
index 000000000000..b85dad5190e7
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
@@ -0,0 +1,5 @@
+[ This file must be max 2-3 paragraphs, and is required. ]
+
+This module extends the functionality of portal to support Brasilian
+fields.
+
diff --git a/l10n_br_account_payment_cobranca/readme/HISTORY.rst b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
new file mode 100644
index 000000000000..ac1f5b674c68
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
@@ -0,0 +1,24 @@
+[ The change log. The goal of this file is to help readers
+ understand changes between version. The primary audience is
+ end users and integrators. Purely technical changes such as
+ code refactoring must not be mentioned here.
+
+ This file may contain ONE level of section titles, underlined
+ with the ~ (tilde) character. Other section markers are
+ forbidden and will likely break the structure of the README.rst
+ or other documents where this fragment is included. ]
+
+11.0.x.y.z (YYYY-MM-DD)
+~~~~~~~~~~~~~~~~~~~~~~~
+
+* [BREAKING] Breaking changes come first.
+ (`#70 `_)
+* [ADD] New feature.
+ (`#74 `_)
+* [FIX] Correct this.
+ (`#71 `_)
+
+11.0.x.y.z (YYYY-MM-DD)
+~~~~~~~~~~~~~~~~~~~~~~~
+
+* ...
diff --git a/l10n_br_account_payment_cobranca/readme/INSTALL.rst b/l10n_br_account_payment_cobranca/readme/INSTALL.rst
new file mode 100644
index 000000000000..b62c6d1e9530
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/INSTALL.rst
@@ -0,0 +1,7 @@
+[ This file must only be present if there are very specific
+ installation instructions, such as installing non-python
+ dependencies. The audience is systems administrators. ]
+
+To install this module, you need to:
+
+#. Do this ...
diff --git a/l10n_br_account_payment_cobranca/readme/ROADMAP.rst b/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
new file mode 100644
index 000000000000..207233013b40
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
@@ -0,0 +1,5 @@
+[ Enumerate known caveats and future potential improvements.
+ It is mostly intended for end-users, and can also help
+ potential new contributors discovering new features to implement. ]
+
+* ...
diff --git a/l10n_br_account_payment_cobranca/readme/USAGE.rst b/l10n_br_account_payment_cobranca/readme/USAGE.rst
new file mode 100644
index 000000000000..f4629c3d548a
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/readme/USAGE.rst
@@ -0,0 +1,11 @@
+[ This file must be present and contains the usage instructions
+ for end-users. As all other rst files included in the README,
+ it MUST NOT contain reStructuredText sections
+ only body text (paragraphs, lists, tables, etc). Should you need
+ a more elaborate structure to explain the addon, please create a
+ Sphinx documentation (which may include this file as a "quick start"
+ section). ]
+
+To use this module, you need to:
+
+#. Go to ...
From e67a7e75f7e5e2587a62d65473ef8cbe582109ce Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Tue, 18 Feb 2020 05:32:56 -0300
Subject: [PATCH 186/612] [NEW] Menu, view and operation type for cobranca
---
.../__manifest__.py | 1 +
.../models/account_payment_mode.py | 3 +++
.../models/account_payment_order.py | 3 +++
.../account_payment_order_menu_views.xml | 24 +++++++++++++++++++
4 files changed, 31 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 57f6d0bc5f58..b55f3a5a59d5 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -23,6 +23,7 @@
"views/account_payment_mode.xml",
"views/res_partner_bank.xml",
"views/account_payment_order.xml",
+ "views/account_payment_order_menu_views.xml",
"views/account_payment_line.xml",
"views/account_payment_term_view.xml",
"views/bank_payment_line.xml",
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index c4a8163fd03e..b92b7b623855 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -124,6 +124,9 @@ class PaymentMode(models.Model):
string="Conta Padrão",
help="Conta padrão para Taxa",
)
+ operation_type = fields.Selection(
+ selection_add=[('3', 'Cobrança')]
+ )
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 1c07ed91ce97..db3b8f5cc5e0 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -66,6 +66,9 @@ class PaymentOrder(models.Model):
readonly=True,
domain=[("is_erro_exportacao", "=", True)],
)
+ operation_type = fields.Selection(
+ selection_add=[('3', 'Cobrança')]
+ )
def _confirm_debit_orders_api(self):
"""
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml b/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
new file mode 100644
index 000000000000..ad260acf8e90
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ Cobrança
+ account.payment.order
+ tree,form,pivot,graph
+
+ [('payment_type', '=', 'inbound'),('operation_type', '=', '3')]
+ {'default_payment_type': 'inbound','default_operation_type': '3'}
+
+
+
+
+
+
From 3db47fca75d142a7c58b8bc0197b98ccb8c9d914 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Tue, 18 Feb 2020 05:34:32 -0300
Subject: [PATCH 187/612] [REF] View separation for payment_order model
---
.../views/account_payment_line.xml | 3 +-
.../views/account_payment_order.xml | 35 +++++++++++++++++--
.../account_payment_order_menu_views.xml | 13 +++++++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/views/account_payment_line.xml b/l10n_br_account_payment_order/views/account_payment_line.xml
index e282123f4f66..602f85c43726 100644
--- a/l10n_br_account_payment_order/views/account_payment_line.xml
+++ b/l10n_br_account_payment_order/views/account_payment_line.xml
@@ -6,9 +6,10 @@
-->
-
+
l10n_br_account.payment.line.form.banking
account.payment.line
+ primary
diff --git a/l10n_br_account_payment_order/views/account_payment_order.xml b/l10n_br_account_payment_order/views/account_payment_order.xml
index 621eb2121ea8..0083255c8a93 100644
--- a/l10n_br_account_payment_order/views/account_payment_order.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order.xml
@@ -6,18 +6,49 @@
-->
-
+
l10n_br_account.payment.order.form.banking
account.payment.order
+ primary
+
+
+
+
+
+
+
+ l10n_br_account.payment.order.form.banking.payment
+ account.payment.order
+ primary
+
+
+
+ {'default_payment_type': payment_type, 'form_view_ref': 'l10n_br_account_payment_order.l10n_br_account_payment_line_form'}
+
+
+
+
+
+ l10n_br_account.payment.order.form.banking.debit
+ account.payment.order
+ primary
+
+
+
+ {'default_payment_type': payment_type, 'form_view_ref': 'l10n_br_account_payment_order.l10n_br_account_payment_line_form'}
+
diff --git a/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml b/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
index de319f98e2a9..4fd5b64785bc 100644
--- a/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
@@ -9,6 +9,12 @@
Payment Orders
account.payment.order
tree,form,pivot,graph
+
[('payment_type', '=', 'outbound'),('operation_type', '=', '1')]
{'default_payment_type': 'outbound','default_operation_type': '1'}
@@ -17,6 +23,13 @@
Debit Orders
account.payment.order
tree,form,pivot,graph
+
+
[('payment_type', '=', 'inbound'),('operation_type', '=', '2')]
{'default_payment_type': 'inbound','default_operation_type': '2'}
From c97334146e15877d5dcb3f569ea9983181239047 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Tue, 18 Feb 2020 05:35:08 -0300
Subject: [PATCH 188/612] [NEW] View for Cobranca
---
.../views/account_payment_line.xml | 36 +++++++++++++++----
.../views/account_payment_order.xml | 8 +++--
2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
index d832b59bf956..b2a95628e762 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -1,9 +1,32 @@
-
- account.payment.order.form
-
+
+ account.payment.line.tree
+ account.payment.line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ account.payment.line.form
+
+ primary
account.payment.line
@@ -11,7 +34,7 @@
-
+
@@ -21,7 +44,8 @@
-
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order.xml b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
index ffd381c9c1ae..5e4d7318ad49 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
@@ -4,8 +4,8 @@
payment.order.form.sequence
account.payment.order
-
+ primary
+
@@ -20,6 +20,7 @@
Verifique-os na aba "Problemas"
+
@@ -30,6 +31,9 @@
+
+ {'default_payment_type': payment_type, 'tree_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_tree', 'form_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_form'}
+
From e957ddb798d9560c92b3197a78b74d6ec6a8aa85 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Mon, 2 Mar 2020 17:16:29 -0300
Subject: [PATCH 189/612] [REM] base_transaction_id dependency
---
l10n_br_account_payment_cobranca/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index b55f3a5a59d5..2a95eaabb4ad 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -12,7 +12,7 @@
"license": "AGPL-3",
"author": "KMEE, Odoo Community Association (OCA)",
"website": "http://www.kmee.com.br",
- "depends": ["base_transaction_id", "l10n_br_account_payment_order"],
+ "depends": ["l10n_br_account_payment_order"],
"data": [
"data/l10n_br_payment_export_type.xml",
"data/boleto_data.xml",
From e18c7fe3454d3ec0f2fcdadcd95792c0db7aa91b Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Mon, 2 Mar 2020 17:19:40 -0300
Subject: [PATCH 190/612] [NEW] Receivables computed field
---
.../models/account_invoice.py | 28 +++++++++++++++----
.../reports/report.py | 2 +-
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 6eba1f71c6c6..2cdc639e2b31 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -17,6 +17,24 @@
class AccountInvoice(models.Model):
_inherit = "account.invoice"
+ @api.multi
+ @api.depends('state', 'move_id.line_ids', 'move_id.line_ids.account_id')
+ def _compute_receivables(self):
+ for record in self:
+ lines = self.env['account.move.line']
+ for line in record.move_id.line_ids:
+ if (line.account_id.id == record.account_id.id and
+ line.account_id.internal_type in
+ ('receivable', 'payable')):
+ lines |= line
+ record.move_line_receivable_ids = lines.sorted()
+
+ move_line_receivable_ids = fields.Many2many(
+ comodel_name='account.move.line',
+ string=u'Receivables',
+ store=True,
+ compute='_compute_receivables')
+
active = fields.Boolean(string="Ativo", default=True)
# eval_state_cnab = fields.Selection(
@@ -121,9 +139,9 @@ def _onchange_payment_term(self):
)
def _remove_payment_order_line(self, _raise=True):
- move_line_receivable_id = self.move_line_receivable_id
+ move_line_receivable_ids = self.move_line_receivable_ids
payment_order_ids = self.env["account.payment.order"].search(
- [("payment_line_ids.move_line_id", "in", [move_line_receivable_id.id])]
+ [("payment_line_ids.move_line_id", "in", [move_line_receivable_ids.id])]
)
if payment_order_ids:
@@ -143,7 +161,7 @@ def _remove_payment_order_line(self, _raise=True):
p_line_id = self.env["account.payment.line"].search(
[
("order_id", "=", po_id.id),
- ("move_line_id", "=", move_line_receivable_id.id),
+ ("move_line_id", "=", move_line_receivable_ids.id),
]
)
po_id.payment_line_ids -= p_line_id
@@ -283,7 +301,7 @@ def _pos_action_move_create(self):
for inv in self:
# inv.transaction_id = sequence
inv._compute_receivables()
- for index, interval in enumerate(inv.move_line_receivable_id):
+ for index, interval in enumerate(inv.move_line_receivable_ids):
inv_number = inv.get_invoice_fiscal_number().split("/")[-1].zfill(8)
numero_documento = inv_number + "/" + str(index + 1).zfill(2)
@@ -437,7 +455,7 @@ def register_payment(
for inv in self:
inv._compute_receivables()
- receivable_id = inv.move_line_receivable_id
+ receivable_id = inv.move_line_receivable_ids
receivable_id.residual = inv.residual
return res
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
index ccc7669ce917..d3e8ad7137aa 100644
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ b/l10n_br_account_payment_cobranca/reports/report.py
@@ -36,7 +36,7 @@
#
# if active_model == "account.invoice":
# for invoices in env["account.invoice"].browse(active_ids):
-# receivable_ids = invoices.mapped("move_line_receivable_id")
+# receivable_ids = invoices.mapped("move_line_receivable_ids")
# if receivable_ids:
# ids_move_lines = receivable_ids
# elif active_model == "account.move.line":
From 205106d118340a61d6191e14de3ac239516a2850 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Mon, 2 Mar 2020 19:02:20 -0300
Subject: [PATCH 191/612] [IMP] Operation type field in invoice and clean
invoice view
---
.../models/account_invoice.py | 18 +++++++++
.../models/res_company.py | 2 +-
.../views/account_invoice.xml | 37 +++++++++++--------
3 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 2cdc639e2b31..48279ec07cc4 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -68,6 +68,10 @@ def _compute_receivables(self):
readonly=True,
)
+ operation_type = fields.Selection(
+ related='payment_mode_id.operation_type',
+ )
+
def register_invoice_api(self):
""" Registrar o boleto via sua API"""
raise NotImplementedError
@@ -415,6 +419,20 @@ def invoice_validate(self):
filtered_invoice_ids.create_account_payment_line()
return result
+ @api.multi
+ def _prepare_new_payment_order(self, payment_mode=None):
+ vals = super(AccountInvoice, self)._prepare_new_payment_order(
+ payment_mode)
+ if payment_mode is None:
+ payment_mode = self.env['account.payment.mode']
+ vals.update(
+ {
+ 'operation_type': payment_mode.operation_type or
+ self.payment_mode_id.operation_type
+ }
+ )
+ return vals
+
@api.multi
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index 406cc346f7e1..5423b9c505d7 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -18,7 +18,7 @@ class ResCompany(models.Model):
(SEQUENCIAL_CARTEIRA, "Sequêncial único por carteira"),
],
string="Tipo de nosso número",
- default="2",
+ default=SEQUENCIAL_FATURA,
)
own_number_sequence = fields.Many2one(
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 362eaeafeba4..1ac13eff6648 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -45,25 +45,28 @@
view.l10n_br_account.invoice.form.form.inherit
account.invoice
+ ref="account_payment_order.invoice_form"/>
+
+ 1
+
-
+
@@ -71,7 +74,11 @@
-
+
+
+
+
+
-
-
-
+
+
+
From 637860d010d86305b65127677edd4dc950317a31 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Mon, 2 Mar 2020 19:03:43 -0300
Subject: [PATCH 192/612] [ADD] Company view for own_number_type field
---
.../views/res_company.xml | 36 +++++++++----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index ecfb9762951b..8ae4b80bb8f6 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -1,20 +1,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ l10n_br_account_payment_boleto.res.company.form
+
+ res.company
+
+
+
+
+
+
+
+
+
@@ -27,7 +27,7 @@
-
-
-
+
+
+
From 69eaddc42ce226e11cd021bb17dbcdf3cf627b3a Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Mon, 2 Mar 2020 19:19:01 -0300
Subject: [PATCH 193/612] [NEW] Demo data for cobranca
---
.../__manifest__.py | 2 +-
.../data/boleto_data.xml | 1 +
.../demo/l10n_br_payment_mode.xml | 41 +++++++++++++------
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 2a95eaabb4ad..560012a85575 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -40,7 +40,7 @@
"security/ir.model.access.csv",
],
"demo": [
- # 'demo/l10n_br_payment_mode.xml',
+ 'demo/l10n_br_payment_mode.xml',
],
"test": [
# 'tests/invoice_create.yml'
diff --git a/l10n_br_account_payment_cobranca/data/boleto_data.xml b/l10n_br_account_payment_cobranca/data/boleto_data.xml
index bca3e6d31ebd..12f79aba2510 100644
--- a/l10n_br_account_payment_cobranca/data/boleto_data.xml
+++ b/l10n_br_account_payment_cobranca/data/boleto_data.xml
@@ -11,6 +11,7 @@
+ 1
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index 6da79653ea0c..36ba7d8f5c32 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -2,11 +2,11 @@
-
+
Cobrança Bradesco240
-
+
+ ref="l10n_br_account_payment_order.main_company_bank_bradesco"/>
@@ -16,7 +16,11 @@
Pagavel em qualquer banco ate o
vencimento
- 3
+
+ variable
+ True
+
+ 3
06
03
DM
@@ -25,11 +29,11 @@
-
+
Cobrança Itau240
-
+
+ ref="l10n_br_account_payment_order.main_company_bank_itau"/>
@@ -39,7 +43,11 @@
Pagavel em qualquer banco ate o
vencimento
- 6
+
+ variable
+ True
+
+ 3
06
03
DM
@@ -48,11 +56,11 @@
-
+
Cobrança Cef240
-
+
+ ref="l10n_br_account_payment_order.main_company_bank_cef"/>
@@ -62,7 +70,11 @@
Pagavel em qualquer banco ate o
vencimento
- 11
+
+ variable
+ True
+
+ 3
06
03
DM
@@ -70,4 +82,9 @@
S
+
+
+
+
+
From 2785dc482628d22550dfe3e51efc522b833644d1 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Tue, 21 Apr 2020 16:42:52 -0300
Subject: [PATCH 194/612] [FIX] pre-commit improvements
---
.isort.cfg | 2 +-
.../__manifest__.py | 4 +--
.../constantes.py | 5 +--
.../models/account_invoice.py | 31 +++++++++----------
.../models/account_payment_line.py | 10 ++----
.../models/account_payment_mode.py | 8 ++---
.../models/account_payment_order.py | 4 +--
.../models/bank_payment_line.py | 10 ++----
.../models/l10n_br_cnab.py | 21 +++++++------
.../readme/DESCRIPTION.rst | 1 -
.../readme/HISTORY.rst | 6 ++--
11 files changed, 40 insertions(+), 62 deletions(-)
diff --git a/.isort.cfg b/.isort.cfg
index d89a563f407f..6bd177f35c7a 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,2 +1,2 @@
[settings]
-known_third_party = OpenSSL,dateutil,erpbrasil,lxml,odoo,pytz,requests,setuptools,workalendar
+known_third_party = OpenSSL,dateutil,erpbrasil,lxml,odoo,openerp,openupgradelib,pytz,requests,setuptools,workalendar
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 560012a85575..57b0b1a39c48 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -39,9 +39,7 @@
"reports/report_print_button_view.xml",
"security/ir.model.access.csv",
],
- "demo": [
- 'demo/l10n_br_payment_mode.xml',
- ],
+ "demo": ["demo/l10n_br_payment_mode.xml"],
"test": [
# 'tests/invoice_create.yml'
],
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index d13a26370513..272b716559d9 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -136,10 +136,7 @@
TRIBUTO_IPVA = ("25", "25 - Tributo - IPVA")
TRIBUTO_LICENCIAMENTO = ("26", "26 - Tributo - Licenciamento")
TRIBUTO_DPVAT = ("27", "27 - Tributo – DPVAT")
-LIQUIDACAO_TITULOS_PROPRIO_BANCO = (
- "30",
- "30 - Liquidação de Títulos do Próprio Banco",
-)
+LIQUIDACAO_TITULOS_PROPRIO_BANCO = ("30", "30 - Liquidação de Títulos do Próprio Banco")
PAGAMENTO_TITULOS_OUTROS_BANCOS = ("31", "31 - Pagamento de Títulos de Outros Bancos")
EXTRATO_CONTA_CORRENTE = ("40", "40 - Extrato de Conta Corrente")
TED_OUTRA_TITULARIDADE = ("41", "41 - TED – Outra Titularidade (1)")
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 48279ec07cc4..bfd70a908a50 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -18,22 +18,24 @@ class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.multi
- @api.depends('state', 'move_id.line_ids', 'move_id.line_ids.account_id')
+ @api.depends("state", "move_id.line_ids", "move_id.line_ids.account_id")
def _compute_receivables(self):
for record in self:
- lines = self.env['account.move.line']
+ lines = self.env["account.move.line"]
for line in record.move_id.line_ids:
- if (line.account_id.id == record.account_id.id and
- line.account_id.internal_type in
- ('receivable', 'payable')):
+ if (
+ line.account_id.id == record.account_id.id
+ and line.account_id.internal_type in ("receivable", "payable")
+ ):
lines |= line
record.move_line_receivable_ids = lines.sorted()
move_line_receivable_ids = fields.Many2many(
- comodel_name='account.move.line',
- string=u'Receivables',
+ comodel_name="account.move.line",
+ string=u"Receivables",
store=True,
- compute='_compute_receivables')
+ compute="_compute_receivables",
+ )
active = fields.Boolean(string="Ativo", default=True)
@@ -68,9 +70,7 @@ def _compute_receivables(self):
readonly=True,
)
- operation_type = fields.Selection(
- related='payment_mode_id.operation_type',
- )
+ operation_type = fields.Selection(related="payment_mode_id.operation_type")
def register_invoice_api(self):
""" Registrar o boleto via sua API"""
@@ -421,14 +421,13 @@ def invoice_validate(self):
@api.multi
def _prepare_new_payment_order(self, payment_mode=None):
- vals = super(AccountInvoice, self)._prepare_new_payment_order(
- payment_mode)
+ vals = super(AccountInvoice, self)._prepare_new_payment_order(payment_mode)
if payment_mode is None:
- payment_mode = self.env['account.payment.mode']
+ payment_mode = self.env["account.payment.mode"]
vals.update(
{
- 'operation_type': payment_mode.operation_type or
- self.payment_mode_id.operation_type
+ "operation_type": payment_mode.operation_type
+ or self.payment_mode_id.operation_type
}
)
return vals
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index b1113e0092ad..7bbe5e0b1829 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -66,14 +66,8 @@ def default_get(self, fields_list):
default=0.00,
)
mora = fields.Float(
- digits=(13, 2),
- string="Valor da Mora",
- help="Campo G047 do CNAB",
- default=0.00,
+ digits=(13, 2), string="Valor da Mora", help="Campo G047 do CNAB", default=0.00
)
multa = fields.Float(
- digits=(13, 2),
- string="Valor da Multa",
- help="Campo G048 do CNAB",
- default=0.00,
+ digits=(13, 2), string="Valor da Multa", help="Campo G048 do CNAB", default=0.00
)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index b92b7b623855..59302b67f802 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -27,9 +27,7 @@ class PaymentMode(models.Model):
selection=TIPO_SERVICO, string="Tipo de Serviço", help="Campo G025 do CNAB"
)
forma_lancamento = fields.Selection(
- selection=FORMA_LANCAMENTO,
- string="Forma Lançamento",
- help="Campo G029 do CNAB",
+ selection=FORMA_LANCAMENTO, string="Forma Lançamento", help="Campo G029 do CNAB"
)
codigo_convenio = fields.Char(
size=20,
@@ -124,9 +122,7 @@ class PaymentMode(models.Model):
string="Conta Padrão",
help="Conta padrão para Taxa",
)
- operation_type = fields.Selection(
- selection_add=[('3', 'Cobrança')]
- )
+ operation_type = fields.Selection(selection_add=[("3", "Cobrança")])
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index db3b8f5cc5e0..bcef979bede1 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -66,9 +66,7 @@ class PaymentOrder(models.Model):
readonly=True,
domain=[("is_erro_exportacao", "=", True)],
)
- operation_type = fields.Selection(
- selection_add=[('3', 'Cobrança')]
- )
+ operation_type = fields.Selection(selection_add=[("3", "Cobrança")])
def _confirm_debit_orders_api(self):
"""
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 8c4a9f92b6a1..8ff54e4079fe 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -63,16 +63,10 @@ def default_get(self, fields_list):
default=0.00,
)
mora = fields.Float(
- digits=(13, 2),
- string="Valor da Mora",
- help="Campo G047 do CNAB",
- default=0.00,
+ digits=(13, 2), string="Valor da Mora", help="Campo G047 do CNAB", default=0.00
)
multa = fields.Float(
- digits=(13, 2),
- string="Valor da Multa",
- help="Campo G048 do CNAB",
- default=0.00,
+ digits=(13, 2), string="Valor da Multa", help="Campo G048 do CNAB", default=0.00
)
evento_id = fields.One2many(
string="Eventos CNAB",
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index e80f7f3ce417..8540f564cdfe 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -673,15 +673,18 @@ def _get_name(self, data, filename):
cnab_ids = self.search([("data", "=", data)], order="id desc")
cnab_idx = 1
if cnab_ids:
- search_result = list(filter(
- lambda x: x is not None,
- [
- re.search(r"\((\d)\)", name)
- for name in self.search(
- [("data", "=", data), ("id", "!=", self.id)], order="id desc"
- ).mapped("name")
- ],
- ))
+ search_result = list(
+ filter(
+ lambda x: x is not None,
+ [
+ re.search(r"\((\d)\)", name)
+ for name in self.search(
+ [("data", "=", data), ("id", "!=", self.id)],
+ order="id desc",
+ ).mapped("name")
+ ],
+ )
+ )
if search_result:
cnab_idx = max(int(result.group(1)) for result in search_result) + 1
diff --git a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
index b85dad5190e7..3551f7975daf 100644
--- a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
+++ b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
@@ -2,4 +2,3 @@
This module extends the functionality of portal to support Brasilian
fields.
-
diff --git a/l10n_br_account_payment_cobranca/readme/HISTORY.rst b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
index ac1f5b674c68..48c062b9e448 100644
--- a/l10n_br_account_payment_cobranca/readme/HISTORY.rst
+++ b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
@@ -1,10 +1,10 @@
[ The change log. The goal of this file is to help readers
understand changes between version. The primary audience is
end users and integrators. Purely technical changes such as
- code refactoring must not be mentioned here.
-
+ code refactoring must not be mentioned here.
+
This file may contain ONE level of section titles, underlined
- with the ~ (tilde) character. Other section markers are
+ with the ~ (tilde) character. Other section markers are
forbidden and will likely break the structure of the README.rst
or other documents where this fragment is included. ]
From a21308e3699a9943d5fb52bfe8724764c3e1a284 Mon Sep 17 00:00:00 2001
From: Daniel Sadamo
Date: Tue, 21 Apr 2020 18:09:02 -0300
Subject: [PATCH 195/612] [FIX] pep8 + lint
---
.../models/account_invoice.py | 9 ++--
.../models/account_move_line.py | 3 +-
.../models/l10n_br_cnab.py | 53 ++++++++++---------
.../readme/CONFIGURE.rst | 12 +----
.../readme/CONTRIBUTORS.rst | 5 +-
.../readme/CREDITS.rst | 6 +--
.../readme/DESCRIPTION.rst | 6 +--
.../readme/HISTORY.rst | 24 ---------
.../readme/INSTALL.rst | 9 +---
.../readme/ROADMAP.rst | 5 --
.../readme/USAGE.rst | 12 +----
.../wizard/payment_order_create.py | 12 ++---
12 files changed, 52 insertions(+), 104 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index bfd70a908a50..68b0b90b3bdb 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -261,7 +261,9 @@ def create_api_account_payment_line(self):
new_payorder = False
if not payorder:
- payorder = apoo.create(inv._prepare_new_payment_order(payment_mode))
+ payorder = apoo.create(
+ inv._prepare_new_payment_order(payment_mode)
+ )
new_payorder = True
payorder.name += "_api"
payorder.active = False
@@ -384,10 +386,11 @@ def create_account_payment_line_baixa(self):
new_payorder = False
if not payorder:
- payorder = apoo.create(inv._prepare_new_payment_order(payment_mode))
+ payorder = apoo.create(
+ inv._prepare_new_payment_order(payment_mode)
+ )
new_payorder = True
result_payorder_ids.append(payorder.id)
- action_payment_type = payorder.payment_type
count = 0
for line in applicable_lines.filtered(
lambda x: x.payment_mode_id == payment_mode
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index f3329b32fd6b..41d9a0db6b5d 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -4,8 +4,7 @@
import logging
-from odoo import _, api, fields, models
-from odoo.exceptions import UserError
+from odoo import api, fields, models
_logger = logging.getLogger(__name__)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 8540f564cdfe..d5a2cdecb70b 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -89,23 +89,24 @@
RETORNO_400_BAIXA,
]
-# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03 NA POSIÇÃO 109-110
+# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03
+# NA POSIÇÃO 109-110
COD_REGISTROS_REJEITADOS_CNAB400 = {
3: "AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO",
4: "ESTADO - SIGLA DO ESTADO INVÁLIDA",
- 5: "DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO",
+ 5: "DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO", # noqa
7: "VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00",
8: "NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO",
9: "AGENCIA/CONTA - AGÊNCIA ENCERRADA",
10: "LOGRADOURO - NÃO INFORMADO OU DESLOCADO",
11: "CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO",
- 12: "SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)",
+ 12: "SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)", # noqa
13: "ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO",
- 14: "NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA",
+ 14: "NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA", # noqa
15: "NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO",
18: "DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA",
19: "OCORRÊNCIA - OCORRÊNCIA INVÁLIDA",
- 21: "AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO",
+ 21: "AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO", # noqa
22: "CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)",
26: "AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA",
27: "CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA",
@@ -118,14 +119,14 @@
42: "NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA",
52: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE",
53: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM",
- 54: "DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS",
+ 54: "DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS", # noqa
55: "DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA",
56: "DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA",
- 57: "DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS",
+ 57: "DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS", # noqa
60: "ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO",
61: "JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO",
62: "DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO",
- 63: "DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO",
+ 63: "DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO", # noqa
64: "DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA",
65: "TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)",
66: "DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)",
@@ -133,19 +134,19 @@
68: "CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA",
69: "CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO",
70: "AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO",
- 78: "AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO",
- 80: "AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)",
+ 78: "AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO", # noqa
+ 80: "AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)", # noqa
81: "AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ",
- 82: "DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO",
- 83: "VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO",
- 84: "AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO",
- 85: "AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO",
- 86: "TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO",
- 87: "AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO",
- 90: "NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS",
- 97: "SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8",
- 98: "FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO",
- 99: "FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE",
+ 82: "DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
+ 83: "VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO", # noqa
+ 84: "AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO", # noqa
+ 85: "AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO", # noqa
+ 86: "TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
+ 87: "AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO", # noqa
+ 90: "NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS", # noqa
+ 97: "SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8", # noqa
+ 98: "FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO", # noqa
+ 99: "FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE", # noqa
}
@@ -392,7 +393,8 @@ def _lote_400(self, evento, lote_id):
"name": evento.nosso_numero,
"nosso_numero": evento.nosso_numero,
"numero_documento": evento.numero_documento,
- "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "identificacao_titulo_empresa":
+ evento.identificacao_titulo_empresa,
"credit": float(evento.valor_principal)
+ float(evento.tarifa_cobranca),
"account_id": invoice.payment_mode_id.default_account_id.id
@@ -427,8 +429,9 @@ def _lote_400(self, evento, lote_id):
"name": str(evento.nosso_numero) + " - Tarifa",
"credit": 0,
"debit": float(evento.tarifa_cobranca),
- "account_id": invoice.payment_mode_id.default_tax_account_id.id
- or invoice.account_id.id,
+ "account_id": invoice.payment_mode_id.\
+ default_tax_account_id.id
+ or invoice.account_id.id,
}
)
line_values.append((0, 0, line_dict_tarifa))
@@ -593,7 +596,6 @@ def _reprocessa_lote_400(self, evento, lote_id):
else:
cnab_event_id.write(vals_evento)
- amount = 0.0
codigo_ocorrencia = evento.codigo_ocorrencia
if codigo_ocorrencia and bank_payment_line_id:
@@ -632,7 +634,8 @@ def _reprocessa_lote_400(self, evento, lote_id):
"name": evento.nosso_numero,
"nosso_numero": evento.nosso_numero,
"numero_documento": evento.numero_documento,
- "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
+ "identificacao_titulo_empresa":
+ evento.identificacao_titulo_empresa,
"date_maturity": datetime.strptime(
str(evento.vencimento).zfill(6), STR_EVENTO_FORMAT
)
diff --git a/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst b/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
index 754e51aeff53..e696e12f1b14 100644
--- a/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
+++ b/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
@@ -1,10 +1,2 @@
-[ This file is optional, it should explain how to configure
- the module before using it; it is aimed at advanced users. ]
-
-To configure this module, you need to:
-
-#. Go to ...
-
-.. figure:: ../static/description/image.png
- :alt: alternative description
- :width: 600 px
++ In a multicompany environment, make sure the sequences payment line and payment order are with the company set to the one you'll use to export the payments and charges.
+ If they are not set like this, you'll not be able to add payment lines with regular users.
diff --git a/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst b/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
index 786f0d6dc9ba..05178524a5a4 100644
--- a/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
+++ b/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
@@ -1,2 +1,3 @@
-* Firstname Lastname (optional company website url)
-* Second Person (optional company website url)
+* Luis Felipe Mileo
+* Fernando Marcato Rodrigues
+* Daniel Sadamo
diff --git a/l10n_br_account_payment_cobranca/readme/CREDITS.rst b/l10n_br_account_payment_cobranca/readme/CREDITS.rst
index 505af5aae590..f41358165b2f 100644
--- a/l10n_br_account_payment_cobranca/readme/CREDITS.rst
+++ b/l10n_br_account_payment_cobranca/readme/CREDITS.rst
@@ -1,7 +1,3 @@
-[ This file is optional and contains additional credits, other than
- authors, contributors, and maintainers. ]
-
The development of this module has been financially supported by:
-* Company 1 name
-* Company 2 name
+* KMEE INFORMATICA LTDA - www.kmee.com.br
diff --git a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
index 3551f7975daf..20192db33f48 100644
--- a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
+++ b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
@@ -1,4 +1,2 @@
-[ This file must be max 2-3 paragraphs, and is required. ]
-
-This module extends the functionality of portal to support Brasilian
-fields.
+This module provide an infrastructure to export payment and debit orders in
+Febraban layout.
diff --git a/l10n_br_account_payment_cobranca/readme/HISTORY.rst b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
index 48c062b9e448..e69de29bb2d1 100644
--- a/l10n_br_account_payment_cobranca/readme/HISTORY.rst
+++ b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
@@ -1,24 +0,0 @@
-[ The change log. The goal of this file is to help readers
- understand changes between version. The primary audience is
- end users and integrators. Purely technical changes such as
- code refactoring must not be mentioned here.
-
- This file may contain ONE level of section titles, underlined
- with the ~ (tilde) character. Other section markers are
- forbidden and will likely break the structure of the README.rst
- or other documents where this fragment is included. ]
-
-11.0.x.y.z (YYYY-MM-DD)
-~~~~~~~~~~~~~~~~~~~~~~~
-
-* [BREAKING] Breaking changes come first.
- (`#70 `_)
-* [ADD] New feature.
- (`#74 `_)
-* [FIX] Correct this.
- (`#71 `_)
-
-11.0.x.y.z (YYYY-MM-DD)
-~~~~~~~~~~~~~~~~~~~~~~~
-
-* ...
diff --git a/l10n_br_account_payment_cobranca/readme/INSTALL.rst b/l10n_br_account_payment_cobranca/readme/INSTALL.rst
index b62c6d1e9530..1ab71ca70369 100644
--- a/l10n_br_account_payment_cobranca/readme/INSTALL.rst
+++ b/l10n_br_account_payment_cobranca/readme/INSTALL.rst
@@ -1,7 +1,2 @@
-[ This file must only be present if there are very specific
- installation instructions, such as installing non-python
- dependencies. The audience is systems administrators. ]
-
-To install this module, you need to:
-
-#. Do this ...
+This module depends on :
+* l10n_br_account_payment_order
diff --git a/l10n_br_account_payment_cobranca/readme/ROADMAP.rst b/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
index 207233013b40..e69de29bb2d1 100644
--- a/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
+++ b/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
@@ -1,5 +0,0 @@
-[ Enumerate known caveats and future potential improvements.
- It is mostly intended for end-users, and can also help
- potential new contributors discovering new features to implement. ]
-
-* ...
diff --git a/l10n_br_account_payment_cobranca/readme/USAGE.rst b/l10n_br_account_payment_cobranca/readme/USAGE.rst
index f4629c3d548a..96bfc78306b3 100644
--- a/l10n_br_account_payment_cobranca/readme/USAGE.rst
+++ b/l10n_br_account_payment_cobranca/readme/USAGE.rst
@@ -1,11 +1 @@
-[ This file must be present and contains the usage instructions
- for end-users. As all other rst files included in the README,
- it MUST NOT contain reStructuredText sections
- only body text (paragraphs, lists, tables, etc). Should you need
- a more elaborate structure to explain the addon, please create a
- Sphinx documentation (which may include this file as a "quick start"
- section). ]
-
-To use this module, you need to:
-
-#. Go to ...
+This module adds a Payment type "Cobrança" and related configuration fields in Payment Mode
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
index 3aabeccbd778..7c226a5e0965 100644
--- a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
+++ b/l10n_br_account_payment_cobranca/wizard/payment_order_create.py
@@ -88,12 +88,12 @@ def _prepare_move_line_domain(self):
# Exclude lines that are already in a non-cancelled
# and non-uploaded payment order; lines that are in a
# uploaded payment order are proposed if they are not reconciled,
- paylines = self.env["account.payment.line"].search(
- [
- ("state", "in", ("draft", "open", "generated", "uploaded")),
- ("move_line_id", "!=", False),
- ]
- )
+ # paylines = self.env["account.payment.line"].search(
+ # [
+ # ("state", "in", ("draft", "open", "generated", "uploaded")),
+ # ("move_line_id", "!=", False),
+ # ]
+ # )
move_line_domain = ["draft"]
if self.allow_error:
From 2aa3cc74bda9b3fddd3806117d048193124dc91f Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 3 Jun 2020 09:54:01 -0300
Subject: [PATCH 196/612] [12.0][MIG][FIX] PEP8.
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index d5a2cdecb70b..a6821faf26bf 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -429,9 +429,9 @@ def _lote_400(self, evento, lote_id):
"name": str(evento.nosso_numero) + " - Tarifa",
"credit": 0,
"debit": float(evento.tarifa_cobranca),
- "account_id": invoice.payment_mode_id.\
- default_tax_account_id.id
- or invoice.account_id.id,
+ "account_id":
+ invoice.payment_mode_id.default_tax_account_id.id
+ or invoice.account_id.id,
}
)
line_values.append((0, 0, line_dict_tarifa))
From 19b18e691cb09381baf15d09c9b821801024e7c5 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 17 Jun 2020 17:03:57 -0300
Subject: [PATCH 197/612] [12.0][MIG][FIX] Paylines can have more than one ID.
---
.../models/account_payment_order.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index bcef979bede1..d02ee4c7a94a 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -88,11 +88,11 @@ def _confirm_debit_orders_api(self):
@api.model
def _prepare_bank_payment_line(self, paylines):
- result = super(PaymentOrder, self)._prepare_bank_payment_line(paylines)
- result["nosso_numero"] = paylines.nosso_numero
- result["numero_documento"] = paylines.numero_documento
- result["identificacao_titulo_empresa"] = paylines.identificacao_titulo_empresa
- result["ultimo_estado_cnab"] = paylines.move_line_id.state_cnab
+ result = super()._prepare_bank_payment_line(paylines)
+ result["nosso_numero"] = paylines[0].nosso_numero
+ result["numero_documento"] = paylines[0].numero_documento
+ result["identificacao_titulo_empresa"] = paylines[0].identificacao_titulo_empresa
+ result["ultimo_estado_cnab"] = paylines.move_line_id[0].state_cnab
return result
@api.multi
From 6537c826ddb528ec7ec57116a9bff3ec67565c44 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 18 Jun 2020 16:43:30 -0300
Subject: [PATCH 198/612] [12.0][MIG][REF] Included field for CNAB Sequence.
---
.../__manifest__.py | 67 ++++++++++---------
.../data/cnab_data.xml | 12 ++++
.../models/account_payment_mode.py | 4 ++
3 files changed, 50 insertions(+), 33 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/data/cnab_data.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 57b0b1a39c48..eeeb5cf70792 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -6,43 +6,44 @@
{
- "name": "Account Payment CNAB",
- "version": "12.0.1.0.0",
- "category": "Banking addons",
- "license": "AGPL-3",
- "author": "KMEE, Odoo Community Association (OCA)",
- "website": "http://www.kmee.com.br",
- "depends": ["l10n_br_account_payment_order"],
- "data": [
- "data/l10n_br_payment_export_type.xml",
- "data/boleto_data.xml",
- "data/ir_cron.xml",
- "data/account_analytic_tag_data.xml",
- "security/cnab_cobranca_security.xml",
- "views/res_company.xml",
- "views/account_payment_mode.xml",
- "views/res_partner_bank.xml",
- "views/account_payment_order.xml",
- "views/account_payment_order_menu_views.xml",
- "views/account_payment_line.xml",
- "views/account_payment_term_view.xml",
- "views/bank_payment_line.xml",
- "views/account_invoice.xml",
- "views/bank_api_operation_views.xml",
- "views/account_move_line.xml",
- "views/l10n_br_cnab_retorno_view.xml",
- "views/l10n_br_cnab_evento_views.xml",
+ 'name': 'Account Payment CNAB',
+ 'version': '12.0.1.0.0',
+ 'category': 'Banking addons',
+ 'license': 'AGPL-3',
+ 'author': 'KMEE, Odoo Community Association (OCA)',
+ 'website': 'http://www.kmee.com.br',
+ 'depends': ['l10n_br_account_payment_order'],
+ 'data': [
+ 'data/l10n_br_payment_export_type.xml',
+ 'data/boleto_data.xml',
+ 'data/ir_cron.xml',
+ 'data/account_analytic_tag_data.xml',
+ 'security/cnab_cobranca_security.xml',
+ 'views/res_company.xml',
+ 'views/account_payment_mode.xml',
+ 'views/res_partner_bank.xml',
+ 'views/account_payment_order.xml',
+ 'views/account_payment_order_menu_views.xml',
+ 'views/account_payment_line.xml',
+ 'views/account_payment_term_view.xml',
+ 'views/bank_payment_line.xml',
+ 'views/account_invoice.xml',
+ 'views/bank_api_operation_views.xml',
+ 'views/account_move_line.xml',
+ 'views/l10n_br_cnab_retorno_view.xml',
+ 'views/l10n_br_cnab_evento_views.xml',
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
- "wizard/payment_order_create_wizard.xml",
- "reports/report_print_button_view.xml",
- "security/ir.model.access.csv",
+ 'wizard/payment_order_create_wizard.xml',
+ 'reports/report_print_button_view.xml',
+ 'security/ir.model.access.csv',
+ 'data/cnab_data.xml',
],
- "demo": ["demo/l10n_br_payment_mode.xml"],
- "test": [
+ 'demo': ['demo/l10n_br_payment_mode.xml'],
+ 'test': [
# 'tests/invoice_create.yml'
],
- "installable": True,
- "auto_install": False,
+ 'installable': True,
+ 'auto_install': False,
}
diff --git a/l10n_br_account_payment_cobranca/data/cnab_data.xml b/l10n_br_account_payment_cobranca/data/cnab_data.xml
new file mode 100644
index 000000000000..2674d3f4f78d
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/data/cnab_data.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Sequencia CNAB
+ Sequencia CNAB
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 59302b67f802..50af93998472 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -123,6 +123,10 @@ class PaymentMode(models.Model):
help="Conta padrão para Taxa",
)
operation_type = fields.Selection(selection_add=[("3", "Cobrança")])
+ cnab_sequence_id = fields.Many2one(
+ comodel_name='ir.sequence',
+ string=u'Sequencia do CNAB')
+
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
From e3f2d14d1cbf8a25bff9b8b3d2a3460fec42e6d0 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 18 Jun 2020 16:48:49 -0300
Subject: [PATCH 199/612] [12.0][MIG][REF][IMP] Demo data.
---
.../demo/l10n_br_payment_mode.xml | 328 +++++++++++++++---
1 file changed, 285 insertions(+), 43 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index 36ba7d8f5c32..3d1cabd0bfb0 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -1,90 +1,332 @@
-
-
- Cobrança Bradesco240
-
-
+
+
+
+
+ Banco Bradesco
+ bank
+ BNC2
+
+
+
+
+
+
+ Banco Unicred
+ bank
+ BN3
+
+
+
+
+
+
+ Banco Itau
+ bank
+ BNC3
+
+
+
+
+
+
+ Banco do Brasil
+ bank
+ BNC3
+
+
+
+
+
+
+ Banco Caixa Economica Federal
+ bank
+ BNC3
+
+
+
+
+
+
+
+
+ Cobrança Bradesco400
- Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
-
-
+ 3
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Unicred400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 3
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Unicred240
+
+
00
Pagavel em qualquer banco ate o
vencimento
-
- variable
+ fixed
+
True
-
+
3
06
- 03
+ 3
DM
19
- S
+ S
+
-
+
Cobrança Itau240
-
-
-
-
-
00
Pagavel em qualquer banco ate o
vencimento
-
- variable
+ fixed
+
True
-
+
3
06
- 03
+ 3
DM
19
- S
+ S
+
-
+
- Cobrança Cef240
-
-
+ Cobrança Caixa Economica Federal 240
- Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
-
-
- 00
+ 3
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Itau400
+
Pagavel em qualquer banco ate o
vencimento
-
- variable
+ fixed
+
True
-
+
3
06
- 03
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Banco do Brasil 400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 3
+ 06
+ 3
DM
19
- S
+ S
+
-
+
+
+
-
+
+
+
+
+
+ Teste Itau CNAB240
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Itau CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Unicred CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Caixa Economica Federal CNAB240
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Banco do Brasil CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
From bba9cda00ac09a400c5a2b2001deff4717de9f04 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 18 Jun 2020 16:55:39 -0300
Subject: [PATCH 200/612] [12.0][MIG][FIX] Included field CNAB Sequence on the
view.
---
l10n_br_account_payment_cobranca/views/account_payment_mode.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 775dc09022d2..dec762a886fb 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -19,6 +19,7 @@
+
From cc592195d71452b37a49fbdc70e366b32c42ece1 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 16:10:42 -0300
Subject: [PATCH 201/612] [12.0][MIG][FIX] Demo data.
---
l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index 3d1cabd0bfb0..be1942b4fb37 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -107,9 +107,7 @@
Cobrança Unicred240
-
- 00
Pagavel em qualquer banco ate o
vencimento
@@ -132,7 +130,6 @@
Cobrança Itau240
- 00
Pagavel em qualquer banco ate o
vencimento
From 6f8a5192f7a458c54d6ded9a670e3e1943423987 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 16:12:43 -0300
Subject: [PATCH 202/612] [12.0][MIG][REF] Removed unused Demo data.
---
.../demo/payment_demo.xml | 162 ------------------
1 file changed, 162 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/demo/payment_demo.xml
diff --git a/l10n_br_account_payment_cobranca/demo/payment_demo.xml b/l10n_br_account_payment_cobranca/demo/payment_demo.xml
deleted file mode 100644
index 89be7a91ceaa..000000000000
--- a/l10n_br_account_payment_cobranca/demo/payment_demo.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-
-
-
- Boleto sem registro Banco do Brasil
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 1
- 27
- 18
- DM
- 29
-
-
-
-
- Boleto sem registro Bradesco
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 3
- 06
- 03
- DM
- 19
-
-
-
-
- Boleto sem registro HSBC
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 5
-
- CNR
- PD
-
-
-
-
-
- Boleto sem registro ITAU
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 7
- 99999999
- 109
- DM
-
-
-
-
-
-
- Boleto sem registro Santander
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 9
-
- 102
- DM
-
-
-
-
-
- Boleto sem registro Caixa Economica SR
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 4
-
- SR
-
-
-
-
-
-
- Boleto sem registro Caixa Economica SR
-
-
-
-
-
-
- 00
- Pagavel em qualquer banco ate o
- vencimento
-
- 11
-
- SR
-
-
-
-
-
-
From e7059051275e9b54a53c76628e352a38118d1922 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 16:27:50 -0300
Subject: [PATCH 203/612] [12.0][MIG][IMP] Included fields used in Boletos from
Sicred, Unicred and Sicoob banks.
---
.../demo/l10n_br_payment_mode.xml | 4 ++++
.../models/account_payment_mode.py | 12 +++++++++++-
.../views/account_payment_mode.xml | 2 ++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index be1942b4fb37..756ff9ad5b22 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -102,6 +102,8 @@
S
+ 2
+ 01
@@ -124,6 +126,8 @@
S
+ 2
+ 01
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 50af93998472..002ed3a90510 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -126,7 +126,17 @@ class PaymentMode(models.Model):
cnab_sequence_id = fields.Many2one(
comodel_name='ir.sequence',
string=u'Sequencia do CNAB')
-
+ boleto_byte_idt = fields.Char(
+ string='Byte IDT', size=1,
+ help='Byte de identificação do cedente do bloqueto'
+ ' utilizado para compor o nosso número,'
+ ' usado pelos bancos Sicred/Unicred e Sicoob'
+ )
+ boleto_posto = fields.Char(
+ string='Posto da Cooperativa de Crédito', size=2,
+ help='Código do Posto da Cooperativa de Crédito,'
+ ' usado pelos bancos Sicred/Unicred e Sicoob.'
+ )
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index dec762a886fb..6e67352ed3e0 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -36,6 +36,8 @@
+
+
From 103eb87f0b5ddf7a3315c9279c8dbdcc20a4b2a3 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 16:48:56 -0300
Subject: [PATCH 204/612] [12.0][MIG][REF] Split Demo data by model.
---
.../__manifest__.py | 6 +-
.../demo/account_invoice_demo.xml | 116 ++++++++++++
.../demo/account_journal_demo.xml | 61 +++++++
.../demo/l10n_br_payment_mode.xml | 171 +-----------------
4 files changed, 183 insertions(+), 171 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml
create mode 100644 l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index eeeb5cf70792..c73a6138c58d 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -40,7 +40,11 @@
'security/ir.model.access.csv',
'data/cnab_data.xml',
],
- 'demo': ['demo/l10n_br_payment_mode.xml'],
+ 'demo': [
+ 'demo/account_journal_demo.xml',
+ 'demo/l10n_br_payment_mode.xml',
+ 'demo/account_invoice_demo.xml',
+ ],
'test': [
# 'tests/invoice_create.yml'
],
diff --git a/l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml b/l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml
new file mode 100644
index 000000000000..81b4352ab16c
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Teste Itau CNAB240
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Itau CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Unicred CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Caixa Economica Federal CNAB240
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+ Teste Banco do Brasil CNAB400
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml b/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
new file mode 100644
index 000000000000..d52d64a19d1f
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+ Banco Bradesco
+ bank
+ BNC2
+
+
+
+
+
+
+ Banco Unicred
+ bank
+ BN3
+
+
+
+
+
+
+ Banco Itau
+ bank
+ BNC3
+
+
+
+
+
+
+ Banco do Brasil
+ bank
+ BNC3
+
+
+
+
+
+
+ Banco Caixa Economica Federal
+ bank
+ BNC3
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
index 756ff9ad5b22..812320a83d56 100644
--- a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
@@ -1,63 +1,6 @@
-
-
-
-
- Banco Bradesco
- bank
- BNC2
-
-
-
-
-
-
- Banco Unicred
- bank
- BN3
-
-
-
-
-
-
- Banco Itau
- bank
- BNC3
-
-
-
-
-
-
- Banco do Brasil
- bank
- BNC3
-
-
-
-
-
-
- Banco Caixa Economica Federal
- bank
- BNC3
-
-
-
-
@@ -218,116 +161,4 @@
ref="l10n_br_account_payment_cobranca.sequence_cnab_number"/>
-
-
-
-
-
-
-
-
-
- Teste Itau CNAB240
-
-
- out_invoice
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
-
-
-
- Teste Itau CNAB400
-
-
- out_invoice
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
-
-
-
- Teste Unicred CNAB400
-
-
- out_invoice
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
-
-
-
- Teste Caixa Economica Federal CNAB240
-
-
- out_invoice
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
-
-
-
- Teste Banco do Brasil CNAB400
-
-
- out_invoice
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
-
-
+
From 505feff4c2cb339b9700ca2654f91d6130db4015 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 16:51:49 -0300
Subject: [PATCH 205/612] [12.0][MIG][REF] Rename demo data by model.
---
l10n_br_account_payment_cobranca/__manifest__.py | 2 +-
.../{l10n_br_payment_mode.xml => account_payment_mode_demo.xml} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename l10n_br_account_payment_cobranca/demo/{l10n_br_payment_mode.xml => account_payment_mode_demo.xml} (100%)
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index c73a6138c58d..8770f5fcae4e 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -42,7 +42,7 @@
],
'demo': [
'demo/account_journal_demo.xml',
- 'demo/l10n_br_payment_mode.xml',
+ 'demo/account_payment_mode_demo.xml',
'demo/account_invoice_demo.xml',
],
'test': [
diff --git a/l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/demo/l10n_br_payment_mode.xml
rename to l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
From a9c2ec6c4a62d4722176cbd623e1d3c311aeb75f Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 22 Jun 2020 17:36:09 -0300
Subject: [PATCH 206/612] [12.0][MIG][REF] Constants.
---
.../constantes.py | 224 ++++++++++++++++++
.../models/account_move_line.py | 24 +-
.../models/account_payment_mode.py | 19 +-
.../models/l10n_br_cnab.py | 176 +-------------
.../models/l10n_br_cnab_evento.py | 4 +-
.../models/l10n_br_cnab_lote.py | 4 +-
.../models/res_partner_bank.py | 11 +-
7 files changed, 240 insertions(+), 222 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 272b716559d9..9f40fbb23ffa 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -467,3 +467,227 @@
("ZJ", "ZJ - Limite de pagamentos parciais excedido"),
("ZK", "ZK - Boleto já liquidado"),
]
+
+ESTADOS_CNAB = [
+ ("draft", "Inicial"),
+ ("added", "Adicionada à ordem de pagamento"),
+ ("added_paid", "Adicionada para Baixa"),
+ ("exported", "Exportada"),
+ ("exporting_error", "Erro ao exportar"),
+ ("accepted", "Aceita"),
+ ("accepted_hml", "Aceita em Homologação"),
+ ("not_accepted", "Não aceita pelo banco"),
+ ("done", "Concluído"),
+]
+
+SITUACAO_PAGAMENTO = [
+ ("inicial", "Inicial"),
+ ("aberta", "Aberta"),
+ ("paga", "Paga"),
+ ("liquidada", "Liquidada"),
+ ("baixa", "Baixa Simples"),
+ ("baixa_liquidacao", "Baixa por Liquidação em Dinheiro"),
+]
+
+BOLETO_ESPECIE = [
+ ("01", "DUPLICATA MERCANTIL"),
+ ("02", "NOTA PROMISSÓRIA"),
+ ("03", "NOTA DE SEGURO"),
+ ("04", "MENSALIDADE ESCOLAR"),
+ ("05", "RECIBO"),
+ ("06", "CONTRATO"),
+ ("07", "COSSEGUROS"),
+ ("08", "DUPLICATA DE SERVIÇO"),
+ ("09", "LETRA DE CÂMBIO"),
+ ("13", "NOTA DE DÉBITOS"),
+ ("15", "DOCUMENTO DE DÍVIDA"),
+ ("16", "ENCARGOS CONDOMINIAIS"),
+ ("17", "CONTA DE PRESTAÇÃO DE SERVIÇOS"),
+ ("99", "DIVERSOS"),
+]
+
+TIPO_DE_CONTA = [
+ ("01", "Conta corrente individual"),
+ ("02", "Conta poupança individual"),
+ ("03", "Conta depósito judicial/Depósito em consignação " "individual"),
+ ("11", "Conta corrente conjunta"),
+ ("12", "Conta poupança conjunta"),
+ ("13", "Conta depósito judicial/Depósito em consignação " "conjunta"),
+]
+
+STATE_CNAB = [("draft", "Novo"), ("done", "Processado"), ("error", "Erro no Processamento")]
+
+TIPO_OPERACAO_CNAB = {
+ "C": "Lançamento a Crédito",
+ "D": "Lançamento a Débito",
+ "E": "Extrato para Conciliação",
+ "G": "Extrato para Gestão de Caixa",
+ "I": "Informações de Títulos Capturados do Próprio Banco",
+ "R": "Arquivo Remessa",
+ "T": "Arquivo Retorno",
+}
+RETORNO_400_CONFIRMADA = [2]
+
+RETORNO_400_REJEITADA = [3]
+
+RETORNO_400_LIQUIDACAO = [
+ 6,
+ # 7, TODO: Implementar a baixa parcial;
+ 8,
+]
+
+RETORNO_400_BAIXA = [9, 10]
+
+RETORNOS_TRATADOS = [
+ RETORNO_400_CONFIRMADA,
+ RETORNO_400_REJEITADA,
+ RETORNO_400_LIQUIDACAO,
+ RETORNO_400_BAIXA,
+]
+
+# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03
+# NA POSIÇÃO 109-110
+COD_REGISTROS_REJEITADOS_CNAB400 = {
+ 3: "AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO",
+ 4: "ESTADO - SIGLA DO ESTADO INVÁLIDA",
+ 5: "DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO", # noqa
+ 7: "VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00",
+ 8: "NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO",
+ 9: "AGENCIA/CONTA - AGÊNCIA ENCERRADA",
+ 10: "LOGRADOURO - NÃO INFORMADO OU DESLOCADO",
+ 11: "CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO",
+ 12: "SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)", # noqa
+ 13: "ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO",
+ 14: "NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA", # noqa
+ 15: "NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO",
+ 18: "DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA",
+ 19: "OCORRÊNCIA - OCORRÊNCIA INVÁLIDA",
+ 21: "AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO", # noqa
+ 22: "CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)",
+ 26: "AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA",
+ 27: "CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA",
+ 29: "CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA",
+ 30: "ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA",
+ 31: "AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)",
+ 35: "VALOR DO IOF - IOF MAIOR QUE 5%",
+ 36: "QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO",
+ 37: "CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS",
+ 42: "NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA",
+ 52: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE",
+ 53: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM",
+ 54: "DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS", # noqa
+ 55: "DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA",
+ 56: "DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA",
+ 57: "DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS", # noqa
+ 60: "ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO",
+ 61: "JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO",
+ 62: "DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO",
+ 63: "DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO", # noqa
+ 64: "DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA",
+ 65: "TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)",
+ 66: "DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)",
+ 67: "VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO",
+ 68: "CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA",
+ 69: "CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO",
+ 70: "AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO",
+ 78: "AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO", # noqa
+ 80: "AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)", # noqa
+ 81: "AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ",
+ 82: "DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
+ 83: "VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO", # noqa
+ 84: "AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO", # noqa
+ 85: "AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO", # noqa
+ 86: "TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
+ 87: "AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO", # noqa
+ 90: "NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS", # noqa
+ 97: "SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8", # noqa
+ 98: "FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO", # noqa
+ 99: "FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE", # noqa
+}
+
+
+CODIGO_OCORRENCIAS_CNAB200 = {
+ 2: "ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)", # noqa
+ 3: "ENTRADA REJEITADA (NOTA 20 – TABELA 1)", # noqa
+ 4: "ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA", # noqa
+ 5: "ALTERAÇÃO DE DADOS – BAIXA",
+ 6: "LIQUIDAÇÃO NORMAL",
+ 7: "LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)",
+ 8: "LIQUIDAÇÃO EM CARTÓRIO",
+ 9: "BAIXA SIMPLES",
+ 10: "BAIXA POR TER SIDO LIQUIDADO",
+ 11: "EM SER (SÓ NO RETORNO MENSAL)",
+ 12: "ABATIMENTO CONCEDIDO",
+ 13: "ABATIMENTO CANCELADO",
+ 14: "VENCIMENTO ALTERADO",
+ 15: "BAIXAS REJEITADAS (NOTA 20 – TABELA 4)",
+ 16: "INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)",
+ 17: "ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)",
+ 18: "COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)", # noqa
+ 19: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO",
+ 20: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA",
+ 21: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR",
+ 23: "TÍTULO ENVIADO A CARTÓRIO/TARIFA",
+ 24: "INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)", # noqa
+ 25: "ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)",
+ 26: "TARIFA DE AVISO DE COBRANÇA",
+ 27: "TARIFA DE EXTRATO POSIÇÃO (B40X)",
+ 28: "TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES",
+ 29: "TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS",
+ 30: "DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)",
+ 32: "BAIXA POR TER SIDO PROTESTADO",
+ 33: "CUSTAS DE PROTESTO",
+ 34: "CUSTAS DE SUSTAÇÃO",
+ 35: "CUSTAS DE CARTÓRIO DISTRIBUIDOR",
+ 36: "CUSTAS DE EDITAL",
+ 37: "TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA",
+ 38: "TARIFA DE INSTRUÇÃO",
+ 39: "TARIFA DE OCORRÊNCIAS",
+ 40: "TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA", # noqa
+ 41: "DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)",
+ 42: "DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES",
+ 43: "DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS",
+ 44: "DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS",
+ 45: "DÉBITO MENSAL DE TARIFAS – PROTESTO",
+ 46: "DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO",
+ 47: "BAIXA COM TRANSFERÊNCIA PARA DESCONTO",
+ 48: "CUSTAS DE SUSTAÇÃO JUDICIAL",
+ 51: "TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA",
+ 52: "TARIFA MENSAL BAIXAS NA CARTEIRA",
+ 53: "TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA",
+ 54: "TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA",
+ 55: "TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA",
+ 56: "CUSTAS DE IRREGULARIDADE",
+ 57: "INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)",
+ 59: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG",
+ 60: "ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)",
+ 61: "TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
+ 62: "DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
+ 63: "TÍTULO SUSTADO JUDICIALMENTE",
+ 64: "ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO",
+ 65: "PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO",
+ 69: "CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)",
+ 71: "ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO",
+ 72: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE",
+ 73: "CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL", # noqa
+ 74: "INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)",
+ 75: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
+ 76: "CHEQUE COMPENSADO",
+ 77: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
+ 78: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA", # noqa
+ 79: "NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)",
+ 80: "CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA",
+ 82: "CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA",
+ 83: "CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA", # noqa
+ 85: "TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
+ 86: "TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA",
+ 87: "TARIFA SMS COBRANÇA ATIVA ELETRÔNICA",
+ 88: "TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
+ 89: "TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA",
+ 90: "TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA",
+ 91: "TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA",
+ 92: "TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA",
+ 93: "TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO",
+}
+
+STR_EVENTO_FORMAT = "%d%m%y"
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 41d9a0db6b5d..7da420a62b79 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -6,29 +6,9 @@
from odoo import api, fields, models
-_logger = logging.getLogger(__name__)
-
+from ..constantes import ESTADOS_CNAB, SITUACAO_PAGAMENTO
-ESTADOS_CNAB = [
- ("draft", "Inicial"),
- ("added", "Adicionada à ordem de pagamento"),
- ("added_paid", "Adicionada para Baixa"),
- ("exported", "Exportada"),
- ("exporting_error", "Erro ao exportar"),
- ("accepted", "Aceita"),
- ("accepted_hml", "Aceita em Homologação"),
- ("not_accepted", "Não aceita pelo banco"),
- ("done", "Concluído"),
-]
-
-SITUACAO_PAGAMENTO = [
- ("inicial", "Inicial"),
- ("aberta", "Aberta"),
- ("paga", "Paga"),
- ("liquidada", "Liquidada"),
- ("baixa", "Baixa Simples"),
- ("baixa_liquidacao", "Baixa por Liquidação em Dinheiro"),
-]
+_logger = logging.getLogger(__name__)
class AccountMoveLine(models.Model):
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 002ed3a90510..275bbd74f462 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -8,7 +8,7 @@
from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
COMPLEMENTO_TIPO_SERVICO, FORMA_LANCAMENTO,
- TIPO_SERVICO)
+ TIPO_SERVICO, BOLETO_ESPECIE)
class PaymentMode(models.Model):
@@ -66,22 +66,7 @@ class PaymentMode(models.Model):
)
boleto_type = fields.Selection(selection=[], string="Boleto")
boleto_especie = fields.Selection(
- [
- ("01", "DUPLICATA MERCANTIL"),
- ("02", "NOTA PROMISSÓRIA"),
- ("03", "NOTA DE SEGURO"),
- ("04", "MENSALIDADE ESCOLAR"),
- ("05", "RECIBO"),
- ("06", "CONTRATO"),
- ("07", "COSSEGUROS"),
- ("08", "DUPLICATA DE SERVIÇO"),
- ("09", "LETRA DE CÂMBIO"),
- ("13", "NOTA DE DÉBITOS"),
- ("15", "DOCUMENTO DE DÍVIDA"),
- ("16", "ENCARGOS CONDOMINIAIS"),
- ("17", "CONTA DE PRESTAÇÃO DE SERVIÇOS"),
- ("99", "DIVERSOS"),
- ],
+ selection=BOLETO_ESPECIE,
string="Espécie do Título",
default="01",
)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index a6821faf26bf..dd3ca052a5ac 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -9,12 +9,13 @@
from odoo import api, fields, models
-from ..constantes import CODIGO_OCORRENCIAS
+from ..constantes import (
+ CODIGO_OCORRENCIAS, STATE_CNAB, RETORNO_400_CONFIRMADA, RETORNO_400_REJEITADA,
+ RETORNO_400_LIQUIDACAO, RETORNO_400_BAIXA, RETORNOS_TRATADOS,
+ COD_REGISTROS_REJEITADOS_CNAB400, CODIGO_OCORRENCIAS_CNAB200, STR_EVENTO_FORMAT)
_logger = logging.getLogger(__name__)
-STATE = [("draft", "Novo"), ("done", "Processado"), ("error", "Erro no Processamento")]
-
TIPO_OPERACAO = {
"C": "Lançamento a Crédito",
"D": "Lançamento a Débito",
@@ -70,173 +71,6 @@
}
-RETORNO_400_CONFIRMADA = [2]
-
-RETORNO_400_REJEITADA = [3]
-
-RETORNO_400_LIQUIDACAO = [
- 6,
- # 7, TODO: Implementar a baixa parcial;
- 8,
-]
-
-RETORNO_400_BAIXA = [9, 10]
-
-RETORNOS_TRATADOS = [
- RETORNO_400_CONFIRMADA,
- RETORNO_400_REJEITADA,
- RETORNO_400_LIQUIDACAO,
- RETORNO_400_BAIXA,
-]
-
-# COD_REGISTROS_REJEITADOS_CNAB400 -> USADO QUANDO HA CODIGO DE OCORRENCIA 03
-# NA POSIÇÃO 109-110
-COD_REGISTROS_REJEITADOS_CNAB400 = {
- 3: "AG. COBRADORA - CEP SEM ATENDIMENTO DE PROTESTO NO MOMENTO",
- 4: "ESTADO - SIGLA DO ESTADO INVÁLIDA",
- 5: "DATA VENCIMENTO - PRAZO DA OPERAÇÃO MENOR QUE PRAZO MÍNIMO OU MAIOR QUE O MÁXIMO", # noqa
- 7: "VALOR DO TÍTULO - VALOR DO TÍTULO MAIOR QUE 10.000.000,00",
- 8: "NOME DO PAGADOR - NÃO INFORMADO OU DESLOCADO",
- 9: "AGENCIA/CONTA - AGÊNCIA ENCERRADA",
- 10: "LOGRADOURO - NÃO INFORMADO OU DESLOCADO",
- 11: "CEP - CEP NÃO NUMÉRICO OU CEP INVÁLIDO",
- 12: "SACADOR / AVALISTA - NOME NÃO INFORMADO OU DESLOCADO (BANCOS CORRESPONDENTES)", # noqa
- 13: "ESTADO/CEP - CEP INCOMPATÍVEL COM A SIGLA DO ESTADO",
- 14: "NOSSO NÚMERO - NOSSO NÚMERO JÁ REGISTRADO NO CADASTRO DO BANCO OU FORA DA FAIXA", # noqa
- 15: "NOSSO NÚMERO - NOSSO NÚMERO EM DUPLICIDADE NO MESMO MOVIMENTO",
- 18: "DATA DE ENTRADA - DATA DE ENTRADA INVÁLIDA PARA OPERAR COM ESTA CARTEIRA",
- 19: "OCORRÊNCIA - OCORRÊNCIA INVÁLIDA",
- 21: "AG. COBRADORA - CARTEIRA NÃO ACEITA DEPOSITÁRIA CORRESPONDENTE ESTADO DA AGÊNCIA DIFERENTE DO ESTADO DO PAGADOR AG. COBRADORA NÃO CONSTA NO CADASTRO OU ENCERRANDO", # noqa
- 22: "CARTEIRA - CARTEIRA NÃO PERMITIDA (NECESSÁRIO CADASTRAR FAIXA LIVRE)",
- 26: "AGÊNCIA/CONTA - AGÊNCIA/CONTA NÃO LIBERADA PARA OPERAR COM COBRANÇA",
- 27: "CNPJ INAPTO - CNPJ DO BENEFICIÁRIO INAPTO DEVOLUÇÃO DE TÍTULO EM GARANTIA",
- 29: "CÓDIGO EMPRESA - CATEGORIA DA CONTA INVÁLIDA",
- 30: "ENTRADA BLOQUEADA - ENTRADAS BLOQUEADAS, CONTA SUSPENSA EM COBRANÇA",
- 31: "AGÊNCIA/CONTA - CONTA NÃO TEM PERMISSÃO PARA PROTESTAR (CONTATE SEU GERENTE)",
- 35: "VALOR DO IOF - IOF MAIOR QUE 5%",
- 36: "QTDADE DE MOEDA - QUANTIDADE DE MOEDA INCOMPATÍVEL COM VALOR DO TÍTULO",
- 37: "CNPJ/CPF DO PAGADOR - NÃO NUMÉRICO OU IGUAL A ZEROS",
- 42: "NOSSO NÚMERO - NOSSO NÚMERO FORA DE FAIXA",
- 52: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE",
- 53: "AG. COBRADORA - EMPRESA NÃO ACEITA BANCO CORRESPONDENTE - COBRANÇA MENSAGEM",
- 54: "DATA DE VENCTO - BANCO CORRESPONDENTE - TÍTULO COM VENCIMENTO INFERIOR A 15 DIAS", # noqa
- 55: "DEP/BCO CORRESP - CEP NÃO PERTENCE À DEPOSITÁRIA INFORMADA",
- 56: "DT VENCTO/BCO CORRESP - VENCTO SUPERIOR A 180 DIAS DA DATA DE ENTRADA",
- 57: "DATA DE VENCTO - CEP SÓ DEPOSITÁRIA BCO DO BRASIL COM VENCTO INFERIOR A 8 DIAS", # noqa
- 60: "ABATIMENTO - VALOR DO ABATIMENTO INVÁLIDO",
- 61: "JUROS DE MORA - JUROS DE MORA MAIOR QUE O PERMITIDO",
- 62: "DESCONTO - VALOR DO DESCONTO MAIOR QUE VALOR DO TÍTULO",
- 63: "DESCONTO DE ANTECIPAÇÃO - VALOR DA IMPORTÂNCIA POR DIA DE DESCONTO (IDD) NÃO PERMITIDO", # noqa
- 64: "DATA DE EMISSÃO - DATA DE EMISSÃO DO TÍTULO INVÁLIDA",
- 65: "TAXA FINANCTO - TAXA INVÁLIDA (VENDOR)",
- 66: "DATA DE VENCTO - INVALIDA/FORA DE PRAZO DE OPERAÇÃO (MÍNIMO OU MÁXIMO)",
- 67: "VALOR/QTIDADE - VALOR DO TÍTULO/QUANTIDADE DE MOEDA INVÁLIDO",
- 68: "CARTEIRA - CARTEIRA INVÁLIDA OU NÃO CADASTRADA NO INTERCÂMBIO DA COBRANÇA",
- 69: "CARTEIRA - CARTEIRA INVÁLIDA PARA TÍTULOS COM RATEIO DE CRÉDITO",
- 70: "AGÊNCIA/CONTA - BENEFICIÁRIO NÃO CADASTRADO PARA FAZER RATEIO DE CRÉDITO",
- 78: "AGÊNCIA/CONTA - DUPLICIDADE DE AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO DE CRÉDITO", # noqa
- 80: "AGÊNCIA/CONTA - QUANTIDADE DE CONTAS BENEFICIÁRIAS DO RATEIO MAIOR DO QUE O PERMITIDO (MÁXIMO DE 30 CONTAS POR TÍTULO)", # noqa
- 81: "AGÊNCIA/CONTA - CONTA PARA RATEIO DE CRÉDITO INVÁLIDA / NÃO PERTENCE AO ITAÚ",
- 82: "DESCONTO/ABATI-MENTO - DESCONTO/ABATIMENTO NÃO PERMITIDO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
- 83: "VALOR DO TÍTULO - VALOR DO TÍTULO MENOR QUE A SOMA DOS VALORES ESTIPULADOS PARA RATEIO", # noqa
- 84: "AGÊNCIA/CONTA - AGÊNCIA/CONTA BENEFICIÁRIA DO RATEIO É A CENTRALIZADORA DE CRÉDITO DO BENEFICIÁRIO", # noqa
- 85: "AGÊNCIA/CONTA - AGÊNCIA/CONTA DO BENEFICIÁRIO É CONTRATUAL / RATEIO DE CRÉDITO NÃO PERMITIDO", # noqa
- 86: "TIPO DE VALOR - CÓDIGO DO TIPO DE VALOR INVÁLIDO / NÃO PREVISTO PARA TÍTULOS COM RATEIO DE CRÉDITO", # noqa
- 87: "AGÊNCIA/CONTA - REGISTRO TIPO 4 SEM INFORMAÇÃO DE AGÊNCIAS/CONTAS BENEFICIÁRIAS DO RATEIO", # noqa
- 90: "NRO DA LINHA - COBRANÇA MENSAGEM - NÚMERO DA LINHA DA MENSAGEM INVÁLIDO OU QUANTIDADE DE LINHAS EXCEDIDAS", # noqa
- 97: "SEM MENSAGEM - COBRANÇA MENSAGEM SEM MENSAGEM (SÓ DE CAMPOS FIXOS), PORÉM COM REGISTRO DO TIPO 7 OU 8", # noqa
- 98: "FLASH INVÁLIDO - REGISTRO MENSAGEM SEM FLASH CADASTRADO OU FLASH INFORMADO DIFERENTE DO CADASTRADO", # noqa
- 99: "FLASH INVÁLIDO - CONTA DE COBRANÇA COM FLASH CADASTRADO E SEM REGISTRO DE MENSAGEM CORRESPONDENTE", # noqa
-}
-
-
-CODIGO_OCORRENCIAS_CNAB200 = {
- 2: "ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM (NOTA 20 – TABELA 10)", # noqa
- 3: "ENTRADA REJEITADA (NOTA 20 – TABELA 1)", # noqa
- 4: "ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA", # noqa
- 5: "ALTERAÇÃO DE DADOS – BAIXA",
- 6: "LIQUIDAÇÃO NORMAL",
- 7: "LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)",
- 8: "LIQUIDAÇÃO EM CARTÓRIO",
- 9: "BAIXA SIMPLES",
- 10: "BAIXA POR TER SIDO LIQUIDADO",
- 11: "EM SER (SÓ NO RETORNO MENSAL)",
- 12: "ABATIMENTO CONCEDIDO",
- 13: "ABATIMENTO CANCELADO",
- 14: "VENCIMENTO ALTERADO",
- 15: "BAIXAS REJEITADAS (NOTA 20 – TABELA 4)",
- 16: "INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)",
- 17: "ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)",
- 18: "COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)", # noqa
- 19: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO",
- 20: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA",
- 21: "CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR",
- 23: "TÍTULO ENVIADO A CARTÓRIO/TARIFA",
- 24: "INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)", # noqa
- 25: "ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)",
- 26: "TARIFA DE AVISO DE COBRANÇA",
- 27: "TARIFA DE EXTRATO POSIÇÃO (B40X)",
- 28: "TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES",
- 29: "TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS",
- 30: "DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)",
- 32: "BAIXA POR TER SIDO PROTESTADO",
- 33: "CUSTAS DE PROTESTO",
- 34: "CUSTAS DE SUSTAÇÃO",
- 35: "CUSTAS DE CARTÓRIO DISTRIBUIDOR",
- 36: "CUSTAS DE EDITAL",
- 37: "TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA",
- 38: "TARIFA DE INSTRUÇÃO",
- 39: "TARIFA DE OCORRÊNCIAS",
- 40: "TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA", # noqa
- 41: "DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)",
- 42: "DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES",
- 43: "DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS",
- 44: "DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS",
- 45: "DÉBITO MENSAL DE TARIFAS – PROTESTO",
- 46: "DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO",
- 47: "BAIXA COM TRANSFERÊNCIA PARA DESCONTO",
- 48: "CUSTAS DE SUSTAÇÃO JUDICIAL",
- 51: "TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA",
- 52: "TARIFA MENSAL BAIXAS NA CARTEIRA",
- 53: "TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA",
- 54: "TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA",
- 55: "TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA",
- 56: "CUSTAS DE IRREGULARIDADE",
- 57: "INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)",
- 59: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG",
- 60: "ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)",
- 61: "TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
- 62: "DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)",
- 63: "TÍTULO SUSTADO JUDICIALMENTE",
- 64: "ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO",
- 65: "PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO",
- 69: "CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)",
- 71: "ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO",
- 72: "BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE",
- 73: "CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL", # noqa
- 74: "INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)",
- 75: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
- 76: "CHEQUE COMPENSADO",
- 77: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA", # noqa
- 78: "CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA", # noqa
- 79: "NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)",
- 80: "CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA",
- 82: "CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA",
- 83: "CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA", # noqa
- 85: "TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
- 86: "TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA",
- 87: "TARIFA SMS COBRANÇA ATIVA ELETRÔNICA",
- 88: "TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA",
- 89: "TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA",
- 90: "TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA",
- 91: "TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA",
- 92: "TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA",
- 93: "TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO",
-}
-
-STR_EVENTO_FORMAT = "%d%m%y"
-
-
class L10nBrHrCnab(models.Model):
_name = "l10n_br.cnab"
_rec_name = "display_name"
@@ -258,7 +92,7 @@ class L10nBrHrCnab(models.Model):
name = fields.Char(string="Name")
num_eventos = fields.Integer(string="Número de Eventos")
num_lotes = fields.Integer(string="Número de Lotes")
- state = fields.Selection(string="Estágio", selection=STATE, default="draft")
+ state = fields.Selection(string="Estágio", selection=STATE_CNAB, default="draft")
@api.one
@api.depends("name")
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index dd29d64a2fc4..ed6240cd5a1a 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -6,7 +6,7 @@
from odoo import fields, models
-from .l10n_br_cnab import STATE
+from ..constantes import STATE_CNAB
_logger = logging.getLogger(__name__)
@@ -38,7 +38,7 @@ class L10nBrCnabEvento(models.Model):
segmento = fields.Char(string="Segmento")
seu_numero = fields.Char(string="Seu Número")
state = fields.Selection(
- string="State", related="lote_id.state", selection=STATE, default="draft"
+ string="State", related="lote_id.state", selection=STATE_CNAB, default="draft"
)
str_motiv_a = fields.Char("Motivo da ocorrência 01")
str_motiv_b = fields.Char("Motivo de ocorrência 02")
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index 3f2d3148dbe1..94cd90ee98a9 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -6,7 +6,7 @@
from odoo import fields, models
-from .l10n_br_cnab import STATE
+from ..constantes import STATE_CNAB
_logger = logging.getLogger(__name__)
@@ -30,7 +30,7 @@ class L10nBrCnabLote(models.Model):
qtd_registros = fields.Integer(string="Quantidade de Registros")
servico_operacao = fields.Char(string="Tipo de Operação")
state = fields.Selection(
- string="State", related="cnab_id.state", selection=STATE, default="draft"
+ string="State", related="cnab_id.state", selection=STATE_CNAB, default="draft"
)
tipo_servico = fields.Char(string="Tipo do Serviço")
total_valores = fields.Float(string="Valor Total")
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
index b8c0f9a08e85..bebf5c80ba3c 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner_bank.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
@@ -4,6 +4,8 @@
from odoo import fields, models
+from ..constantes import TIPO_DE_CONTA
+
class ResPartnerBank(models.Model):
""" Adiciona campos necessários para o cadastramentos de contas
@@ -19,14 +21,7 @@ class ResPartnerBank(models.Model):
)
tipo_de_conta = fields.Selection(
- selection=[
- ("01", "Conta corrente individual"),
- ("02", "Conta poupança individual"),
- ("03", "Conta depósito judicial/Depósito em consignação " "individual"),
- ("11", "Conta corrente conjunta"),
- ("12", "Conta poupança conjunta"),
- ("13", "Conta depósito judicial/Depósito em consignação " "conjunta"),
- ],
+ selection=TIPO_DE_CONTA,
string="Tipo de Conta",
default="01",
)
From ada9a636fd039ce17d99176fe238df981333a8d7 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 23 Jun 2020 17:47:42 -0300
Subject: [PATCH 207/612] [12.0][MIG][FIX] Security access to CNAB File return.
---
.../security/ir.model.access.csv | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/security/ir.model.access.csv b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
index b624831a7622..e4226cb7088f 100644
--- a/l10n_br_account_payment_cobranca/security/ir.model.access.csv
+++ b/l10n_br_account_payment_cobranca/security/ir.model.access.csv
@@ -1,7 +1,6 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,,1,0,0,0
-access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,,1,0
-access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,,1,0,0,0
-
+access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,group_cnab_cobranca,1,1,1,1
+access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,group_cnab_cobranca,1,1,1,1
+access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,group_cnab_cobranca,1,1,1,1
access_bank_api_operation,bank.api.operation,model_bank_api_operation,account.group_account_invoice,1,1,1,1
access_bank_api_operation_error_line,bank.api.operation,model_bank_api_operation_error_line,account.group_account_invoice,1,1,1,1
From a108f442524ffd588731dd0e1b4999c10b7e62c3 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 23 Jun 2020 17:48:36 -0300
Subject: [PATCH 208/612] [12.0][MIG][IMP] Demo data, configure users access to
CNAB File return.
---
l10n_br_account_payment_cobranca/__manifest__.py | 1 +
.../demo/res_users_demo.xml | 13 +++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/demo/res_users_demo.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index 8770f5fcae4e..a7a1fabf22cf 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -41,6 +41,7 @@
'data/cnab_data.xml',
],
'demo': [
+ 'demo/res_users_demo.xml',
'demo/account_journal_demo.xml',
'demo/account_payment_mode_demo.xml',
'demo/account_invoice_demo.xml',
diff --git a/l10n_br_account_payment_cobranca/demo/res_users_demo.xml b/l10n_br_account_payment_cobranca/demo/res_users_demo.xml
new file mode 100644
index 000000000000..b1cf4146b7c1
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/demo/res_users_demo.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ 1
+
+
+
+ 1
+
+
+
From 875977329d8ccedd62f22c633144407d58e40b03 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 24 Jun 2020 09:19:13 -0300
Subject: [PATCH 209/612] [12.0][MIG][FIX] Code mistake.
---
.../models/account_payment_order.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index d02ee4c7a94a..42a7d92b317e 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -92,7 +92,7 @@ def _prepare_bank_payment_line(self, paylines):
result["nosso_numero"] = paylines[0].nosso_numero
result["numero_documento"] = paylines[0].numero_documento
result["identificacao_titulo_empresa"] = paylines[0].identificacao_titulo_empresa
- result["ultimo_estado_cnab"] = paylines.move_line_id[0].state_cnab
+ result["ultimo_estado_cnab"] = paylines[0].move_line_id.state_cnab
return result
@api.multi
From 26fc03539cb584b13f93adaf1b334365925ac747 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 24 Jun 2020 09:20:00 -0300
Subject: [PATCH 210/612] [12.0][MIG][FIX] Field date should receive date not
datetime.
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index dd3ca052a5ac..d6cf2876c6d6 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -82,7 +82,8 @@ class L10nBrHrCnab(models.Model):
bank_account_id = fields.Many2one(
string="Conta cedente", comodel_name="res.partner.bank"
)
- data = fields.Date(string="Data CNAB", required=True, default=datetime.now())
+ data = fields.Date(
+ string="Data CNAB", required=True, default=datetime.now().date())
data_arquivo = fields.Date(string="Data Criação no Banco")
sequencial_arquivo = fields.Char(string="Sequencial do Arquivo")
motivo_erro = fields.Char(string="Motivo do Erro")
From a2cf2050c2cd6f94b9abaff9153937823cdeaa6c Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 24 Jun 2020 10:04:54 -0300
Subject: [PATCH 211/612] [12.0][MIG][IMP] Tests.
---
l10n_br_account_payment_cobranca/__init__.py | 1 +
.../tests/__init__.py | 5 +++
.../tests/test_payment_order.py | 43 +++++++++++++++++++
3 files changed, 49 insertions(+)
create mode 100644 l10n_br_account_payment_cobranca/tests/__init__.py
create mode 100644 l10n_br_account_payment_cobranca/tests/test_payment_order.py
diff --git a/l10n_br_account_payment_cobranca/__init__.py b/l10n_br_account_payment_cobranca/__init__.py
index 36f9107d400e..4b1fb7e9bc51 100644
--- a/l10n_br_account_payment_cobranca/__init__.py
+++ b/l10n_br_account_payment_cobranca/__init__.py
@@ -7,3 +7,4 @@
from . import wizard
from . import models
from . import reports
+from . import tests
diff --git a/l10n_br_account_payment_cobranca/tests/__init__.py b/l10n_br_account_payment_cobranca/tests/__init__.py
new file mode 100644
index 000000000000..7707a125036e
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/tests/__init__.py
@@ -0,0 +1,5 @@
+# @ 2020 Akretion - www.akretion.com.br -
+# Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
+
+from . import test_payment_order
diff --git a/l10n_br_account_payment_cobranca/tests/test_payment_order.py b/l10n_br_account_payment_cobranca/tests/test_payment_order.py
new file mode 100644
index 000000000000..1253f1e49c4d
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/tests/test_payment_order.py
@@ -0,0 +1,43 @@
+# @ 2020 Akretion - www.akretion.com.br -
+# Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
+
+
+from openerp.tests.common import TransactionCase
+from openerp.exceptions import UserError, ValidationError
+
+
+class TestPaymentOrder(TransactionCase):
+
+ def setUp(self):
+ super(TestPaymentOrder, self).setUp()
+
+ # Get Invoice for test
+ self.invoice_customer_original = self.env.ref(
+ 'l10n_br_account_payment_order.demo_invoice_payment_order'
+ )
+
+ self.invoice_customer_original.journal_id.update_posted = True
+
+ def test_payment_order(self):
+ """Test automatic creation of Payment Order."""
+
+ # I check that Initially customer invoice is in the "Draft" state
+ self.assertEquals(self.invoice_customer_original.state, 'draft')
+
+ # I validate invoice by creating on
+ self.invoice_customer_original.action_invoice_open()
+
+ # I check that the invoice state is "Open"
+ self.assertEquals(self.invoice_customer_original.state, 'open')
+
+ # I check that now there is a move attached to the invoice
+ assert self.invoice_customer_original.move_id,\
+ "Move not created for open invoice"
+
+ payment_order = self.env['account.payment.order'].search([])
+ # I check creation of Payment Order
+ assert payment_order, "Payment Order not created."
+ payment_order.draft2open()
+ # The file generation need additional module to use BRCobranca or PyBoleto
+ # payment_order.open2generated()
From e39e14bb64e79578e4b8bbbade6fefa6f386ebc6 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 24 Jun 2020 13:44:42 -0300
Subject: [PATCH 212/612] [12.0][MIG][FIX] Demo data.
---
.../demo/account_payment_mode_demo.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
index 812320a83d56..bfcc67937433 100644
--- a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
@@ -14,7 +14,7 @@
True
+ ref="l10n_br_account_payment_cobranca.payment_mode_type_cnab400"/>
3
06
03
From 95f1bfc791ce929a22ecebf153e35a3014ba1cad Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 24 Jun 2020 15:11:10 -0300
Subject: [PATCH 213/612] [12.0][MIG][FIX] PEP8.
---
l10n_br_account_payment_cobranca/constantes.py | 6 +++++-
.../models/account_payment_order.py | 3 ++-
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 5 +++--
.../tests/test_payment_order.py | 3 +--
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 9f40fbb23ffa..592e0d37d914 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -515,7 +515,11 @@
("13", "Conta depósito judicial/Depósito em consignação " "conjunta"),
]
-STATE_CNAB = [("draft", "Novo"), ("done", "Processado"), ("error", "Erro no Processamento")]
+STATE_CNAB = [
+ ("draft", "Novo"),
+ ("done", "Processado"),
+ ("error", "Erro no Processamento")
+]
TIPO_OPERACAO_CNAB = {
"C": "Lançamento a Crédito",
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 42a7d92b317e..0bb27fbce686 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -91,7 +91,8 @@ def _prepare_bank_payment_line(self, paylines):
result = super()._prepare_bank_payment_line(paylines)
result["nosso_numero"] = paylines[0].nosso_numero
result["numero_documento"] = paylines[0].numero_documento
- result["identificacao_titulo_empresa"] = paylines[0].identificacao_titulo_empresa
+ result["identificacao_titulo_empresa"] =\
+ paylines[0].identificacao_titulo_empresa
result["ultimo_estado_cnab"] = paylines[0].move_line_id.state_cnab
return result
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index d6cf2876c6d6..d1bfdb3b5043 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -223,6 +223,7 @@ def _lote_400(self, evento, lote_id):
)
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
+ payment_mode = invoice.payment_mode_id
if bank_state == "liquidada" and invoice.state == "open":
line_dict = {
"name": evento.nosso_numero,
@@ -232,7 +233,7 @@ def _lote_400(self, evento, lote_id):
evento.identificacao_titulo_empresa,
"credit": float(evento.valor_principal)
+ float(evento.tarifa_cobranca),
- "account_id": invoice.payment_mode_id.default_account_id.id
+ "account_id": payment_mode.default_account_id.id
or invoice.account_id.id,
"journal_id": bank_payment_line_id.order_id.journal_id.id,
"date_maturity": datetime.strptime(
@@ -265,7 +266,7 @@ def _lote_400(self, evento, lote_id):
"credit": 0,
"debit": float(evento.tarifa_cobranca),
"account_id":
- invoice.payment_mode_id.default_tax_account_id.id
+ payment_mode.default_tax_account_id.id
or invoice.account_id.id,
}
)
diff --git a/l10n_br_account_payment_cobranca/tests/test_payment_order.py b/l10n_br_account_payment_cobranca/tests/test_payment_order.py
index 1253f1e49c4d..3faae109961e 100644
--- a/l10n_br_account_payment_cobranca/tests/test_payment_order.py
+++ b/l10n_br_account_payment_cobranca/tests/test_payment_order.py
@@ -3,8 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-from openerp.tests.common import TransactionCase
-from openerp.exceptions import UserError, ValidationError
+from odoo.tests.common import TransactionCase
class TestPaymentOrder(TransactionCase):
From abfd2da11ae9f9698b8f2718413e0193a56abe1c Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 2 Jul 2020 18:08:34 -0300
Subject: [PATCH 214/612] [12.0][MIG][REF] Demo data to use Unicred Bank.
---
.../demo/account_journal_demo.xml | 10 +-
.../demo/account_payment_mode_demo.xml | 145 ++++++++++++++++++
2 files changed, 150 insertions(+), 5 deletions(-)
create mode 100644 l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
diff --git a/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml b/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
index d52d64a19d1f..439d503920de 100644
--- a/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
@@ -18,18 +18,18 @@
Banco Unicred
bank
- BN3
+ BNC3
-
+
Banco Itau
bank
- BNC3
+ BNC4
@@ -40,7 +40,7 @@
Banco do Brasil
bank
- BNC3
+ BNC5
@@ -51,7 +51,7 @@
Banco Caixa Economica Federal
bank
- BNC3
+ BNC6
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
new file mode 100644
index 000000000000..99cebad83765
--- /dev/null
+++ b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+ 5384
+ 8
+ 7030
+ 8
+
+
+ BANCO DO BRASIL S.A.
+
+
+
+ 5162
+ 0
+ 0100
+ 3
+
+
+ HSBC BANK BRASIL S.A. - BANCO MULTIPLO
+
+
+
+ 15016
+ 0
+ 8515
+ 0
+
+
+ BANCO ITAÚ S.A.
+
+
+
+ 1333
+ 0
+ 0707
+ 0
+
+
+ BANCO SANTANDER (BRASIL) S.A.
+
+
+
+ 414
+ 3
+ 1565
+ 1
+
+
+ CAIXA ECONOMICA FEDERAL
+
+
+
+ 395
+ 0
+ 1611
+ 0
+
+
+ BANCO BRADESCO S.A.
+
+
+
+ 123
+ 0
+ 1234
+ 0
+
+
+ BANCO DO NORDESTE DO BRASIL S.A.
+
+
+
+ 321
+ 0
+ 1234
+ 0
+
+
+ BANCO DO ESTADO DO RIO GRANDE DO SUL S.A.
+
+
+
+ 231
+ 0
+ 1234
+ 0
+
+
+ BANESTES S.A. BANCO DO ESTADO DO ESPIRITO SANTO
+
+
+
+ 312
+ 0
+ 1234
+ 0
+
+
+ BANCO COOPERATIVO DO BRASIL S.A. (SICOOB)
+
+
+
+ 331
+ 0
+ 1234
+ 0
+
+
+ Sicredi - Instituição Financeira Cooperativa
+
+
+
+ 371
+ 0
+ 1234
+ 0
+
+
+ Unicred
+
+
+
+
+ Diário de Banco(teste l10n_br_account_payment_order)
+ TPO
+ sale
+
+
+
+
+
+ Boleto Bancario
+
+ variable
+
+
+
+
+
+
From 50ebc8b17e306f8c0e5fb360727b9eb9b1f468cc Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 2 Jul 2020 18:20:01 -0300
Subject: [PATCH 215/612] [12.0][MIG][FIX] Field Codigo de Instrucao should
have two digits.
---
l10n_br_account_payment_cobranca/constantes.py | 4 ++--
.../models/account_payment_order.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index 592e0d37d914..a28e3b6e24a2 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -274,8 +274,8 @@
]
CODIGO_INSTRUCAO_MOVIMENTO = [
- ("0", "00 - Inclusão de Registro Detalhe Liberado"),
- ("9", "09 - Inclusão do Registro Detalhe Bloqueado"),
+ ("00", "00 - Inclusão de Registro Detalhe Liberado"),
+ ("09", "09 - Inclusão do Registro Detalhe Bloqueado"),
("10", "10 - Alteração do Pagamento Liberado para Bloqueado (Bloqueio)"),
("11", "11 - Alteração do Pagamento Bloqueado para Liberado (Liberação)"),
("17", "17 - Alteração do Valor do Título"),
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 0bb27fbce686..2734e8f983a0 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -57,7 +57,7 @@ class PaymentOrder(models.Model):
selection=CODIGO_INSTRUCAO_MOVIMENTO,
string="Código da Instrução para Movimento",
help="Campo G061 do CNAB",
- default="0",
+ default="00",
)
bank_line_error_ids = fields.One2many(
comodel_name="bank.payment.line",
From 3339542260e82e1fc71a0d897bbeea1bc1c46b2f Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 2 Jul 2020 18:45:24 -0300
Subject: [PATCH 216/612] [12.0][MIG][REF] Field Tipo Conta implemented in
module l10n_br_base as bank_account_type and was created constraint to check
lenght of bra_number.
---
l10n_br_account_payment_cobranca/constantes.py | 9 ---------
.../models/res_partner_bank.py | 10 ----------
2 files changed, 19 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_cobranca/constantes.py
index a28e3b6e24a2..2032176f79c4 100644
--- a/l10n_br_account_payment_cobranca/constantes.py
+++ b/l10n_br_account_payment_cobranca/constantes.py
@@ -506,15 +506,6 @@
("99", "DIVERSOS"),
]
-TIPO_DE_CONTA = [
- ("01", "Conta corrente individual"),
- ("02", "Conta poupança individual"),
- ("03", "Conta depósito judicial/Depósito em consignação " "individual"),
- ("11", "Conta corrente conjunta"),
- ("12", "Conta poupança conjunta"),
- ("13", "Conta depósito judicial/Depósito em consignação " "conjunta"),
-]
-
STATE_CNAB = [
("draft", "Novo"),
("done", "Processado"),
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
index bebf5c80ba3c..27e581cd9baf 100644
--- a/l10n_br_account_payment_cobranca/models/res_partner_bank.py
+++ b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
@@ -4,8 +4,6 @@
from odoo import fields, models
-from ..constantes import TIPO_DE_CONTA
-
class ResPartnerBank(models.Model):
""" Adiciona campos necessários para o cadastramentos de contas
@@ -19,11 +17,3 @@ class ResPartnerBank(models.Model):
help="Será informado pelo banco depois do cadastro do beneficiário "
"na agência",
)
-
- tipo_de_conta = fields.Selection(
- selection=TIPO_DE_CONTA,
- string="Tipo de Conta",
- default="01",
- )
-
- bra_number = fields.Char(size=5)
From 5720c9f97e8f29ac0cdfa1056e067e8fb4475f81 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 2 Jul 2020 18:51:43 -0300
Subject: [PATCH 217/612] [12.0][MIG][REF] Removed unused code.
---
l10n_br_account_payment_cobranca/models/__init__.py | 1 -
.../models/res_partner.py | 11 -----------
2 files changed, 12 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/res_partner.py
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index d5c25fea10cc..d1f935400f96 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -16,5 +16,4 @@
from . import l10n_br_cnab_lote
from . import res_company
from . import res_partner_bank
-from . import res_partner
from .. import constantes
diff --git a/l10n_br_account_payment_cobranca/models/res_partner.py b/l10n_br_account_payment_cobranca/models/res_partner.py
deleted file mode 100644
index 2e7c8736bd14..000000000000
--- a/l10n_br_account_payment_cobranca/models/res_partner.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import fields, models
-
-
-class ResPartner(models.Model):
- _inherit = "res.partner"
-
- type = fields.Selection(selection_add=[("cnab_cobranca", "Cobrança CNAB")])
From b9904f63aca69dc2c77eba89de487eb418a05437 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 3 Jul 2020 18:15:57 -0300
Subject: [PATCH 218/612] [12.0][MIG][REF] Removed unnecessary view, partner_id
is already required in core definition.
---
.../__manifest__.py | 1 -
.../views/res_partner_bank.xml | 32 -------------------
2 files changed, 33 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/views/res_partner_bank.xml
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index a7a1fabf22cf..fa70fef6b288 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -21,7 +21,6 @@
'security/cnab_cobranca_security.xml',
'views/res_company.xml',
'views/account_payment_mode.xml',
- 'views/res_partner_bank.xml',
'views/account_payment_order.xml',
'views/account_payment_order_menu_views.xml',
'views/account_payment_line.xml',
diff --git a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml b/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
deleted file mode 100644
index fdc34d85eced..000000000000
--- a/l10n_br_account_payment_cobranca/views/res_partner_bank.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- view_cnab_bank_acc_dig.partner.bank.form
- res.partner.bank
-
-
-
-
-
-
-
-
-
- {'required': True}
-
-
-
- {'required': True}
-
-
-
-
-
-
-
-
-
-
-
From e4dbb592302c295e6e2fb0de4ac2d07e821ec638 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 3 Jul 2020 18:17:33 -0300
Subject: [PATCH 219/612] [12.0][MIG][REF] Removed unnecessary field.
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 68b0b90b3bdb..0f5000fa71bd 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -37,8 +37,6 @@ def _compute_receivables(self):
compute="_compute_receivables",
)
- active = fields.Boolean(string="Ativo", default=True)
-
# eval_state_cnab = fields.Selection(
# string=u"Estado CNAB",
# related="move_line_receivable_id.state_cnab",
From d3733a759c35b30a1b6afde5282de82bacc0d1de Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Sun, 5 Jul 2020 17:23:39 -0300
Subject: [PATCH 220/612] [12.0][MIG][IMP] Included field used to make
invisible banks specifics fields.
---
.../models/account_payment_mode.py | 2 ++
.../views/account_payment_mode.xml | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 275bbd74f462..180f32e91ef7 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -122,6 +122,8 @@ class PaymentMode(models.Model):
help='Código do Posto da Cooperativa de Crédito,'
' usado pelos bancos Sicred/Unicred e Sicoob.'
)
+ # Field used to make invisible banks specifics fields
+ bank_code_bc = fields.Char(related='fixed_journal_id.bank_id.code_bc')
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 6e67352ed3e0..3906e3d07e3e 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -25,6 +25,7 @@
+
@@ -36,8 +37,8 @@
-
-
+
+
From 2c90bc355ef8bc4e56588e1eedf6acec101e7342 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 6 Jul 2020 08:49:38 -0300
Subject: [PATCH 221/612] [12.0][MIG][REF] Renamed fields related to Protesto
of Boletos.
---
.../models/account_payment_mode.py | 18 +++++++++++++++---
.../views/account_payment_mode.xml | 4 ++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 180f32e91ef7..41af8aed4d43 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -70,7 +70,13 @@ class PaymentMode(models.Model):
string="Espécie do Título",
default="01",
)
- boleto_protesto = fields.Char(
+ boleto_cod_protesto = fields.Char(
+ # Na configuração ou implementação de outros campos é
+ # melhor seguir a idéia abaixo pois os campos não são usados com
+ # frequencia e incluir um campo do tipo Char permitindo que seja
+ # informado o valor de acordo com a configuração do Boleto ao
+ # invês de diversos campos do Tipo Select para cada Banco parece
+ # ser melhor.
# [ Deixado manualmente, pois cada banco parece ter sua tabela.
# ('0', u'Sem instrução'),
# ('1', u'Protestar (Dias Corridos)'),
@@ -79,10 +85,16 @@ class PaymentMode(models.Model):
# ('7', u'Negativar (Dias Corridos)'),
# ('8', u'Não Negativar')
# ]
- string="Códigos de Protesto",
+ string="Código de Protesto",
+ help='Código adotado pela FEBRABAN para identificar o tipo'
+ ' de prazo a ser considerado para o protesto.',
default="0",
)
- boleto_protesto_prazo = fields.Char("Prazo protesto", size=2)
+ boleto_dias_protesto = fields.Char(
+ string="Número de Dias para Protesto", size=2,
+ help='Número de dias decorrentes após a data de vencimento'
+ ' para inicialização do processo de cobrança via protesto.'
+ )
gera_nosso_numero = fields.Boolean(
string="Gerar nosso número?",
help="Dependendo da carteira, banco, etc. "
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 3906e3d07e3e..17e11d331bde 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -35,8 +35,8 @@
-
-
+
+
From 7ff73e3d8896627561312d06d8d516d5830b432b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 8 Jul 2020 11:03:06 -0300
Subject: [PATCH 222/612] [12.0][MIG][IMP] Demo data, details of Unicred
Payment Mode.
---
.../demo/account_payment_mode_demo.xml | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
index bfcc67937433..2731c168e7cd 100644
--- a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
@@ -42,11 +42,12 @@
3
DM
19
- S
+ N
- 2
- 01
+ 2
+ 5
+ 72234050
@@ -66,11 +67,12 @@
3
DM
19
- S
+ N
- 2
- 01
+ 2
+ 5
+ 72234050
From e88e0590670a7c0e823a82611ade9445d0eb6771 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 8 Jul 2020 11:07:12 -0300
Subject: [PATCH 223/612] [12.0][MIG][FIX] Method Write can receive more than
one record.
---
.../models/account_move_line.py | 27 ++++++++++---------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index 7da420a62b79..cd704a209700 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -77,18 +77,19 @@ def write(self, vals):
:param vals:
:return:
"""
- state_cnab = vals.get("state_cnab")
-
- if state_cnab and (
- self.state_cnab == "done"
- or (
- self.state_cnab in ["accepted", "accepted_hml"]
- and state_cnab not in ["accepted", "accepted_hml", "done"]
- )
- ):
- vals.pop("state_cnab", False)
-
- if self.situacao_pagamento not in ["inicial", "aberta"]:
- vals.pop("situacao_pagamento", False)
+ for record in self:
+ state_cnab = vals.get("state_cnab")
+
+ if state_cnab and (
+ record.state_cnab == "done"
+ or (
+ record.state_cnab in ["accepted", "accepted_hml"]
+ and state_cnab not in ["accepted", "accepted_hml", "done"]
+ )
+ ):
+ vals.pop("state_cnab", False)
+
+ if record.situacao_pagamento not in ["inicial", "aberta"]:
+ vals.pop("situacao_pagamento", False)
return super(AccountMoveLine, self).write(vals)
From ab3ed68b1edcabd1c4f75fc333a6ea078deb0fdb Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 14 Jul 2020 17:02:58 -0300
Subject: [PATCH 224/612] [12.0][MIG][IMP] Configure admin and system group
security access to CNAB Group.
---
.../security/cnab_cobranca_security.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
index 4ac02592c50e..de73aa6b1b93 100644
--- a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
+++ b/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
@@ -7,4 +7,14 @@
ref="base.module_category_accounting_and_finance"/>
+
+
+
+
+
+
+
+
From c5fc5fa3e1a83d6e14ce1d9552211fcbeba7447a Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 14 Jul 2020 17:05:33 -0300
Subject: [PATCH 225/612] [12.0][MIG][FIX] Avoid error by inform parameter.
---
l10n_br_account_payment_cobranca/models/account_invoice.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 0f5000fa71bd..5cf16c851d57 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -397,7 +397,7 @@ def create_account_payment_line_baixa(self):
count += 1
if new_payorder:
inv.message_post(
- _(
+ body=_(
"%d payment lines added to the new draft payment "
"order %s which has been automatically created."
)
@@ -405,7 +405,7 @@ def create_account_payment_line_baixa(self):
)
else:
inv.message_post(
- _(
+ body=_(
"%d payment lines added to the existing draft "
"payment order %s."
)
@@ -464,7 +464,6 @@ def assign_outstanding_credit(self, credit_aml_id):
def register_payment(
self, payment_line, writeoff_acc_id=False, writeoff_journal_id=False
):
-
res = super(AccountInvoice, self).register_payment(
payment_line, writeoff_acc_id, writeoff_journal_id
)
From 0b3740ed9ec1b888a0ee36a462ad92b644892be9 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 14 Jul 2020 17:22:55 -0300
Subject: [PATCH 226/612] [12.0][MIG][FIX] Field vencimento missing create as
data_vencimento.
---
l10n_br_account_payment_cobranca/models/l10n_br_cnab.py | 8 ++++----
.../models/l10n_br_cnab_evento.py | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index d1bfdb3b5043..64725d59df88 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -237,9 +237,9 @@ def _lote_400(self, evento, lote_id):
or invoice.account_id.id,
"journal_id": bank_payment_line_id.order_id.journal_id.id,
"date_maturity": datetime.strptime(
- str(evento.vencimento).zfill(6), STR_EVENTO_FORMAT
+ str(evento.data_vencimento).zfill(6), STR_EVENTO_FORMAT
)
- if evento.vencimento
+ if evento.data_vencimento
else "",
"date": datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
@@ -473,9 +473,9 @@ def _reprocessa_lote_400(self, evento, lote_id):
"identificacao_titulo_empresa":
evento.identificacao_titulo_empresa,
"date_maturity": datetime.strptime(
- str(evento.vencimento).zfill(6), STR_EVENTO_FORMAT
+ str(evento.data_vencimento).zfill(6), STR_EVENTO_FORMAT
)
- if evento.vencimento
+ if evento.data_vencimento
else "",
"date": datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index ed6240cd5a1a..a3dee1bb67bc 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -19,6 +19,7 @@ class L10nBrCnabEvento(models.Model):
)
data_real_pagamento = fields.Date(string="Data do Crédito")
data_ocorrencia = fields.Date(string="Data da Ocorrência")
+ data_vencimento = fields.Date(string="Data de Vencimento")
favorecido_conta_bancaria_id = fields.Many2one(
string="Conta Bancária", comodel_name="res.partner.bank"
)
From ea9db751866606f5c37e0173550687a24be4a724 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 14 Jul 2020 17:26:32 -0300
Subject: [PATCH 227/612] [12.0][MIG][IMP] Demo data, full access in acount to
admin user.
---
l10n_br_account_payment_cobranca/demo/res_users_demo.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/l10n_br_account_payment_cobranca/demo/res_users_demo.xml b/l10n_br_account_payment_cobranca/demo/res_users_demo.xml
index b1cf4146b7c1..4f3e08640507 100644
--- a/l10n_br_account_payment_cobranca/demo/res_users_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/res_users_demo.xml
@@ -4,6 +4,7 @@
1
+ 1
From 6f4f9e08598fee02419a9ed1c1c90cadb741f1c8 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 5 Aug 2020 16:20:16 -0300
Subject: [PATCH 228/612] [12.0][MIG][FIX] Inform Nosso Numero sequence in the
Payment Mode.
---
.../models/account_invoice.py | 11 +++++++++--
.../models/account_payment_mode.py | 11 +++++++++++
.../views/account_payment_mode.xml | 1 +
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 5cf16c851d57..147165b53651 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -315,8 +315,15 @@ def _pos_action_move_create(self):
elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
sequence = numero_documento.replace("/", "")
elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
- # TODO: Implementar uma sequencia na carteira de cobranca
- raise NotImplementedError
+ if not inv.payment_mode_id.own_number_sequence:
+ raise UserError(
+ _(
+ "Favor acessar aba Cobrança da configuração"
+ " do Modo de Pagamento e determinar o "
+ "campo Sequência do Nosso Número."
+ )
+ )
+ sequence = inv.payment_mode_id.get_own_number_sequence()
else:
raise UserError(
_(
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 41af8aed4d43..5f3a16e42206 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -136,6 +136,12 @@ class PaymentMode(models.Model):
)
# Field used to make invisible banks specifics fields
bank_code_bc = fields.Char(related='fixed_journal_id.bank_id.code_bc')
+ own_number_sequence = fields.Many2one(
+ comodel_name='ir.sequence', string='Sequência do Nosso Número',
+ help='Para usar essa Sequencia é preciso definir o campo Tipo do'
+ ' Nosso Número como Sequencial Único por Carteira no cadastro da'
+ ' empresa ',
+ )
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
@@ -158,3 +164,8 @@ def _constrains_product_override(self):
def boleto_restriction(self):
if self.boleto_type == "6" and not self.boleto_carteira:
raise ValidationError("Carteira no banco Itaú é obrigatória")
+
+ @api.multi
+ def get_own_number_sequence(self):
+ self.ensure_one()
+ return self.own_number_sequence.next_by_id()
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 17e11d331bde..a0c0087b11bb 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -28,6 +28,7 @@
+
From c8b23c9f601ef7db098d256cc05c4e1bbec2d13c Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 12 Jun 2020 17:41:43 -0300
Subject: [PATCH 229/612] [12.0][MIG][FIX] Reimplement fields used in Boletos.
---
.../models/account_payment_mode.py | 30 ++++++++++++++++++-
.../models/account_payment_term.py | 20 ++++++++++++-
.../views/account_payment_mode.xml | 4 +++
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 5f3a16e42206..bd08abf31367 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -2,7 +2,7 @@
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models
+from odoo import api, fields, models, _
from odoo.addons import decimal_precision as dp
from odoo.exceptions import ValidationError
@@ -143,6 +143,27 @@ class PaymentMode(models.Model):
' empresa ',
)
+ boleto_perc_mora = fields.Float(
+ string='Percentual de Juros de Mora',
+ digits=dp.get_precision('Account')
+ )
+ instrucao_boleto_perc_mora = fields.Text(
+ 'Instrução Juros Mora',
+ help='Juros de mora - é o percentual ao'
+ ' mês sobre o valor principal.',
+ default='Após vencimento cobrar juros de mora de'
+ )
+ boleto_perc_multa = fields.Float(
+ string='Percentual de Multa',
+ digits=dp.get_precision('Account')
+ )
+ instrucao_boleto_perc_multa = fields.Text(
+ 'Instrução Multa por Atraso',
+ help=' Multa por atraso - é o valor percentual acrescido uma única'
+ ' vez sobre o valor do principal. ',
+ default='Após vencimento cobrar multa de'
+ )
+
@api.onchange("product_tax_id")
def _onchange_product_tax_id(self):
if not self.product_tax_id:
@@ -169,3 +190,10 @@ def boleto_restriction(self):
def get_own_number_sequence(self):
self.ensure_one()
return self.own_number_sequence.next_by_id()
+
+ @api.constrains('boleto_perc_mora')
+ def _check_boleto_perc_mora(self):
+ for record in self:
+ if record.boleto_perc_mora > 2 or record.boleto_perc_mora < 0:
+ raise ValidationError(
+ _('O percentual de Mora deve ser um valor entre 0 a 2.'))
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_term.py b/l10n_br_account_payment_cobranca/models/account_payment_term.py
index 791879450acd..868f8ffaf40f 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_term.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_term.py
@@ -1,8 +1,9 @@
# © 2019 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import openerp.addons.decimal_precision as dp
+import odoo.addons.decimal_precision as dp
from odoo import api, fields, models
+from odoo.exceptions import Warning as UserError
PAYMENT_SELECTION = [
("boleto", "Boleto"),
@@ -30,6 +31,23 @@ class AccountPaymentTerm(models.Model):
comodel_name="account.account", string="Conta", help="Conta padrão para Juros"
)
+ discount_perc = fields.Float(
+ string=u"Percentual de Desconto até a Data de Vencimento",
+ digits=dp.get_precision('Account'))
+ instrucao_discount_perc = fields.Text(
+ u'Instrução de Desconto antes do Vencimento',
+ help=u'Percentual de Desconto concedido antes da Data de Vencimento',
+ default=u'CONCEDER ABATIMENTO PERCENTUAL DE '
+ )
+
+ @api.constrains('discount_perc')
+ def _check_discount_perc(self):
+ for record in self:
+ if record.discount_perc > 100 or record.discount_perc < 0:
+ raise UserError(
+ _('O percentual deve ser um valor entre 0 a 100.'))
+
+
@api.onchange("payment_mode_selection")
def _onchange_payment_mode(self):
if self.payment_mode_selection not in ["cartao"]:
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index a0c0087b11bb..635bf34c59c6 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -40,6 +40,10 @@
+
+
+
+
From a5f2cda4557bd1e3b3dd210e658d432834ef6b4c Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Sun, 5 Jul 2020 21:58:12 -0300
Subject: [PATCH 230/612] [12.0][MIG][IMP] Included fields used in Boletos(Tipo
Mora e Multa).
---
.../models/account_payment_mode.py | 12 ++++++++++++
.../views/account_payment_mode.xml | 2 ++
2 files changed, 14 insertions(+)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index bd08abf31367..0a3c310c71c0 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -143,6 +143,12 @@ class PaymentMode(models.Model):
' empresa ',
)
+ boleto_cod_mora = fields.Char(
+ size=1,
+ string='Código da Mora',
+ help='Código adotado pela FEBRABAN para identificação'
+ ' do tipo de pagamento de mora de juros.',
+ )
boleto_perc_mora = fields.Float(
string='Percentual de Juros de Mora',
digits=dp.get_precision('Account')
@@ -157,6 +163,12 @@ class PaymentMode(models.Model):
string='Percentual de Multa',
digits=dp.get_precision('Account')
)
+ boleto_cod_multa = fields.Char(
+ size=1,
+ string='Código da Multa',
+ help='Código adotado pela FEBRABAN para identificação'
+ ' do tipo de pagamento de multa.',
+ )
instrucao_boleto_perc_multa = fields.Text(
'Instrução Multa por Atraso',
help=' Multa por atraso - é o valor percentual acrescido uma única'
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index 635bf34c59c6..b3684e4f870d 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -40,8 +40,10 @@
+
+
From b1d3d2d4379615f892f72add99af71f2a6590dac Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 16:54:05 -0300
Subject: [PATCH 231/612] [REF] prepare l10n_br_account_payment_order to merge
with l10n_br_payment_order_cobranca
---
.../models/account_move_line.py | 36 ++++++++-------
.../models/account_payment_line.py | 45 ++++++-------------
.../models/account_payment_mode.py | 35 +++++++--------
.../models/account_payment_order.py | 6 ---
.../models/res_partner_bank.py | 13 +-----
.../views/account_due_list.xml | 4 +-
.../views/account_payment_line.xml | 6 +--
.../views/account_payment_mode.xml | 7 +--
.../views/account_payment_order.xml | 41 ++---------------
9 files changed, 59 insertions(+), 134 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 143949a6b026..0f6e70edb39c 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -6,26 +6,28 @@
class AccountMoveLine(models.Model):
- _inherit = "account.move.line"
+ _inherit = 'account.move.line'
- date_scheduled = fields.Date(string="Data Prevista")
-
- @api.depends("move_id")
- def _compute_journal_entry_ref(self):
- for record in self:
- if record.name:
- record.journal_entry_ref = record.name
- elif record.move_id.name:
- record.journal_entry_ref = record.move_id.name
- elif record.invoice_id and record.invoice_id.number:
- record.journal_entry_ref = record.invoice_id.number
- else:
- record.journal_entry_ref = "*" + str(record.move_id.id)
-
- journal_entry_ref = fields.Char(
- compute="_compute_journal_entry_ref", string="Journal Entry Ref", store=True
+ date_scheduled = fields.Date(
+ string='Data Prevista',
)
+ # journal_entry_ref = fields.Char(
+ # compute="_compute_journal_entry_ref", string="Journal Entry Ref", store=True
+ # )
+ #
+ # @api.depends("move_id")
+ # def _compute_journal_entry_ref(self):
+ # for record in self:
+ # if record.name:
+ # record.journal_entry_ref = record.name
+ # elif record.move_id.name:
+ # record.journal_entry_ref = record.move_id.name
+ # elif record.invoice_id and record.invoice_id.number:
+ # record.journal_entry_ref = record.invoice_id.number
+ # else:
+ # record.journal_entry_ref = "*" + str(record.move_id.id)
+
@api.multi
def get_balance(self):
"""
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index e35f5a6abc2e..ed81983fab62 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -2,32 +2,14 @@
# Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, fields, api
+from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
-from odoo.tools.float_utils import float_round as round
-from .account_payment_mode import OPERATION_TYPE
+from odoo.tools.float_utils import float_round as round # TODO check round methods in 12.0
class PaymentLine(models.Model):
_inherit = 'account.payment.line'
- @api.model
- def _get_info_partner(self, partner_record):
- if not partner_record:
- return False
- st = partner_record.street or ''
- n = partner_record.street_number or ''
- st1 = partner_record.street2 or ''
- zip = partner_record.zip or ''
- city = partner_record.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 ''
- cnpj = partner_record.cnpj_cpf or ''
- return partner_record.legal_name or '' + "\n" + cnpj + "\n" + st \
- + ", " + n + " " + st1 + "\n" + zip_city + "\n" + cntry
-
@api.multi
@api.depends('percent_interest', 'amount_currency')
def _compute_interest(self):
@@ -38,16 +20,17 @@ def _compute_interest(self):
record.amount_currency * (
record.percent_interest / 100), precision)
- linha_digitavel = fields.Char(string="Linha Digitável")
- percent_interest = fields.Float(string="Percentual de Juros",
- digits=dp.get_precision('Account'))
- amount_interest = fields.Float(string="Valor Juros",
- compute='_compute_interest',
- digits=dp.get_precision('Account'))
+ linha_digitavel = fields.Char(
+ string='Linha Digitável',
+ )
+
+ percent_interest = fields.Float(
+ string='Percentual de Juros',
+ digits=dp.get_precision('Account'),
+ )
- operation_type = fields.Selection(
- selection=OPERATION_TYPE,
- string='Tipo de Operação',
- related='order_id.operation_type',
- store=True
+ amount_interest = fields.Float(
+ string='Valor Juros',
+ compute='_compute_interest',
+ digits=dp.get_precision('Account'),
)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 928076066422..650a2b1bf172 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -1,31 +1,30 @@
# Copyright (C) 2012-Today - KMEE ().
# @author Luis Felipe Miléo - mileo@kmee.com.br
+# @author Renato Lima - renato.lima@akretion.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import fields, models
-
-OPERATION_TYPE = [
- ('1', 'Pagamento'),
- ('2', 'Debito em conta corrente'),
-]
+from odoo import _, fields, models
class AccountPaymentMode(models.Model):
- _inherit = "account.payment.mode"
+ _inherit = 'account.payment.mode'
+
+ internal_sequence_id = fields.Many2one(
+ comodel_name='ir.sequence',
+ string='Sequência',
+ )
- internal_sequence_id = fields.Many2one("ir.sequence", "Sequência")
- instrucoes = fields.Text("Instruções de cobrança")
- invoice_print = fields.Boolean("Gerar relatorio na conclusão da fatura?")
+ instrucoes = fields.Text(
+ string='Instruções de cobrança',
+ )
- operation_type = fields.Selection(
- selection=OPERATION_TYPE,
- string='Tipo de Operação'
+ invoice_print = fields.Boolean(
+ string='Gerar relatorio na conclusão da fatura?'
)
- _sql_constraints = [
- (
- "internal_sequence_id_unique",
- "unique(internal_sequence_id)",
- "Sequência já usada! Crie uma sequência unica para cada modo",
+ _sql_constraints = [(
+ "internal_sequence_id_unique",
+ "unique(internal_sequence_id)",
+ _("Sequência já usada! Crie uma sequência unica para cada modo"),
)
]
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 5ed69f16f384..8ca0b0f3581f 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -3,13 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
-from .account_payment_mode import OPERATION_TYPE
class AccountPaymentOrder(models.Model):
_inherit = 'account.payment.order'
-
- operation_type = fields.Selection(
- selection=OPERATION_TYPE,
- string='Tipo de Operação',
- )
diff --git a/l10n_br_account_payment_order/models/res_partner_bank.py b/l10n_br_account_payment_order/models/res_partner_bank.py
index 87d7b594726d..407ff2d832f1 100644
--- a/l10n_br_account_payment_order/models/res_partner_bank.py
+++ b/l10n_br_account_payment_order/models/res_partner_bank.py
@@ -9,15 +9,4 @@
class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"
- @api.multi
- @api.constrains("bra_number")
- def check_bra_number(self):
- for record in self:
- if record.bank_id.code_bc == "033":
- if len(record.bra_number) > 4:
- raise UserError(
- _(
- u"O cógido da Agencia Bancaria do Santander"
- u" deve ter no máximo quatro caracteres."
- )
- )
+ # TODO REMOVE THIS FILE
diff --git a/l10n_br_account_payment_order/views/account_due_list.xml b/l10n_br_account_payment_order/views/account_due_list.xml
index 2269b063c65d..1d5f7c830876 100644
--- a/l10n_br_account_payment_order/views/account_due_list.xml
+++ b/l10n_br_account_payment_order/views/account_due_list.xml
@@ -1,8 +1,8 @@
-
- l10n_br_account_payment_order.aml
+
+ l10n_br_account_payment_order.move.line.payments.tree
account.move.line
diff --git a/l10n_br_account_payment_order/views/account_payment_line.xml b/l10n_br_account_payment_order/views/account_payment_line.xml
index 602f85c43726..cb8c9d5e0865 100644
--- a/l10n_br_account_payment_order/views/account_payment_line.xml
+++ b/l10n_br_account_payment_order/views/account_payment_line.xml
@@ -7,16 +7,14 @@
- l10n_br_account.payment.line.form.banking
+ l10n_br_account.payment.line.form
account.payment.line
primary
-
+
-
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 31ce39e1e7aa..08008b341d54 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -3,7 +3,7 @@
- payment.mode.l10n_br_payment.form.inherit
+ payment.mode.l10n_br_payment.form
account.payment.mode
@@ -21,11 +21,6 @@
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/account_payment_order.xml b/l10n_br_account_payment_order/views/account_payment_order.xml
index 0083255c8a93..53e2132fd987 100644
--- a/l10n_br_account_payment_order/views/account_payment_order.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order.xml
@@ -7,47 +7,12 @@
- l10n_br_account.payment.order.form.banking
+ l10n_br_account.payment.order.form
account.payment.order
- primary
-
+
-
-
-
-
-
-
-
-
-
-
- l10n_br_account.payment.order.form.banking.payment
- account.payment.order
- primary
-
-
-
- {'default_payment_type': payment_type, 'form_view_ref': 'l10n_br_account_payment_order.l10n_br_account_payment_line_form'}
-
-
-
-
-
- l10n_br_account.payment.order.form.banking.debit
- account.payment.order
- primary
-
-
-
- {'default_payment_type': payment_type, 'form_view_ref': 'l10n_br_account_payment_order.l10n_br_account_payment_line_form'}
+
From 1e5fd59eb555acbb66f5858c7ba049a25829c6e4 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 18:25:16 -0300
Subject: [PATCH 232/612] Move files from cobranca module to new module to
separe Bank API feature
---
.../models/account_invoice_api_confirm.py | 91 ------------
.../models/bank_api_operation.py | 119 ----------------
.../views/bank_api_operation_views.xml | 129 ------------------
3 files changed, 339 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
delete mode 100644 l10n_br_account_payment_cobranca/models/bank_api_operation.py
delete mode 100644 l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py b/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
deleted file mode 100644
index 7a54a3adb272..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_invoice_api_confirm.py
+++ /dev/null
@@ -1,91 +0,0 @@
-import logging
-
-from odoo import api, fields, models
-from odoo.exceptions import UserError
-
-_logger = logging.getLogger(__name__)
-
-
-class AccountInvoiceAPIConfirm(models.TransientModel):
- """
- Esse wizard é utilizado para seleção de faturas a serem registradas no
- banco via API
- """
-
- _name = "account.invoice.api.confirm"
- _description = "Registrar as faturas selecionadas via API"
-
- environment = fields.Char(
- string="Ambiente", default=lambda self: self._default_environment()
- )
-
- invoice_ids = fields.Many2many(
- comodel_name="account.invoice",
- string="Faturas",
- default=lambda self: self._default_invoice_ids(),
- )
-
- @api.model
- def _default_invoice_ids(self):
- active_ids = self.env["account.invoice"].browse(self._context.get("active_ids"))
-
- valid_ids = active_ids.filtered(
- lambda a: a.state == "open"
- and a.eval_state_cnab
- not in ["added_paid", "accepted", "done", "accepted_hml"]
- ).ids
-
- return valid_ids
-
- @api.model
- def _default_environment(self):
- # TODO: Multi-company approach
- active_ids = self.env["account.invoice"].browse(self._context.get("active_ids"))
- environment = active_ids[:1].partner_id.company_id.environment
- if not environment:
- message = (
- "Nenhum ambiente está configurado no cadastro da "
- "empresa. Favor escolher entre Produção e Homologação."
- )
- _logger.error(message)
- raise UserError(message)
-
- try:
- environment_text = (
- self.env["res.company"]
- ._fields.get("environment")
- .selection[int(environment) - 1][-1]
- )
- except Exception as e:
- message = "Erro ao obter ambiente. %s" % str(e)
- _logger.error(message)
- raise UserError(message)
-
- return environment_text
-
- @api.multi
- def api_register_confirm(self):
- # TODO: Redundant code
- environment = self.env.user.company_id.environment
- for record in self:
- if len(record.invoice_ids) > 1:
- for invoice_id in record.invoice_ids:
- try:
- invoice_id.obtain_token(
- self.env.user.company_id.sudo(), environment
- )
- invoice_id.with_delay().register_invoice_api()
- except Exception as e:
- _logger.debug(
- "Erro ao processar fatura %s. %s"
- % (invoice_id.number, str(e))
- )
- else:
- for invoice_id in record.invoice_ids:
- try:
- invoice_id.register_invoice_api()
- except Exception as e:
- _logger.debug(
- "Erro ao processar fatura %s. %s"
- % (invoice_id.number, str(e))
- )
diff --git a/l10n_br_account_payment_cobranca/models/bank_api_operation.py b/l10n_br_account_payment_cobranca/models/bank_api_operation.py
deleted file mode 100644
index d3c5e5620c95..000000000000
--- a/l10n_br_account_payment_cobranca/models/bank_api_operation.py
+++ /dev/null
@@ -1,119 +0,0 @@
-import json
-
-from odoo import api, fields, models
-
-SELECTION_OPERATION_TYPE = [
- ("post", "Post"),
- ("token_request", "Requisição de Token"),
- ("invoice_register", "Registro de Fatura"),
- ("invoice_query", "Consulta de Fatura"),
- ("invoice_update", "Atualização de Fatura"),
- ("invoice_cancellation", "Baixa de Fatura"),
-]
-
-
-class BankAPIOperation(models.Model):
- _name = "bank.api.operation"
- _rec_name = "name"
-
- name = fields.Char(
- string="Nome", compute="_compute_name", readonly=True, store=True
- )
-
- environment = fields.Selection(
- string="Ambiente",
- selection=[("1", "Homologação"), ("2", "Produção")],
- readonly=True,
- required=True,
- )
-
- @api.multi
- @api.depends("operation_datetime", "operation_type")
- def _compute_name(self):
- for record in self:
- name = record.operation_datetime
- if record.operation_type:
- name += " - " + dict(self._fields["operation_type"].selection).get(
- record.operation_type
- )
- record.name = name
-
- invoice_id = fields.Many2one(
- comodel_name="account.invoice", string="Fatura", readonly=True
- )
-
- operation_datetime = fields.Datetime(
- string="Data da Operação", default=fields.Datetime.now, readonly=True
- )
-
- user_id = fields.Many2one(
- comodel_name="res.users",
- string="Usuário",
- default=lambda self: self.env.uid,
- readonly=True,
- )
-
- operation_type = fields.Selection(
- string="Tipo da Operação",
- selection=SELECTION_OPERATION_TYPE,
- required=True,
- readonly=True,
- )
-
- message_sent = fields.Text(string="Mensagem Enviada", readonly=True)
-
- message_received = fields.Text(string="Mensagem Recebida", readonly=True)
-
- status = fields.Char(string="Estado", readonly=True)
-
- endpoint = fields.Char(string="Endpoint", readonly=True)
-
- operation_error_line_ids = fields.One2many(
- string="Linhas de Erro",
- comodel_name="bank.api.operation.error.line",
- inverse_name="operation_id",
- readonly=True,
- )
-
- error_400 = fields.Boolean(string="Erro 400", default=False, readonly=True)
-
- def register_post(self, request):
- self.endpoint = request.request.url
- self.status = "[{}] - {}".format(request.status_code, request.reason)
-
- self.message_sent = request.request.body
- self.message_received = request.content
-
- if request.status_code == 400:
- self.error_400 = True
- content_json = json.loads(request.content)
- operation_line_model = self.env["bank.api.operation.error.line"]
- for campo in content_json.get("campos"):
-
- data = {
- "operation_id": self.id,
- "field_name": campo.get("campo"),
- "field_value": "%s (%s)"
- % (campo.get("valor"), type(campo.get("valor")).__name__),
- "error_message": campo.get("mensagem"),
- }
- operation_line = operation_line_model.create(data)
- self.operation_error_line_ids += operation_line
-
-
-class BankAPIOperationErrorLine(models.Model):
- _name = "bank.api.operation.error.line"
- _rec_name = "field_name"
-
- operation_id = fields.Many2one(
- string="Operação Bancária",
- comodel_name="bank.api.operation",
- required=True,
- readonly=True,
- )
-
- field_name = fields.Char(string="Nome do Campo", readonly=True)
-
- field_value = fields.Char(string="Valor do Campo", readonly=True)
-
- error_message = fields.Char(string="Mensagem de Erro", readonly=True)
diff --git a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml b/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
deleted file mode 100644
index 75e5f73001be..000000000000
--- a/l10n_br_account_payment_cobranca/views/bank_api_operation_views.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
- bank.api.operation.tree.view
- bank.api.operation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bank.api.operation.form.view
- bank.api.operation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- action.bank.api.operation
- ir.actions.act_window
- bank.api.operation
- form
- tree,form
-
-
-
-
-
From 57c9fea0aed1677084d5fd450dd7299d509050a2 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 18:26:12 -0300
Subject: [PATCH 233/612] [REF] move objects from cobranca module to bank api
---
.../models/__init__.py | 3 -
.../models/account_invoice.py | 112 ------------------
.../models/res_company.py | 16 ---
.../views/account_invoice.xml | 51 --------
.../views/res_company.xml | 25 +---
5 files changed, 6 insertions(+), 201 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
index d1f935400f96..8224bbc4da0b 100644
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ b/l10n_br_account_payment_cobranca/models/__init__.py
@@ -1,7 +1,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice
-from . import account_invoice_api_confirm
from . import account_move
from . import account_move_line
from . import account_payment
@@ -9,11 +8,9 @@
from . import account_payment_mode
from . import account_payment_order
from . import account_payment_term
-from . import bank_api_operation
from . import bank_payment_line
from . import l10n_br_cnab
from . import l10n_br_cnab_evento
from . import l10n_br_cnab_lote
from . import res_company
from . import res_partner_bank
-from .. import constantes
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 147165b53651..6e1cc910f071 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -61,19 +61,6 @@ def _compute_receivables(self):
instrucoes = fields.Text(string="Instruções de cobrança")
- bank_api_operation_ids = fields.One2many(
- string="Operações Realizadas",
- comodel_name="bank.api.operation",
- inverse_name="invoice_id",
- readonly=True,
- )
-
- operation_type = fields.Selection(related="payment_mode_id.operation_type")
-
- def register_invoice_api(self):
- """ Registrar o boleto via sua API"""
- raise NotImplementedError
-
@api.onchange("payment_mode_id")
def _onchange_payment_mode_id(self):
tax_analytic_tag_id = self.env.ref(
@@ -192,105 +179,6 @@ def action_invoice_cancel(self):
super(AccountInvoice, self).action_invoice_cancel()
- def create_bank_api_operation(
- self, request, operation_type=False, environment=False
- ):
- # 'not request' não é válido para o propósito
- if request == False:
- return
-
- operation_model = self.env["bank.api.operation"]
-
- if not operation_type:
- operation_type = "post"
-
- data = {
- "operation_type": operation_type,
- "invoice_id": self.id,
- "environment": environment,
- }
-
- operation_id = operation_model.create(data)
- operation_id.register_post(request)
- self.bank_api_operation_ids += operation_id
-
- @api.multi
- def create_api_account_payment_line(self):
- # TODO: Criar CRON para confirmar as account.payment.order no final de
- # cada dia
- apoo = self.env["account.payment.order"]
- result_payorder_ids = []
- payorder = False
- for inv in self:
- if inv.state != "open":
- raise UserError(_("The invoice %s is not in Open state") % inv.number)
- if not inv.move_id:
- raise UserError(_("No Journal Entry on invoice %s") % inv.number)
- applicable_lines = inv.move_id.line_ids.filtered(
- lambda x: (
- not x.reconciled
- and x.payment_mode_id.payment_order_ok
- and x.account_id.internal_type in ("receivable", "payable")
- and not x.payment_line_ids
- )
- )
- if not applicable_lines:
- raise UserError(
- _(
- "No Payment Line created for invoice %s because "
- "it already exists or because this invoice is "
- "already paid."
- )
- % inv.number
- )
- payment_modes = applicable_lines.mapped("payment_mode_id")
- if not payment_modes:
- raise UserError(_("No Payment Mode on invoice %s") % inv.number)
- for payment_mode in payment_modes:
- payorder = apoo.search(
- [
- ("payment_mode_id", "=", payment_mode.id),
- ("state", "=", "draft"),
- ("active", "=", False),
- ("name", "ilike", "api"),
- ],
- limit=1,
- )
-
- new_payorder = False
- if not payorder:
- payorder = apoo.create(
- inv._prepare_new_payment_order(payment_mode)
- )
- new_payorder = True
- payorder.name += "_api"
- payorder.active = False
-
- result_payorder_ids.append(payorder.id)
- count = 0
- for line in applicable_lines.filtered(
- lambda x: x.payment_mode_id == payment_mode
- ):
- line.create_payment_line_from_move_line(payorder)
- count += 1
- if new_payorder:
- inv.message_post(
- _(
- "%d payment lines added to the new draft payment "
- "order %s which has been automatically created."
- )
- % (count, payorder.name)
- )
- else:
- inv.message_post(
- _(
- "%d payment lines added to the existing draft "
- "payment order %s."
- )
- % (count, payorder.name)
- )
- return payorder
-
@api.multi
def get_invoice_fiscal_number(self):
""" Como neste modulo nao temos o numero do documento fiscal,
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_cobranca/models/res_company.py
index 5423b9c505d7..e6dd7cae73d2 100644
--- a/l10n_br_account_payment_cobranca/models/res_company.py
+++ b/l10n_br_account_payment_cobranca/models/res_company.py
@@ -31,22 +31,6 @@ class ResCompany(models.Model):
default="1",
)
- client_id = fields.Char(string="ID do Cliente")
-
- client_secret = fields.Char(string="Segredo")
-
- itau_key = fields.Char(string="Chave")
-
- api_endpoint = fields.Char(string="API ENDPOINT")
-
- raiz_endpoint = fields.Char(string="RAIZ ENDPOINT")
-
- api_itau_token = fields.Char(string="Itaú API Token", readonly=True)
-
- api_itau_token_due_datetime = fields.Datetime(
- string="Validade do Token", readonly=True
- )
-
@api.multi
def get_own_number_sequence(self):
self.ensure_one()
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index 1ac13eff6648..f1079e2cdb2a 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -1,45 +1,6 @@
-
- account.invoice.api.form
- account.invoice.api.confirm
-
-
-
-
-
-
-
-
-
- Você está prestes a registrar uma faturamente diretamente
- com o Banco. Verifique se o ambiente selecionado está de
- acordo com a operação que deseja realizar.
-
-
-
-
-
-
-
-
- Registrar faturas via API
- account.invoice.api.confirm
- form
-
- new
-
-
-
-
view.l10n_br_account.invoice.form.form.inherit
@@ -96,18 +57,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
view.account.invoice.filter.inherit
account.invoice
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_cobranca/views/res_company.xml
index 8ae4b80bb8f6..459efb042b7e 100644
--- a/l10n_br_account_payment_cobranca/views/res_company.xml
+++ b/l10n_br_account_payment_cobranca/views/res_company.xml
@@ -1,33 +1,20 @@
-
- l10n_br_account_payment_boleto.res.company.form
-
+
+
+ l10n_br_account_payment_order.res.company.form
res.company
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
From 1eed2fa45a2bff6a6bbaf871145400de71d49706 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 18:53:12 -0300
Subject: [PATCH 234/612] Comment l10n_br_account_payment_order menus file
---
l10n_br_account_payment_order/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 37b53c868065..abbbd1e2e0f7 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -19,7 +19,7 @@
'data': [
'views/account_due_list.xml',
'views/account_payment_order.xml',
- 'views/account_payment_order_menu_views.xml',
+ # 'views/account_payment_order_menu_views.xml',
'views/account_payment_line.xml',
'views/account_payment_mode.xml',
],
From 85f74b09d677b93607e12693c097615ef28411d5 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 18:54:11 -0300
Subject: [PATCH 235/612] [REF] remove field operation_type in
l10n_br_account_payment_order
---
.../i18n/l10n_br_account_payment_order.pot | 20 -------------------
l10n_br_account_payment_order/i18n/pt_BR.po | 17 +++-------------
2 files changed, 3 insertions(+), 34 deletions(-)
diff --git a/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot b/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
index 503ad9ddbc55..c934434eac26 100644
--- a/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
+++ b/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
@@ -35,12 +35,6 @@ msgstr ""
msgid "Data Prevista"
msgstr ""
-#. module: l10n_br_account_payment_order
-#: selection:account.payment.mode,operation_type:0
-#: selection:account.payment.order,operation_type:0
-msgid "Debito em conta corrente"
-msgstr ""
-
#. module: l10n_br_account_payment_order
#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
msgid "Geral"
@@ -77,12 +71,6 @@ msgstr ""
msgid "O cógido da Agencia Bancaria do Santander deve ter no máximo quatro caracteres."
msgstr ""
-#. module: l10n_br_account_payment_order
-#: selection:account.payment.mode,operation_type:0
-#: selection:account.payment.order,operation_type:0
-msgid "Pagamento"
-msgstr ""
-
#. module: l10n_br_account_payment_order
#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_line
msgid "Payment Lines"
@@ -123,15 +111,7 @@ msgstr ""
msgid "Sequência já usada! Crie uma sequência unica para cada modo"
msgstr ""
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__operation_type
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__operation_type
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_order__operation_type
-msgid "Tipo de Operação"
-msgstr ""
-
#. module: l10n_br_account_payment_order
#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__amount_interest
msgid "Valor Juros"
msgstr ""
-
diff --git a/l10n_br_account_payment_order/i18n/pt_BR.po b/l10n_br_account_payment_order/i18n/pt_BR.po
index a8afe829535b..96282b79239c 100644
--- a/l10n_br_account_payment_order/i18n/pt_BR.po
+++ b/l10n_br_account_payment_order/i18n/pt_BR.po
@@ -40,12 +40,15 @@ msgid "Data Prevista"
msgstr "Data Prevista"
#. module: l10n_br_account_payment_order
+<<<<<<< HEAD
#: selection:account.payment.mode,operation_type:0
#: selection:account.payment.order,operation_type:0
msgid "Debito em conta corrente"
msgstr "Debito em conta corrente"
#. module: l10n_br_account_payment_order
+=======
+>>>>>>> [REF] remove field operation_type in l10n_br_account_payment_order
#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
msgid "Geral"
msgstr "Geral"
@@ -85,12 +88,6 @@ msgstr ""
"O código da Agencia Bancaria do Santander deve ter no máximo quatro "
"caracteres."
-#. module: l10n_br_account_payment_order
-#: selection:account.payment.mode,operation_type:0
-#: selection:account.payment.order,operation_type:0
-msgid "Pagamento"
-msgstr "Pagamento"
-
#. module: l10n_br_account_payment_order
#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_line
msgid "Payment Lines"
@@ -131,14 +128,6 @@ msgstr "Sequência"
msgid "Sequência já usada! Crie uma sequência unica para cada modo"
msgstr "Sequência já usada! Crie uma sequência unica para cada modo"
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__operation_type
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__operation_type
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_order__operation_type
-msgid "Tipo de Operação"
-msgstr "Tipo de Operação"
-
-#. module: l10n_br_account_payment_order
#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__amount_interest
msgid "Valor Juros"
msgstr "Valor Juros"
From 07e0f224cfd3b8503602010f77c71ea19ff2852a Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Tue, 18 Aug 2020 18:54:25 -0300
Subject: [PATCH 236/612] [REF] remove field operation_type in
l10n_br_account_payment_cobranca
---
.../demo/account_payment_mode_demo.xml | 15 ++++-----------
.../models/account_invoice.py | 13 -------------
.../models/account_payment_mode.py | 1 -
.../models/account_payment_order.py | 1 -
.../views/account_invoice.xml | 12 ------------
5 files changed, 4 insertions(+), 38 deletions(-)
diff --git a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
index 2731c168e7cd..cb837c73a4c6 100644
--- a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
@@ -15,7 +15,6 @@
True
- 3
06
03
DM
@@ -37,7 +36,6 @@
True
- 3
06
3
DM
@@ -62,8 +60,7 @@
True
- 3
- 06
+ 06
3
DM
19
@@ -87,8 +84,7 @@
True
- 3
- 06
+ 06
3
DM
19
@@ -109,8 +105,7 @@
True
- 3
- 06
+ 06
3
DM
19
@@ -131,8 +126,7 @@
True
- 3
- 06
+ 06
3
DM
19
@@ -153,7 +147,6 @@
True
- 3
06
3
DM
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_cobranca/models/account_invoice.py
index 6e1cc910f071..fa4d94922f26 100644
--- a/l10n_br_account_payment_cobranca/models/account_invoice.py
+++ b/l10n_br_account_payment_cobranca/models/account_invoice.py
@@ -315,19 +315,6 @@ def invoice_validate(self):
filtered_invoice_ids.create_account_payment_line()
return result
- @api.multi
- def _prepare_new_payment_order(self, payment_mode=None):
- vals = super(AccountInvoice, self)._prepare_new_payment_order(payment_mode)
- if payment_mode is None:
- payment_mode = self.env["account.payment.mode"]
- vals.update(
- {
- "operation_type": payment_mode.operation_type
- or self.payment_mode_id.operation_type
- }
- )
- return vals
-
@api.multi
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index 0a3c310c71c0..b3bd59694f5e 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -119,7 +119,6 @@ class PaymentMode(models.Model):
string="Conta Padrão",
help="Conta padrão para Taxa",
)
- operation_type = fields.Selection(selection_add=[("3", "Cobrança")])
cnab_sequence_id = fields.Many2one(
comodel_name='ir.sequence',
string=u'Sequencia do CNAB')
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 2734e8f983a0..66749a9af30f 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -66,7 +66,6 @@ class PaymentOrder(models.Model):
readonly=True,
domain=[("is_erro_exportacao", "=", True)],
)
- operation_type = fields.Selection(selection_add=[("3", "Cobrança")])
def _confirm_debit_orders_api(self):
"""
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_cobranca/views/account_invoice.xml
index f1079e2cdb2a..57835888ef94 100644
--- a/l10n_br_account_payment_cobranca/views/account_invoice.xml
+++ b/l10n_br_account_payment_cobranca/views/account_invoice.xml
@@ -36,20 +36,8 @@
-
-
-
-
-
-
-
-
-
-
-
From 145b676e3b6eeeb3a2771a3e6f0ed50dea962cc8 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 19 Aug 2020 13:36:57 -0300
Subject: [PATCH 237/612] [12.0][MIG][REF] Change name fields from portuguese
to english.
---
.../__manifest__.py | 4 +-
.../demo/account_payment_mode_demo.xml | 80 ++++----
.../migrations/12.0.2.0.0/pre-migration.py | 125 +++++++++++++
.../models/account_move_line.py | 64 +++----
.../models/account_payment_line.py | 76 ++++----
.../models/account_payment_mode.py | 174 ++++++++----------
.../models/account_payment_order.py | 84 ++++-----
.../models/bank_payment_line.py | 99 +++++-----
.../models/l10n_br_cnab.py | 16 +-
.../models/l10n_br_cnab_evento.py | 76 ++++----
.../models/l10n_br_cnab_lote.py | 26 +--
.../views/account_move_line.xml | 12 +-
.../views/account_payment_line.xml | 18 +-
.../views/account_payment_mode.xml | 44 ++---
.../views/account_payment_order.xml | 20 +-
.../views/bank_payment_line.xml | 26 +--
.../views/l10n_br_cnab_evento_views.xml | 4 +-
.../views/l10n_br_cnab_retorno_view.xml | 124 ++++++-------
18 files changed, 584 insertions(+), 488 deletions(-)
create mode 100644 l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
index fa70fef6b288..d98cc2081d93 100644
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ b/l10n_br_account_payment_cobranca/__manifest__.py
@@ -7,7 +7,7 @@
{
'name': 'Account Payment CNAB',
- 'version': '12.0.1.0.0',
+ 'version': '12.0.2.0.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'author': 'KMEE, Odoo Community Association (OCA)',
@@ -27,7 +27,7 @@
'views/account_payment_term_view.xml',
'views/bank_payment_line.xml',
'views/account_invoice.xml',
- 'views/bank_api_operation_views.xml',
+ # 'views/bank_api_operation_views.xml',
'views/account_move_line.xml',
'views/l10n_br_cnab_retorno_view.xml',
'views/l10n_br_cnab_evento_views.xml',
diff --git a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
index cb837c73a4c6..1aad702d2ba9 100644
--- a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
@@ -15,11 +15,11 @@
True
- 06
- 03
- DM
- 19
- S
+ 06
+ 03
+ DM
+ 19
+ S
@@ -36,15 +36,15 @@
True
- 06
- 3
- DM
- 19
- N
+ 06
+ 21
+ DM
+ 19
+ N
- 2
- 5
+ 2
+ 5
72234050
@@ -60,16 +60,16 @@
True
- 06
- 3
- DM
- 19
- N
+ 06
+ 3
+ DM
+ 19
+ N
- 2
- 5
- 72234050
+ 2
+ 5
+ 72234050
@@ -84,11 +84,11 @@
True
- 06
- 3
- DM
- 19
- S
+ 06
+ 3
+ DM
+ 19
+ S
@@ -105,11 +105,11 @@
True
- 06
- 3
- DM
- 19
- S
+ 06
+ 3
+ DM
+ 19
+ S
@@ -126,11 +126,11 @@
True
- 06
- 3
- DM
- 19
- S
+ 06
+ 3
+ DM
+ 19
+ S
@@ -147,11 +147,11 @@
True
- 06
- 3
- DM
- 19
- S
+ 06
+ 3
+ DM
+ 19
+ S
diff --git a/l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py
new file mode 100644
index 000000000000..ad0f1fab96de
--- /dev/null
+++ b/l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py
@@ -0,0 +1,125 @@
+# @ 2020 Akretion - www.akretion.com.br -
+# Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
+
+from openupgradelib import openupgrade
+
+_column_renames = {
+ 'account.payment.mode': [
+ ('condicao_da_papeleta', 'condition_issuing_paper'),
+ ('comunicacao_2', 'communication_2'),
+ ('tipo_servico', 'service_type'),
+ ('forma_lancamento', 'release_form'),
+ ('codigo_convenio', 'code_convetion'),
+ ('codigo_finalidade_doc', 'doc_finality_code'),
+ ('codigo_finalidade_ted', 'ted_finality_code'),
+ ('codigo_finalidade_complementar', 'complementary_finality_code'),
+ ('aviso_ao_favorecido', 'favored_warning'),
+ ('boleto_carteira', 'boleto_wallet'),
+ ('boleto_modalidade', 'boleto_modality'),
+ ('boleto_convenio', 'boleto_convetion'),
+ ('boleto_variacao', 'boleto_variation'),
+ ('boleto_aceite', 'boleto_accept'),
+ ('boleto_especie', 'boleto_species'),
+ ('boleto_cod_protesto', 'boleto_protest_code'),
+ ('boleto_dias_protesto', 'boleto_days_protest'),
+ ('gera_nosso_numero', 'generate_own_number'),
+ ('boleto_posto', 'boleto_post'),
+ ('boleto_cod_mora', 'boleto_interest_code'),
+ ('boleto_perc_mora', 'boleto_interest_perc'),
+ ('boleto_cod_multa', 'boleto_fee_code'),
+ ('boleto_perc_multa', 'boleto_fee_perc'),
+ ],
+ 'account.payment.line': [
+ ('nosso_numero', 'own_number'),
+ ('numero_documento', 'document_number'),
+ ('identificacao_titulo_empresa', 'company_title_identification'),
+ ('codigo_finalidade_doc', 'doc_finality_code'),
+ ('codigo_finalidade_ted', 'ted_finality_code'),
+ ('codigo_finalidade_complementar', 'complementary_finality_code'),
+ ('aviso_ao_favorecido', 'favored_warning'),
+ ('abatimento', 'rebate_value'),
+ ('desconto', 'discount_value'),
+ ('mora', 'interest_value'),
+ ('multa', 'fee_value'),
+ ],
+ 'account.payment.order': [
+ ('tipo_servico', 'service_type'),
+ ('forma_lancamento', 'release_form'),
+ ('codigo_convenio', 'code_convetion'),
+ ('indicativo_forma_pagamento', 'indicative_form_payment'),
+ ('tipo_movimento', 'movement_type'),
+ ('codigo_instrucao_movimento', 'movement_instruction_code'),
+ ],
+ 'bank.payment.line': [
+ ('codigo_finalidade_doc', 'doc_finality_code'),
+ ('codigo_finalidade_ted', 'ted_finality_code'),
+ ('codigo_finalidade_complementar', 'complementary_finality_code'),
+ ('aviso_ao_favorecido', 'favored_warning'),
+ ('abatimento', 'rebate_value'),
+ ('desconto', 'discount_value'),
+ ('mora', 'interest_value'),
+ ('multa', 'fee_value'),
+ ('evento_id', 'event_id'),
+ ('nosso_numero', 'own_number'),
+ ('numero_documento', 'document_number'),
+ ('identificacao_titulo_empresa', 'company_title_identification'),
+ ('is_erro_exportacao', 'is_export_error'),
+ ('mensagem_erro_exportacao', 'export_error_message'),
+ ('ultimo_estado_cnab', 'last_state_cnab')
+ ],
+ 'l10n_br.cnab.evento': [
+ ('data_real_pagamento', 'real_payment_date'),
+ ('data_ocorrencia', 'occurrence_date'),
+ ('data_vencimento', 'due_date'),
+ ('favorecido_conta_bancaria_id', 'favored_bank_account_id'),
+ ('favorecido_id', 'favored_id'),
+ ('identificacao_titulo_empresa', 'company_title_identification'),
+ ('juros_mora_multa', 'interest_fee_value'),
+ ('nosso_numero', 'own_number'),
+ ('ocorrencias', 'occurrences'),
+ ('outros_creditos', 'other_credits'),
+ ('segmento', 'segment'),
+ ('numero_documento', 'document_number'),
+ ('seu_numero', 'your_number'),
+ ('tipo_moeda', 'currency_type'),
+ ('tarifa_cobranca', 'tariff_charge'),
+ ('valor', 'title_value'),
+ ('valor_abatimento', 'rebate_value'),
+ ('valor_desconto', 'discount_value'),
+ ('valor_iof', 'iof_value'),
+ ('valor_pagamento', 'payment_value'),
+ ],
+ 'l10n_br.cnab.lote': [
+ ('empresa_inscricao_numero', 'company_registration_number'),
+ ('empresa_inscricao_tipo', 'company_registration_type'),
+ ('mensagem', 'message'),
+ ('qtd_registros', 'register_qty'),
+ ('servico_operacao', 'operation_service'),
+ ('tipo_servico', 'service_type'),
+ ('total_valores', 'total_value'),
+ ],
+ 'l10n_br.cnab': [
+ ('arquivo_retorno', 'return_file'),
+ ('data', 'cnab_date'),
+ ('data_arquivo', 'date_file'),
+ ('sequencial_arquivo', 'sequential_file'),
+ ('motivo_erro', 'reason_error'),
+ ('lote_id', 'lot_id'),
+ ('num_eventos', 'number_events'),
+ ('num_lotes', 'number_lots'),
+ ],
+ 'account.move.line': [
+ ('state_cnab', 'cnab_state'),
+ ('nosso_numero', 'own_number'),
+ ('numero_documento', 'document_number'),
+ ('identificacao_titulo_empresa', 'company_title_identification'),
+ ('situacao_pagamento', 'payment_situation'),
+ ('instrucoes', 'instructions'),
+ ('ultimo_estado_cnab', 'last_state_cnab')
+ ],
+}
+
+@openupgrade.migrate(use_env=True)
+def migrate(env, version):
+ openupgrade.rename_columns(env.cr, _column_renames)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
index cd704a209700..48be89ddbfe2 100644
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_move_line.py
@@ -12,46 +12,46 @@
class AccountMoveLine(models.Model):
- _inherit = "account.move.line"
-
- state_cnab = fields.Selection(ESTADOS_CNAB, "Estados CNAB", default="draft")
- date_payment_created = fields.Date("Data da criação do pagamento", readonly=True)
- nosso_numero = fields.Char(string="Nosso Numero")
- numero_documento = fields.Char(string="Número documento")
- identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
- situacao_pagamento = fields.Selection(
- selection=SITUACAO_PAGAMENTO, string="Situação do Pagamento", default="inicial"
+ _inherit = 'account.move.line'
+
+ cnab_state = fields.Selection(ESTADOS_CNAB, 'Estados CNAB', default='draft')
+ date_payment_created = fields.Date('Data da criação do pagamento', readonly=True)
+ own_number = fields.Char(string='Nosso Numero')
+ document_number = fields.Char(string='Número documento')
+ company_title_identification = fields.Char(string='Identificação Titulo Empresa')
+ payment_situation = fields.Selection(
+ selection=SITUACAO_PAGAMENTO, string='Situação do Pagamento', default='inicial'
)
- instrucoes = fields.Text(string="Instruções de cobrança", readonly=True)
+ instructions = fields.Text(string='Instruções de cobrança', readonly=True)
residual = fields.Monetary(
- string="Valor Residual", default=0.0, currency_field="company_currency_id"
+ string='Valor Residual', default=0.0, currency_field='company_currency_id'
)
@api.multi
def _prepare_payment_line_vals(self, payment_order):
vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
- vals["nosso_numero"] = self.nosso_numero
- vals["numero_documento"] = self.numero_documento
- vals["identificacao_titulo_empresa"] = self.identificacao_titulo_empresa
+ vals['own_number'] = self.own_number
+ vals['document_number'] = self.document_number
+ vals['company_title_identification'] = self.company_title_identification
- if self.invoice_id.state == "paid":
- vals["amount_currency"] = self.credit or self.debit
+ if self.invoice_id.state == 'paid':
+ vals['amount_currency'] = self.credit or self.debit
return vals
@api.multi
def create_payment_line_from_move_line(self, payment_order):
- """
+ '''
Altera estado do cnab para adicionado a ordem
:param payment_order:
:return:
- """
- state_cnab = "added"
- if self.invoice_id.state == "paid":
- state_cnab = "added_paid"
+ '''
+ cnab_state = 'added'
+ if self.invoice_id.state == 'paid':
+ cnab_state = 'added_paid'
- self.state_cnab = state_cnab
+ self.cnab_state = cnab_state
return super(AccountMoveLine, self).create_payment_line_from_move_line(
payment_order
@@ -64,32 +64,32 @@ def generate_boleto(self, validate=True):
@api.multi
def _update_check(self):
- if self._context.get("reprocessing"):
+ if self._context.get('reprocessing'):
return True
return super(AccountMoveLine, self)._update_check()
@api.multi
def write(self, vals):
- """
+ '''
Sobrescrita do método Write. Não deve ser possível voltar o state_cnab
ou a situacao_pagamento para um estado anterior
:param vals:
:return:
- """
+ '''
for record in self:
- state_cnab = vals.get("state_cnab")
+ state_cnab = vals.get('state_cnab')
if state_cnab and (
- record.state_cnab == "done"
+ record.state_cnab == 'done'
or (
- record.state_cnab in ["accepted", "accepted_hml"]
- and state_cnab not in ["accepted", "accepted_hml", "done"]
+ record.state_cnab in ['accepted', 'accepted_hml']
+ and state_cnab not in ['accepted', 'accepted_hml', 'done']
)
):
- vals.pop("state_cnab", False)
+ vals.pop('state_cnab', False)
- if record.situacao_pagamento not in ["inicial", "aberta"]:
- vals.pop("situacao_pagamento", False)
+ if record.situacao_pagamento not in ['inicial', 'aberta']:
+ vals.pop('situacao_pagamento', False)
return super(AccountMoveLine, self).write(vals)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
index 7bbe5e0b1829..17b2fe0ffdf0 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_line.py
@@ -8,66 +8,66 @@
COMPLEMENTO_TIPO_SERVICO)
-class PaymentLine(models.Model):
- _inherit = "account.payment.line"
+class AccountPaymentLine(models.Model):
+ _inherit = 'account.payment.line'
@api.model
def default_get(self, fields_list):
- res = super(PaymentLine, self).default_get(fields_list)
+ res = super().default_get(fields_list)
mode = (
- self.env["account.payment.order"]
- .browse(self.env.context.get("order_id"))
+ self.env['account.payment.order']
+ .browse(self.env.context.get('order_id'))
.payment_mode_id
)
- if mode.codigo_finalidade_doc:
- res.update({"codigo_finalidade_doc": mode.codigo_finalidade_doc})
- if mode.codigo_finalidade_ted:
- res.update({"codigo_finalidade_ted": mode.codigo_finalidade_ted})
- if mode.codigo_finalidade_complementar:
+ if mode.doc_finality_code:
+ res.update({'doc_finality_code': mode.doc_finality_code})
+ if mode.ted_finality_code:
+ res.update({'ted_finality_code': mode.ted_finality_code})
+ if mode.complementary_finality_code:
res.update(
- {"codigo_finalidade_complementar": mode.codigo_finalidade_complementar}
+ {'complementary_finality_code': mode.complementary_finality_code}
)
- if mode.aviso_ao_favorecido:
- res.update({"aviso_ao_favorecido": mode.aviso_ao_favorecido})
+ if mode.favored_warning:
+ res.update({'favored_warning': mode.favored_warning})
return res
- nosso_numero = fields.Char(string="Nosso Numero")
- numero_documento = fields.Char(string="Número documento")
- identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
- codigo_finalidade_doc = fields.Selection(
+ own_number = fields.Char(string='Nosso Numero')
+ document_number = fields.Char(string='Número documento')
+ company_title_identification = fields.Char(string='Identificação Titulo Empresa')
+ doc_finality_code = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string="Complemento do Tipo de Serviço",
- help="Campo P005 do CNAB",
+ string='Complemento do Tipo de Serviço',
+ help='Campo P005 do CNAB',
)
- codigo_finalidade_ted = fields.Selection(
+ ted_finality_code = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string="Código Finalidade da TED",
- help="Campo P011 do CNAB",
+ string='Código Finalidade da TED',
+ help='Campo P011 do CNAB',
)
- codigo_finalidade_complementar = fields.Char(
- size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
+ complementary_finality_code = fields.Char(
+ size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
)
- aviso_ao_favorecido = fields.Selection(
+ favored_warning = fields.Selection(
selection=AVISO_FAVORECIDO,
- string="Aviso ao Favorecido",
- help="Campo P006 do CNAB",
- default="0",
+ string='Aviso ao Favorecido',
+ help='Campo P006 do CNAB',
+ default='0',
)
- abatimento = fields.Float(
+ rebate_value = fields.Float(
digits=(13, 2),
- string="Valor do Abatimento",
- help="Campo G045 do CNAB",
+ string='Valor do Abatimento',
+ help='Campo G045 do CNAB',
default=0.00,
)
- desconto = fields.Float(
+ discount_value = fields.Float(
digits=(13, 2),
- string="Valor do Desconto",
- help="Campo G046 do CNAB",
+ string='Valor do Desconto',
+ help='Campo G046 do CNAB',
default=0.00,
)
- mora = fields.Float(
- digits=(13, 2), string="Valor da Mora", help="Campo G047 do CNAB", default=0.00
+ interest_value = fields.Float(
+ digits=(13, 2), string='Valor da Mora', help='Campo G047 do CNAB', default=0.00
)
- multa = fields.Float(
- digits=(13, 2), string="Valor da Multa", help="Campo G048 do CNAB", default=0.00
+ fee_value = fields.Float(
+ digits=(13, 2), string='Valor da Multa', help='Campo G048 do CNAB', default=0.00
)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
index b3bd59694f5e..da69217e2529 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
@@ -2,7 +2,7 @@
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models, _
+from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
from odoo.exceptions import ValidationError
@@ -11,66 +11,66 @@
TIPO_SERVICO, BOLETO_ESPECIE)
-class PaymentMode(models.Model):
- _inherit = "account.payment.mode"
+class AccountPaymentMode(models.Model):
+ _inherit = 'account.payment.mode'
- condicao_emissao_papeleta = fields.Selection(
- [("1", "Banco emite e Processa"), ("2", "Cliente emite e banco processa")],
- "Condição Emissão de Papeleta",
- default="1",
+ condition_issuing_paper = fields.Selection(
+ [('1', 'Banco emite e Processa'), ('2', 'Cliente emite e banco processa')],
+ 'Condição Emissão de Papeleta',
+ default='1',
)
cnab_percent_interest = fields.Float(
- string="Percentual de Juros", digits=dp.get_precision("Account")
+ string='Percentual de Juros', digits=dp.get_precision('Account')
)
- comunicacao_2 = fields.Char("Comunicação para o sacador avalista")
- tipo_servico = fields.Selection(
- selection=TIPO_SERVICO, string="Tipo de Serviço", help="Campo G025 do CNAB"
+ communication_2 = fields.Char('Comunicação para o sacador avalista')
+ service_type = fields.Selection(
+ selection=TIPO_SERVICO, string='Tipo de Serviço', help='Campo G025 do CNAB'
)
- forma_lancamento = fields.Selection(
- selection=FORMA_LANCAMENTO, string="Forma Lançamento", help="Campo G029 do CNAB"
+ release_form = fields.Selection(
+ selection=FORMA_LANCAMENTO, string='Forma Lançamento', help='Campo G029 do CNAB'
)
- codigo_convenio = fields.Char(
+ code_convetion = fields.Char(
size=20,
- string="Código do Convênio no Banco",
- help="Campo G007 do CNAB",
- default="0001222130126",
+ string='Código do Convênio no Banco',
+ help='Campo G007 do CNAB',
+ default='0001222130126',
)
- codigo_finalidade_doc = fields.Selection(
+ doc_finality_code = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string="Complemento do Tipo de Serviço",
- help="Campo P005 do CNAB",
+ string='Complemento do Tipo de Serviço',
+ help='Campo P005 do CNAB',
)
- codigo_finalidade_ted = fields.Selection(
+ ted_finality_code = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string="Código Finalidade da TED",
- help="Campo P011 do CNAB",
+ string='Código Finalidade da TED',
+ help='Campo P011 do CNAB',
)
- codigo_finalidade_complementar = fields.Char(
- size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
+ complementary_finality_code = fields.Char(
+ size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
)
- aviso_ao_favorecido = fields.Selection(
+ favored_warning = fields.Selection(
selection=AVISO_FAVORECIDO,
- string="Aviso ao Favorecido",
- help="Campo P006 do CNAB",
+ string='Aviso ao Favorecido',
+ help='Campo P006 do CNAB',
default=0,
)
# A exportação CNAB não se encaixa somente nos parâmetros de
# débito e crédito.
- boleto_carteira = fields.Char("Carteira", size=3)
- boleto_modalidade = fields.Char("Modalidade", size=2)
- boleto_convenio = fields.Char("Codigo convênio", size=10)
- boleto_variacao = fields.Char("Variação", size=2)
- boleto_cnab_code = fields.Char("Código Cnab", size=20)
- boleto_aceite = fields.Selection(
- [("S", "Sim"), ("N", "Não")], string="Aceite", default="N"
- )
- boleto_type = fields.Selection(selection=[], string="Boleto")
- boleto_especie = fields.Selection(
+ boleto_wallet = fields.Char('Carteira', size=3)
+ boleto_modality = fields.Char('Modalidade', size=2)
+ boleto_convetion = fields.Char('Codigo convênio', size=10)
+ boleto_variation = fields.Char('Variação', size=2)
+ boleto_cnab_code = fields.Char('Código Cnab', size=20)
+ boleto_accept = fields.Selection(
+ [('S', 'Sim'), ('N', 'Não')], string='Aceite', default='N'
+ )
+ boleto_type = fields.Selection(selection=[], string='Boleto')
+ boleto_species = fields.Selection(
selection=BOLETO_ESPECIE,
- string="Espécie do Título",
- default="01",
+ string='Espécie do Título',
+ default='01',
)
- boleto_cod_protesto = fields.Char(
+ boleto_protest_code = fields.Char(
# Na configuração ou implementação de outros campos é
# melhor seguir a idéia abaixo pois os campos não são usados com
# frequencia e incluir um campo do tipo Char permitindo que seja
@@ -85,39 +85,39 @@ class PaymentMode(models.Model):
# ('7', u'Negativar (Dias Corridos)'),
# ('8', u'Não Negativar')
# ]
- string="Código de Protesto",
+ string='Código de Protesto',
help='Código adotado pela FEBRABAN para identificar o tipo'
' de prazo a ser considerado para o protesto.',
- default="0",
+ default='0',
)
- boleto_dias_protesto = fields.Char(
- string="Número de Dias para Protesto", size=2,
+ boleto_days_protest = fields.Char(
+ string='Número de Dias para Protesto', size=2,
help='Número de dias decorrentes após a data de vencimento'
' para inicialização do processo de cobrança via protesto.'
)
- gera_nosso_numero = fields.Boolean(
- string="Gerar nosso número?",
- help="Dependendo da carteira, banco, etc. "
- "O nosso número pode ser gerado pelo banco.",
+ generate_own_number = fields.Boolean(
+ string='Gerar nosso número?',
+ help='Dependendo da carteira, banco, etc. '
+ 'O nosso número pode ser gerado pelo banco.',
default=True,
)
default_account_id = fields.Many2one(
- comodel_name="account.account",
- string="Conta Padrão",
- help="Conta padrão para recebimentos",
+ comodel_name='account.account',
+ string='Conta Padrão',
+ help='Conta padrão para recebimentos',
)
default_tax_account_id = fields.Many2one(
- comodel_name="account.account",
- string="Conta Padrão para Taxas Bancárias",
- help="Conta padrão para recebimentos de Taxas Bancárias",
+ comodel_name='account.account',
+ string='Conta Padrão para Taxas Bancárias',
+ help='Conta padrão para recebimentos de Taxas Bancárias',
)
product_tax_id = fields.Many2one(
- comodel_name="product.product", string="Taxa Adicional"
+ comodel_name='product.product', string='Taxa Adicional'
)
tax_account_id = fields.Many2one(
- comodel_name="account.account",
- string="Conta Padrão",
- help="Conta padrão para Taxa",
+ comodel_name='account.account',
+ string='Conta Padrão',
+ help='Conta padrão para Taxa',
)
cnab_sequence_id = fields.Many2one(
comodel_name='ir.sequence',
@@ -128,7 +128,7 @@ class PaymentMode(models.Model):
' utilizado para compor o nosso número,'
' usado pelos bancos Sicred/Unicred e Sicoob'
)
- boleto_posto = fields.Char(
+ boleto_post = fields.Char(
string='Posto da Cooperativa de Crédito', size=2,
help='Código do Posto da Cooperativa de Crédito,'
' usado pelos bancos Sicred/Unicred e Sicoob.'
@@ -141,70 +141,50 @@ class PaymentMode(models.Model):
' Nosso Número como Sequencial Único por Carteira no cadastro da'
' empresa ',
)
-
- boleto_cod_mora = fields.Char(
+ boleto_interest_code = fields.Char(
size=1,
string='Código da Mora',
help='Código adotado pela FEBRABAN para identificação'
' do tipo de pagamento de mora de juros.',
)
- boleto_perc_mora = fields.Float(
+ boleto_interest_perc = fields.Float(
string='Percentual de Juros de Mora',
digits=dp.get_precision('Account')
)
- instrucao_boleto_perc_mora = fields.Text(
- 'Instrução Juros Mora',
- help='Juros de mora - é o percentual ao'
- ' mês sobre o valor principal.',
- default='Após vencimento cobrar juros de mora de'
- )
- boleto_perc_multa = fields.Float(
- string='Percentual de Multa',
- digits=dp.get_precision('Account')
- )
- boleto_cod_multa = fields.Char(
+ boleto_fee_code = fields.Char(
size=1,
string='Código da Multa',
help='Código adotado pela FEBRABAN para identificação'
' do tipo de pagamento de multa.',
)
- instrucao_boleto_perc_multa = fields.Text(
- 'Instrução Multa por Atraso',
- help=' Multa por atraso - é o valor percentual acrescido uma única'
- ' vez sobre o valor do principal. ',
- default='Após vencimento cobrar multa de'
+ boleto_fee_perc = fields.Float(
+ string='Percentual de Multa',
+ digits=dp.get_precision('Account')
)
- @api.onchange("product_tax_id")
+ @api.onchange('product_tax_id')
def _onchange_product_tax_id(self):
if not self.product_tax_id:
self.tax_account_id = False
- @api.constrains("product_override")
+ @api.constrains('product_override')
def _constrains_product_override(self):
if self.product_override and self.product_override_value <= 0:
- raise ValidationError("O valor da Taxa deve ser maior que 0 (zero)")
+ raise ValidationError('O valor da Taxa deve ser maior que 0 (zero)')
@api.constrains(
- "boleto_type",
- "boleto_carteira",
- "boleto_modalidade",
- "boleto_convenio",
- "boleto_variacao",
- "boleto_aceite",
+ 'boleto_type',
+ 'boleto_wallet',
+ 'boleto_modality',
+ 'boleto_convetion',
+ 'boleto_variation',
+ 'boleto_accept',
)
def boleto_restriction(self):
- if self.boleto_type == "6" and not self.boleto_carteira:
- raise ValidationError("Carteira no banco Itaú é obrigatória")
+ if self.boleto_type == '6' and not self.boleto_wallet:
+ raise ValidationError('Carteira no banco Itaú é obrigatória')
@api.multi
def get_own_number_sequence(self):
self.ensure_one()
return self.own_number_sequence.next_by_id()
-
- @api.constrains('boleto_perc_mora')
- def _check_boleto_perc_mora(self):
- for record in self:
- if record.boleto_perc_mora > 2 or record.boleto_perc_mora < 0:
- raise ValidationError(
- _('O percentual de Mora deve ser um valor entre 0 a 2.'))
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
index 66749a9af30f..1835aa847804 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment_order.py
@@ -16,66 +16,66 @@
class PaymentOrder(models.Model):
- _inherit = "account.payment.order"
+ _inherit = 'account.payment.order'
- active = fields.Boolean(string="Ativo", default=True)
+ active = fields.Boolean(string='Ativo', default=True)
- file_number = fields.Integer(string="Número sequencial do arquivo")
+ file_number = fields.Integer(string='Número sequencial do arquivo')
- cnab_file = fields.Binary(string="CNAB File", readonly=True)
+ cnab_file = fields.Binary(string='CNAB File', readonly=True)
- cnab_filename = fields.Char("CNAB Filename")
+ cnab_filename = fields.Char('CNAB Filename')
- tipo_servico = fields.Selection(
+ service_type = fields.Selection(
selection=TIPO_SERVICO,
- string="Tipo de Serviço",
- help="Campo G025 do CNAB",
- default="30",
+ string='Tipo de Serviço',
+ help='Campo G025 do CNAB',
+ default='30',
)
- forma_lancamento = fields.Selection(
- selection=FORMA_LANCAMENTO, string="Forma Lançamento", help="Campo G029 do CNAB"
+ release_form = fields.Selection(
+ selection=FORMA_LANCAMENTO, string='Forma Lançamento', help='Campo G029 do CNAB'
)
- codigo_convenio = fields.Char(
+ code_convetion = fields.Char(
size=20,
- string="Código do Convênio no Banco",
- help="Campo G007 do CNAB",
- default="0001222130126",
+ string='Código do Convênio no Banco',
+ help='Campo G007 do CNAB',
+ default='0001222130126',
)
- indicativo_forma_pagamento = fields.Selection(
+ indicative_form_payment = fields.Selection(
selection=INDICATIVO_FORMA_PAGAMENTO,
- string="Indicativo de Forma de Pagamento",
- help="Campo P014 do CNAB",
- default="01",
+ string='Indicativo de Forma de Pagamento',
+ help='Campo P014 do CNAB',
+ default='01',
)
- tipo_movimento = fields.Selection(
+ movement_type = fields.Selection(
selection=TIPO_MOVIMENTO,
- string="Tipo de Movimento",
- help="Campo G060 do CNAB",
- default="0",
+ string='Tipo de Movimento',
+ help='Campo G060 do CNAB',
+ default='0',
)
- codigo_instrucao_movimento = fields.Selection(
+ movement_instruction_code = fields.Selection(
selection=CODIGO_INSTRUCAO_MOVIMENTO,
- string="Código da Instrução para Movimento",
- help="Campo G061 do CNAB",
- default="00",
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ default='00',
)
bank_line_error_ids = fields.One2many(
- comodel_name="bank.payment.line",
- inverse_name="order_id",
- string="Bank Payment Error Lines",
+ comodel_name='bank.payment.line',
+ inverse_name='order_id',
+ string='Bank Payment Error Lines',
readonly=True,
- domain=[("is_erro_exportacao", "=", True)],
+ domain=[('is_export_error', '=', True)],
)
def _confirm_debit_orders_api(self):
- """
+ '''
Method create to confirm all bank_api exclusive account.payment.order
:return:
- """
- _logger.info("_confirm_debit_orders_api()")
+ '''
+ _logger.info('_confirm_debit_orders_api()')
order_ids = self.search(
- [("active", "=", False), ("state", "=", "draft"), ("name", "ilike", "api")]
+ [('active', '=', False), ('state', '=', 'draft'), ('name', 'ilike', 'api')]
)
for order_id in order_ids:
@@ -88,11 +88,11 @@ def _confirm_debit_orders_api(self):
@api.model
def _prepare_bank_payment_line(self, paylines):
result = super()._prepare_bank_payment_line(paylines)
- result["nosso_numero"] = paylines[0].nosso_numero
- result["numero_documento"] = paylines[0].numero_documento
- result["identificacao_titulo_empresa"] =\
- paylines[0].identificacao_titulo_empresa
- result["ultimo_estado_cnab"] = paylines[0].move_line_id.state_cnab
+ result['own_number'] = paylines[0].own_number
+ result['document_number'] = paylines[0].document_number
+ result['company_title_identification'] =\
+ paylines[0].company_title_identification
+ result['last_state_cnab'] = paylines[0].move_line_id.state_cnab
return result
@api.multi
@@ -101,8 +101,8 @@ def open2generated(self):
if self.bank_line_error_ids:
self.message_post(
- "Erro ao gerar o arquivo," ' verifique a aba "Linhas com problemas"'
+ 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
)
return False
- self.message_post("Arquivo gerado com sucesso")
+ self.message_post('Arquivo gerado com sucesso')
return result
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
index 8ff54e4079fe..d64b291895f7 100644
--- a/l10n_br_account_payment_cobranca/models/bank_payment_line.py
+++ b/l10n_br_account_payment_cobranca/models/bank_payment_line.py
@@ -9,102 +9,99 @@
class BankPaymentLine(models.Model):
- _inherit = "bank.payment.line"
+ _inherit = 'bank.payment.line'
@api.model
def default_get(self, fields_list):
res = super(BankPaymentLine, self).default_get(fields_list)
mode = (
- self.env["account.payment.order"]
- .browse(self.env.context.get("order_id"))
+ self.env['account.payment.order']
+ .browse(self.env.context.get('order_id'))
.payment_mode_id
)
if mode.codigo_finalidade_doc:
- res.update({"codigo_finalidade_doc": mode.codigo_finalidade_doc})
+ res.update({'doc_finality_code': mode.doc_finality_code})
if mode.codigo_finalidade_ted:
- res.update({"codigo_finalidade_ted": mode.codigo_finalidade_ted})
+ res.update({'ted_finality_code': mode.ted_finality_code})
if mode.codigo_finalidade_complementar:
res.update(
- {"codigo_finalidade_complementar": mode.codigo_finalidade_complementar}
+ {'complementary_finality_code': mode.complementary_finality_code}
)
if mode.aviso_ao_favorecido:
- res.update({"aviso_ao_favorecido": mode.aviso_ao_favorecido})
+ res.update({'favored_warning': mode.favored_warning})
return res
- codigo_finalidade_doc = fields.Selection(
+ doc_finality_code = fields.Selection(
selection=COMPLEMENTO_TIPO_SERVICO,
- string="Complemento do Tipo de Serviço",
- help="Campo P005 do CNAB",
+ string='Complemento do Tipo de Serviço',
+ help='Campo P005 do CNAB',
)
- codigo_finalidade_ted = fields.Selection(
+ ted_finality_code = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
- string="Código Finalidade da TED",
- help="Campo P011 do CNAB",
+ string='Código Finalidade da TED',
+ help='Campo P011 do CNAB',
)
- codigo_finalidade_complementar = fields.Char(
- size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
+ complementary_finality_code = fields.Char(
+ size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
)
- aviso_ao_favorecido = fields.Selection(
+ favored_warning = fields.Selection(
selection=AVISO_FAVORECIDO,
- string="Aviso ao Favorecido",
- help="Campo P006 do CNAB",
- default="0",
+ string='Aviso ao Favorecido',
+ help='Campo P006 do CNAB',
+ default='0',
)
- abatimento = fields.Float(
+ rebate_value = fields.Float(
digits=(13, 2),
- string="Valor do Abatimento",
- help="Campo G045 do CNAB",
+ string='Valor do Abatimento',
+ help='Campo G045 do CNAB',
default=0.00,
)
- desconto = fields.Float(
+ discount_value = fields.Float(
digits=(13, 2),
- string="Valor do Desconto",
- help="Campo G046 do CNAB",
+ string='Valor do Desconto',
+ help='Campo G046 do CNAB',
default=0.00,
)
- mora = fields.Float(
- digits=(13, 2), string="Valor da Mora", help="Campo G047 do CNAB", default=0.00
+ interest_value = fields.Float(
+ digits=(13, 2), string='Valor da Mora', help='Campo G047 do CNAB', default=0.00
)
- multa = fields.Float(
- digits=(13, 2), string="Valor da Multa", help="Campo G048 do CNAB", default=0.00
+ fee_value = fields.Float(
+ digits=(13, 2), string='Valor da Multa', help='Campo G048 do CNAB', default=0.00
)
- evento_id = fields.One2many(
- string="Eventos CNAB",
- comodel_name="l10n_br.cnab.evento",
- inverse_name="bank_payment_line_id",
+ event_id = fields.One2many(
+ string='Eventos CNAB',
+ comodel_name='l10n_br.cnab.evento',
+ inverse_name='bank_payment_line_id',
readonly=True,
)
- codigo_finalidade_complementar = fields.Char(
- size=2, string="Código de finalidade complementar", help="Campo P013 do CNAB"
- )
- nosso_numero = fields.Char(string="Nosso Numero")
- numero_documento = fields.Char(string="Número documento")
- identificacao_titulo_empresa = fields.Char(string="Identificação Titulo Empresa")
- is_erro_exportacao = fields.Boolean(string="Contem erro de exportação")
- mensagem_erro_exportacao = fields.Char(string="Mensagem de erro")
- ultimo_estado_cnab = fields.Selection(
+ own_number = fields.Char(string='Nosso Numero')
+ document_number = fields.Char(string='Número documento')
+ company_title_identification = fields.Char(string='Identificação Titulo Empresa')
+ is_export_error = fields.Boolean(string='Contem erro de exportação')
+ export_error_message = fields.Char(string='Mensagem de erro')
+ last_state_cnab = fields.Selection(
selection=ESTADOS_CNAB,
- string="Último Estado do CNAB",
- help="Último Estado do CNAB antes da confirmação de "
- "pagamento nas Ordens de Pagamento",
+ string='Último Estado do CNAB',
+ help='Último Estado do CNAB antes da confirmação de '
+ 'pagamento nas Ordens de Pagamento',
)
@api.multi
def unlink(self):
for record in self:
- if not record.ultimo_estado_cnab:
+ if not record.last_state_cnab:
continue
- move_line_id = self.env["account.move.line"].search(
+ move_line_id = self.env['account.move.line'].search(
[
(
- "identificacao_titulo_empresa",
- "=",
- record.identificacao_titulo_empresa,
+ 'company_title_identification',
+ '=',
+ record.company_title_identification,
)
]
)
- move_line_id.state_cnab = record.ultimo_estado_cnab
+ move_line_id.state_cnab = record.last_state_cnab
return super(BankPaymentLine, self).unlink()
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
index 64725d59df88..a9fb389be893 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
@@ -77,22 +77,22 @@ class L10nBrHrCnab(models.Model):
display_name = fields.Char(compute="_compute_display_name", store=True, index=True)
- arquivo_retorno = fields.Binary(string="Arquivo Retorno")
+ return_file = fields.Binary(string="Arquivo Retorno")
filename = fields.Char(string="Filename")
bank_account_id = fields.Many2one(
string="Conta cedente", comodel_name="res.partner.bank"
)
- data = fields.Date(
+ cnab_date = fields.Date(
string="Data CNAB", required=True, default=datetime.now().date())
- data_arquivo = fields.Date(string="Data Criação no Banco")
- sequencial_arquivo = fields.Char(string="Sequencial do Arquivo")
- motivo_erro = fields.Char(string="Motivo do Erro")
- lote_id = fields.One2many(
+ date_file = fields.Date(string="Data Criação no Banco")
+ sequential_file = fields.Char(string="Sequencial do Arquivo")
+ reason_error = fields.Char(string="Motivo do Erro")
+ lot_id = fields.One2many(
string="Lotes", comodel_name="l10n_br.cnab.lote", inverse_name="cnab_id"
)
name = fields.Char(string="Name")
- num_eventos = fields.Integer(string="Número de Eventos")
- num_lotes = fields.Integer(string="Número de Lotes")
+ number_events = fields.Integer(string="Número de Eventos")
+ number_lots = fields.Integer(string="Número de Lotes")
state = fields.Selection(string="Estágio", selection=STATE_CNAB, default="draft")
@api.one
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
index a3dee1bb67bc..ed7a4dd743ec 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
@@ -12,64 +12,64 @@
class L10nBrCnabEvento(models.Model):
- _name = "l10n_br.cnab.evento"
+ _name = 'l10n_br.cnab.evento'
bank_payment_line_id = fields.Many2one(
- string="Bank Payment Line", comodel_name="bank.payment.line"
+ string='Bank Payment Line', comodel_name='bank.payment.line'
)
- data_real_pagamento = fields.Date(string="Data do Crédito")
- data_ocorrencia = fields.Date(string="Data da Ocorrência")
- data_vencimento = fields.Date(string="Data de Vencimento")
- favorecido_conta_bancaria_id = fields.Many2one(
- string="Conta Bancária", comodel_name="res.partner.bank"
+ real_payment_date = fields.Date(string='Data do Crédito')
+ occurrence_date = fields.Date(string='Data da Ocorrência')
+ due_date = fields.Date(string='Data de Vencimento')
+ favored_bank_account_id = fields.Many2one(
+ string='Conta Bancária', comodel_name='res.partner.bank'
)
- favorecido_id = fields.Many2one(string="Favorecido", comodel_name="res.partner")
- identificacao_titulo_empresa = fields.Char(
- string="Identificação do Título da Empresa", required=False
+ favored_id = fields.Many2one(string='Favorecido', comodel_name='res.partner')
+ company_title_identification = fields.Char(
+ string='Identificação do Título da Empresa', required=False
)
- invoice_id = fields.Many2one(comodel_name="account.invoice", string="Fatura")
- juros_mora_multa = fields.Float(string="Juros de Mora/Multa")
+ invoice_id = fields.Many2one(comodel_name='account.invoice', string='Fatura')
+ interest_fee_value = fields.Float(string='Juros de Mora/Multa')
lote_id = fields.Many2one(
- string="Lote", comodel_name="l10n_br.cnab.lote", ondelete="cascade"
+ string='Lote', comodel_name='l10n_br.cnab.lote', ondelete='cascade'
)
- nosso_numero = fields.Char(string="Nosso Número")
- ocorrencias = fields.Char(string="Ocorrências")
- outros_creditos = fields.Float(string="Outros Créditos")
- partner_id = fields.Many2one(comodel_name="res.partner", string="Associado")
- segmento = fields.Char(string="Segmento")
- seu_numero = fields.Char(string="Seu Número")
+ own_number = fields.Char(string='Nosso Número')
+ occurrences = fields.Char(string='Ocorrências')
+ other_credits = fields.Float(string='Outros Créditos')
+ partner_id = fields.Many2one(comodel_name='res.partner', string='Associado')
+ segment = fields.Char(string='Segmento')
+ your_number = fields.Char(string='Seu Número')
state = fields.Selection(
- string="State", related="lote_id.state", selection=STATE_CNAB, default="draft"
+ string='State', related='lote_id.state', selection=STATE_CNAB, default='draft'
)
- str_motiv_a = fields.Char("Motivo da ocorrência 01")
- str_motiv_b = fields.Char("Motivo de ocorrência 02")
- str_motiv_c = fields.Char("Motivo de ocorrência 03")
- str_motiv_d = fields.Char("Motivo de ocorrência 04")
- str_motiv_e = fields.Char("Motivo de ocorrência 05")
- tipo_moeda = fields.Char(string="Tipo de Moeda")
- tarifa_cobranca = fields.Float(string="Tarifa")
- valor = fields.Float(string="Valor da Linha")
- valor_abatimento = fields.Float(
- string="Valor do Abatimento",
- help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ str_motiv_a = fields.Char('Motivo da ocorrência 01')
+ str_motiv_b = fields.Char('Motivo de ocorrência 02')
+ str_motiv_c = fields.Char('Motivo de ocorrência 03')
+ str_motiv_d = fields.Char('Motivo de ocorrência 04')
+ str_motiv_e = fields.Char('Motivo de ocorrência 05')
+ currency_type = fields.Char(string='Tipo de Moeda')
+ tariff_charge = fields.Float(string='Tarifa')
+ title_value = fields.Float(string='Valor da Linha')
+ rebate_value = fields.Float(
+ string='Valor do Abatimento',
+ help='''Se o desconto ou abatimento é concedido na entrada do boleto
estes campos são retornados zerados(apesar de corretamente registrados
no Itaú). Se concedidos após a entrada, retornam com os valores
do desconto ou abatimento.
Na liquidação, desconto e abatimento retornam somados no campo
desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
estes valores poderão retornar separados, conforme mostra o
- indicador 36.4 do Item 5 - Condições Personalizadas.""",
+ indicador 36.4 do Item 5 - Condições Personalizadas.''',
)
- valor_desconto = fields.Float(
- string="Valor do Desconto",
- help="""Se o desconto ou abatimento é concedido na entrada do boleto
+ discount_value = fields.Float(
+ string='Valor do Desconto',
+ help='''Se o desconto ou abatimento é concedido na entrada do boleto
estes campos são retornados zerados(apesar de corretamente registrados
no Itaú). Se concedidos após a entrada, retornam com os valores
do desconto ou abatimento.
Na liquidação, desconto e abatimento retornam somados no campo
desconto; opcionalmente, mediante cadastro prévio em nosso sistema,
estes valores poderão retornar separados, conforme mostra o
- indicador 36.4 do Item 5 - Condições Personalizadas.""",
+ indicador 36.4 do Item 5 - Condições Personalizadas.''',
)
- valor_iof = fields.Float(string="Valor do IOF")
- valor_pagamento = fields.Float(string="Valor do Pagamento")
+ iof_value = fields.Float(string='Valor do IOF')
+ payment_value = fields.Float(string='Valor do Pagamento')
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
index 94cd90ee98a9..8eb6b8ddfa76 100644
--- a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
@@ -13,24 +13,24 @@
class L10nBrCnabLote(models.Model):
- _name = "l10n_br.cnab.lote"
+ _name = 'l10n_br.cnab.lote'
account_bank_id = fields.Many2one(
- string="Conta Bancária", comodel_name="res.partner.bank"
+ string='Conta Bancária', comodel_name='res.partner.bank'
)
cnab_id = fields.Many2one(
- string="CNAB", comodel_name="l10n_br.cnab", ondelete="cascade"
+ string='CNAB', comodel_name='l10n_br.cnab', ondelete='cascade'
)
- empresa_inscricao_numero = fields.Char(string="Número de Inscrição")
- empresa_inscricao_tipo = fields.Char(string="Tipo de Inscrição")
- evento_id = fields.One2many(
- string="Eventos", comodel_name="l10n_br.cnab.evento", inverse_name="lote_id"
+ company_registration_number = fields.Char(string='Número de Inscrição')
+ company_registration_type = fields.Char(string='Tipo de Inscrição')
+ event_id = fields.One2many(
+ string='Eventos', comodel_name='l10n_br.cnab.evento', inverse_name='lote_id'
)
- mensagem = fields.Char(string="Mensagem")
- qtd_registros = fields.Integer(string="Quantidade de Registros")
- servico_operacao = fields.Char(string="Tipo de Operação")
+ message = fields.Char(string='Mensagem')
+ register_qty = fields.Integer(string='Quantidade de Registros')
+ operation_service = fields.Char(string='Tipo de Operação')
state = fields.Selection(
- string="State", related="cnab_id.state", selection=STATE_CNAB, default="draft"
+ string='State', related='cnab_id.state', selection=STATE_CNAB, default='draft'
)
- tipo_servico = fields.Char(string="Tipo do Serviço")
- total_valores = fields.Float(string="Valor Total")
+ service_type = fields.Char(string='Tipo do Serviço')
+ total_value = fields.Float(string='Valor Total')
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_cobranca/views/account_move_line.xml
index c746abd5f2ca..67d347142ddb 100644
--- a/l10n_br_account_payment_cobranca/views/account_move_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_move_line.xml
@@ -7,12 +7,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
index b2a95628e762..b59d32d0384e 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
@@ -8,8 +8,8 @@
-
-
+
+
@@ -36,13 +36,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
index b3684e4f870d..e1a781d0e26c 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
@@ -17,46 +17,40 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order.xml b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
index 5e4d7318ad49..67bceeab7f54 100644
--- a/l10n_br_account_payment_cobranca/views/account_payment_order.xml
+++ b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
@@ -22,14 +22,14 @@
-
-
-
+
+
+
-
-
-
+
+
+
{'default_payment_type': payment_type, 'tree_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_tree', 'form_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_form'}
@@ -42,10 +42,10 @@
-
-
-
-
+
+
+
+
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
index 9f1a612dace7..b41f1311fa88 100644
--- a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_cobranca/views/bank_payment_line.xml
@@ -8,24 +8,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
index 7797910a5931..20c3b81a500e 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
@@ -11,12 +11,12 @@
-
+ />-->
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
index 854b8a6f157d..8b316073d10b 100644
--- a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
@@ -1,8 +1,8 @@
-
+
cnab.retorno.tree
@@ -10,13 +10,13 @@
-
-
-
-
+
+
+
+
-
-
+
+
@@ -28,14 +28,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -49,18 +49,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -78,25 +78,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -121,26 +121,26 @@
-
-
-
-
-
-
-
-
@@ -170,35 +170,35 @@
-
-
-
-
-
-
-
-
@@ -243,9 +243,9 @@
tree,form
-
+ action="action_cnab_retorno"/>-->
From 521387e325a96143e19f022b5990cf3fab271360 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:02:11 -0300
Subject: [PATCH 238/612] Moved files from l10n_br_account_payment_cobranca to
l10n_br_account_payment_order
---
.../constantes.py => l10n_br_account_payment_order/constants.py | 0
.../models/account_invoice.py | 0
.../models/bank_payment_line.py | 0
.../models/l10n_br_cnab.py | 0
.../models/l10n_br_cnab_evento.py | 0
.../models/l10n_br_cnab_lote.py | 0
.../models/res_company.py | 0
.../views/account_invoice.xml | 0
.../views/bank_payment_line.xml | 0
.../views/l10n_br_cnab_evento_views.xml | 0
.../views/l10n_br_cnab_retorno_view.xml | 0
.../views/l10n_br_cobranca_cnab.xml | 0
.../views/l10n_br_cobranca_cnab_lines.xml | 0
.../views/l10n_br_payment_cnab.xml | 0
.../views/res_company.xml | 0
15 files changed, 0 insertions(+), 0 deletions(-)
rename l10n_br_account_payment_cobranca/constantes.py => l10n_br_account_payment_order/constants.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/account_invoice.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/bank_payment_line.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/l10n_br_cnab.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/l10n_br_cnab_evento.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/l10n_br_cnab_lote.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/res_company.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/account_invoice.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/bank_payment_line.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/l10n_br_cnab_evento_views.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/l10n_br_cnab_retorno_view.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/l10n_br_cobranca_cnab.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/l10n_br_cobranca_cnab_lines.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/l10n_br_payment_cnab.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/res_company.xml (100%)
diff --git a/l10n_br_account_payment_cobranca/constantes.py b/l10n_br_account_payment_order/constants.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/constantes.py
rename to l10n_br_account_payment_order/constants.py
diff --git a/l10n_br_account_payment_cobranca/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/account_invoice.py
rename to l10n_br_account_payment_order/models/account_invoice.py
diff --git a/l10n_br_account_payment_cobranca/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/bank_payment_line.py
rename to l10n_br_account_payment_order/models/bank_payment_line.py
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/l10n_br_cnab.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab.py
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/l10n_br_cnab_evento.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
diff --git a/l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/l10n_br_cnab_lote.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
diff --git a/l10n_br_account_payment_cobranca/models/res_company.py b/l10n_br_account_payment_order/models/res_company.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/res_company.py
rename to l10n_br_account_payment_order/models/res_company.py
diff --git a/l10n_br_account_payment_cobranca/views/account_invoice.xml b/l10n_br_account_payment_order/views/account_invoice.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/account_invoice.xml
rename to l10n_br_account_payment_order/views/account_invoice.xml
diff --git a/l10n_br_account_payment_cobranca/views/bank_payment_line.xml b/l10n_br_account_payment_order/views/bank_payment_line.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/bank_payment_line.xml
rename to l10n_br_account_payment_order/views/bank_payment_line.xml
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml b/l10n_br_account_payment_order/views/l10n_br_cnab_evento_views.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/l10n_br_cnab_evento_views.xml
rename to l10n_br_account_payment_order/views/l10n_br_cnab_evento_views.xml
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/l10n_br_cnab_retorno_view.xml
rename to l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab.xml
rename to l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/l10n_br_cobranca_cnab_lines.xml
rename to l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml
diff --git a/l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml b/l10n_br_account_payment_order/views/l10n_br_payment_cnab.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/l10n_br_payment_cnab.xml
rename to l10n_br_account_payment_order/views/l10n_br_payment_cnab.xml
diff --git a/l10n_br_account_payment_cobranca/views/res_company.xml b/l10n_br_account_payment_order/views/res_company.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/res_company.xml
rename to l10n_br_account_payment_order/views/res_company.xml
From 6608c0a0c35721ca31305bfd9156af354b4960a0 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:06:15 -0300
Subject: [PATCH 239/612] Moved res.partner.bank field to
l10n_br_account_payment_order
---
.../models/res_partner_bank.py | 19 -------------------
.../models/res_partner_bank.py | 14 ++++++++++----
2 files changed, 10 insertions(+), 23 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/res_partner_bank.py
diff --git a/l10n_br_account_payment_cobranca/models/res_partner_bank.py b/l10n_br_account_payment_cobranca/models/res_partner_bank.py
deleted file mode 100644
index 27e581cd9baf..000000000000
--- a/l10n_br_account_payment_cobranca/models/res_partner_bank.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2012 KMEE - Fernando Marcato Rodrigues
-# Copyright 2017 KMEE - Hendrix Costa
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-from odoo import fields, models
-
-
-class ResPartnerBank(models.Model):
- """ Adiciona campos necessários para o cadastramentos de contas
- bancárias no Brasil."""
-
- _inherit = "res.partner.bank"
-
- codigo_da_empresa = fields.Integer(
- "Código da empresa",
- size=20,
- help="Será informado pelo banco depois do cadastro do beneficiário "
- "na agência",
- )
diff --git a/l10n_br_account_payment_order/models/res_partner_bank.py b/l10n_br_account_payment_order/models/res_partner_bank.py
index 407ff2d832f1..0d4c1f802d46 100644
--- a/l10n_br_account_payment_order/models/res_partner_bank.py
+++ b/l10n_br_account_payment_order/models/res_partner_bank.py
@@ -1,12 +1,18 @@
-# @ 2018 Akretion - www.akretion.com.br -
+# Copyright 2012 KMEE - Fernando Marcato Rodrigues
+# Copyright 2017 KMEE - Hendrix Costa
+# @ 2018 Akretion - www.akretion.com.br
# Magno Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import _, api, models
-from odoo.exceptions import Warning as UserError
class ResPartnerBank(models.Model):
- _inherit = "res.partner.bank"
+ _inherit = 'res.partner.bank'
- # TODO REMOVE THIS FILE
+ codigo_da_empresa = fields.Integer(
+ string='Código da empresa',
+ size=20,
+ help="Será informado pelo banco depois do cadastro do beneficiário "
+ "na agência",
+ )
From d9c8662a55e676da5a39313e65c4080799e9cd9d Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:13:56 -0300
Subject: [PATCH 240/612] Move account move line fields to
l10n_br_account_payment_order
---
.../models/account_move_line.py | 95 ---------------
.../models/account_move.py | 4 +-
.../models/account_move_line.py | 109 ++++++++++++++++++
.../views/account_move_line.xml | 0
4 files changed, 111 insertions(+), 97 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/account_move_line.py
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/account_move.py (91%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/views/account_move_line.xml (100%)
diff --git a/l10n_br_account_payment_cobranca/models/account_move_line.py b/l10n_br_account_payment_cobranca/models/account_move_line.py
deleted file mode 100644
index 48be89ddbfe2..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_move_line.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import logging
-
-from odoo import api, fields, models
-
-from ..constantes import ESTADOS_CNAB, SITUACAO_PAGAMENTO
-
-_logger = logging.getLogger(__name__)
-
-
-class AccountMoveLine(models.Model):
- _inherit = 'account.move.line'
-
- cnab_state = fields.Selection(ESTADOS_CNAB, 'Estados CNAB', default='draft')
- date_payment_created = fields.Date('Data da criação do pagamento', readonly=True)
- own_number = fields.Char(string='Nosso Numero')
- document_number = fields.Char(string='Número documento')
- company_title_identification = fields.Char(string='Identificação Titulo Empresa')
- payment_situation = fields.Selection(
- selection=SITUACAO_PAGAMENTO, string='Situação do Pagamento', default='inicial'
- )
- instructions = fields.Text(string='Instruções de cobrança', readonly=True)
-
- residual = fields.Monetary(
- string='Valor Residual', default=0.0, currency_field='company_currency_id'
- )
-
- @api.multi
- def _prepare_payment_line_vals(self, payment_order):
- vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
- vals['own_number'] = self.own_number
- vals['document_number'] = self.document_number
- vals['company_title_identification'] = self.company_title_identification
-
- if self.invoice_id.state == 'paid':
- vals['amount_currency'] = self.credit or self.debit
-
- return vals
-
- @api.multi
- def create_payment_line_from_move_line(self, payment_order):
- '''
- Altera estado do cnab para adicionado a ordem
- :param payment_order:
- :return:
- '''
- cnab_state = 'added'
- if self.invoice_id.state == 'paid':
- cnab_state = 'added_paid'
-
- self.cnab_state = cnab_state
-
- return super(AccountMoveLine, self).create_payment_line_from_move_line(
- payment_order
- )
-
- @api.multi
- def generate_boleto(self, validate=True):
- raise NotImplementedError
-
- @api.multi
- def _update_check(self):
-
- if self._context.get('reprocessing'):
- return True
-
- return super(AccountMoveLine, self)._update_check()
-
- @api.multi
- def write(self, vals):
- '''
- Sobrescrita do método Write. Não deve ser possível voltar o state_cnab
- ou a situacao_pagamento para um estado anterior
- :param vals:
- :return:
- '''
- for record in self:
- state_cnab = vals.get('state_cnab')
-
- if state_cnab and (
- record.state_cnab == 'done'
- or (
- record.state_cnab in ['accepted', 'accepted_hml']
- and state_cnab not in ['accepted', 'accepted_hml', 'done']
- )
- ):
- vals.pop('state_cnab', False)
-
- if record.situacao_pagamento not in ['inicial', 'aberta']:
- vals.pop('situacao_pagamento', False)
-
- return super(AccountMoveLine, self).write(vals)
diff --git a/l10n_br_account_payment_cobranca/models/account_move.py b/l10n_br_account_payment_order/models/account_move.py
similarity index 91%
rename from l10n_br_account_payment_cobranca/models/account_move.py
rename to l10n_br_account_payment_order/models/account_move.py
index bdf4cb727dad..94c6c0ed0cf8 100644
--- a/l10n_br_account_payment_cobranca/models/account_move.py
+++ b/l10n_br_account_payment_order/models/account_move.py
@@ -6,7 +6,7 @@
class AccountMove(models.Model):
- _inherit = "account.move"
+ _inherit = 'account.move'
@api.multi
def unlink(self):
@@ -24,4 +24,4 @@ def unlink(self):
)
)
payment_line_ids.unlink()
- return super(AccountMove, self).unlink()
+ return super().unlink()
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 0f6e70edb39c..a18d4588e16f 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -4,6 +4,8 @@
from odoo import api, fields, models
+from ..constants import ESTADOS_CNAB, SITUACAO_PAGAMENTO
+
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@@ -12,6 +14,113 @@ class AccountMoveLine(models.Model):
string='Data Prevista',
)
+ cnab_state = fields.Selection(
+ selection=ESTADOS_CNAB,
+ string='Estados CNAB',
+ default='draft',
+ )
+
+ date_payment_created = fields.Date(
+ string='Data da criação do pagamento',
+ readonly=True,
+ )
+
+ own_number = fields.Char(
+ string='Nosso Numero',
+ )
+
+ document_number = fields.Char(
+ string='Número documento',
+ )
+
+ company_title_identification = fields.Char(
+ string='Identificação Titulo Empresa',
+ )
+
+ payment_situation = fields.Selection(
+ selection=SITUACAO_PAGAMENTO,
+ string='Situação do Pagamento',
+ default='inicial',
+ )
+
+ instructions = fields.Text(
+ string='Instruções de cobrança',
+ readonly=True,
+ )
+
+ residual = fields.Monetary(
+ string='Valor Residual',
+ default=0.0,
+ currency_field='company_currency_id',
+ )
+
+ @api.multi
+ def _prepare_payment_line_vals(self, payment_order):
+ vals = super()._prepare_payment_line_vals(payment_order)
+ vals['own_number'] = self.own_number
+ vals['document_number'] = self.document_number
+ vals['company_title_identification'] = self.company_title_identification
+
+ if self.invoice_id.state == 'paid':
+ vals['amount_currency'] = self.credit or self.debit
+
+ return vals
+
+ @api.multi
+ def create_payment_line_from_move_line(self, payment_order):
+ '''
+ Altera estado do cnab para adicionado a ordem
+ :param payment_order:
+ :return:
+ '''
+ cnab_state = 'added'
+ if self.invoice_id.state == 'paid':
+ cnab_state = 'added_paid'
+
+ self.cnab_state = cnab_state
+
+ return super().create_payment_line_from_move_line(
+ payment_order
+ )
+
+ @api.multi
+ def generate_boleto(self, validate=True):
+ raise NotImplementedError
+
+ @api.multi
+ def _update_check(self):
+
+ if self._context.get('reprocessing'):
+ return True
+
+ return super(AccountMoveLine, self)._update_check()
+
+ @api.multi
+ def write(self, values):
+ '''
+ Sobrescrita do método Write. Não deve ser possível voltar o state_cnab
+ ou a situacao_pagamento para um estado anterior
+ :param values:
+ :return:
+ '''
+ for record in self:
+ state_cnab = values.get('state_cnab')
+
+ if state_cnab and (
+ record.state_cnab == 'done'
+ or (
+ record.state_cnab in ['accepted', 'accepted_hml']
+ and state_cnab not in ['accepted', 'accepted_hml', 'done']
+ )
+ ):
+ values.pop('state_cnab', False)
+
+ if record.situacao_pagamento not in ['inicial', 'aberta']:
+ values.pop('situacao_pagamento', False)
+
+ return super().write(values)
+
+
# journal_entry_ref = fields.Char(
# compute="_compute_journal_entry_ref", string="Journal Entry Ref", store=True
# )
diff --git a/l10n_br_account_payment_cobranca/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/views/account_move_line.xml
rename to l10n_br_account_payment_order/views/account_move_line.xml
From e7d5bd30217833dcecb3d9c0538f910ea5b310b8 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:44:08 -0300
Subject: [PATCH 241/612] Move account payment mode fields to
l10n_br_account_payment_order
---
.../models/account_payment_mode.py | 190 -------------
.../views/account_payment_mode.xml | 65 -----
.../models/account_payment_mode.py | 263 +++++++++++++++++-
.../views/account_payment_mode.xml | 50 ++++
4 files changed, 312 insertions(+), 256 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/account_payment_mode.py
delete mode 100644 l10n_br_account_payment_cobranca/views/account_payment_mode.xml
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_mode.py b/l10n_br_account_payment_cobranca/models/account_payment_mode.py
deleted file mode 100644
index da69217e2529..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_payment_mode.py
+++ /dev/null
@@ -1,190 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import api, fields, models
-from odoo.addons import decimal_precision as dp
-from odoo.exceptions import ValidationError
-
-from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
- COMPLEMENTO_TIPO_SERVICO, FORMA_LANCAMENTO,
- TIPO_SERVICO, BOLETO_ESPECIE)
-
-
-class AccountPaymentMode(models.Model):
- _inherit = 'account.payment.mode'
-
- condition_issuing_paper = fields.Selection(
- [('1', 'Banco emite e Processa'), ('2', 'Cliente emite e banco processa')],
- 'Condição Emissão de Papeleta',
- default='1',
- )
- cnab_percent_interest = fields.Float(
- string='Percentual de Juros', digits=dp.get_precision('Account')
- )
- communication_2 = fields.Char('Comunicação para o sacador avalista')
- service_type = fields.Selection(
- selection=TIPO_SERVICO, string='Tipo de Serviço', help='Campo G025 do CNAB'
- )
- release_form = fields.Selection(
- selection=FORMA_LANCAMENTO, string='Forma Lançamento', help='Campo G029 do CNAB'
- )
- code_convetion = fields.Char(
- size=20,
- string='Código do Convênio no Banco',
- help='Campo G007 do CNAB',
- default='0001222130126',
- )
- doc_finality_code = fields.Selection(
- selection=COMPLEMENTO_TIPO_SERVICO,
- string='Complemento do Tipo de Serviço',
- help='Campo P005 do CNAB',
- )
- ted_finality_code = fields.Selection(
- selection=CODIGO_FINALIDADE_TED,
- string='Código Finalidade da TED',
- help='Campo P011 do CNAB',
- )
- complementary_finality_code = fields.Char(
- size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
- )
- favored_warning = fields.Selection(
- selection=AVISO_FAVORECIDO,
- string='Aviso ao Favorecido',
- help='Campo P006 do CNAB',
- default=0,
- )
- # A exportação CNAB não se encaixa somente nos parâmetros de
- # débito e crédito.
- boleto_wallet = fields.Char('Carteira', size=3)
- boleto_modality = fields.Char('Modalidade', size=2)
- boleto_convetion = fields.Char('Codigo convênio', size=10)
- boleto_variation = fields.Char('Variação', size=2)
- boleto_cnab_code = fields.Char('Código Cnab', size=20)
- boleto_accept = fields.Selection(
- [('S', 'Sim'), ('N', 'Não')], string='Aceite', default='N'
- )
- boleto_type = fields.Selection(selection=[], string='Boleto')
- boleto_species = fields.Selection(
- selection=BOLETO_ESPECIE,
- string='Espécie do Título',
- default='01',
- )
- boleto_protest_code = fields.Char(
- # Na configuração ou implementação de outros campos é
- # melhor seguir a idéia abaixo pois os campos não são usados com
- # frequencia e incluir um campo do tipo Char permitindo que seja
- # informado o valor de acordo com a configuração do Boleto ao
- # invês de diversos campos do Tipo Select para cada Banco parece
- # ser melhor.
- # [ Deixado manualmente, pois cada banco parece ter sua tabela.
- # ('0', u'Sem instrução'),
- # ('1', u'Protestar (Dias Corridos)'),
- # ('2', u'Protestar (Dias Úteis)'),
- # ('3', u'Não protestar'),
- # ('7', u'Negativar (Dias Corridos)'),
- # ('8', u'Não Negativar')
- # ]
- string='Código de Protesto',
- help='Código adotado pela FEBRABAN para identificar o tipo'
- ' de prazo a ser considerado para o protesto.',
- default='0',
- )
- boleto_days_protest = fields.Char(
- string='Número de Dias para Protesto', size=2,
- help='Número de dias decorrentes após a data de vencimento'
- ' para inicialização do processo de cobrança via protesto.'
- )
- generate_own_number = fields.Boolean(
- string='Gerar nosso número?',
- help='Dependendo da carteira, banco, etc. '
- 'O nosso número pode ser gerado pelo banco.',
- default=True,
- )
- default_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão',
- help='Conta padrão para recebimentos',
- )
- default_tax_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão para Taxas Bancárias',
- help='Conta padrão para recebimentos de Taxas Bancárias',
- )
- product_tax_id = fields.Many2one(
- comodel_name='product.product', string='Taxa Adicional'
- )
- tax_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão',
- help='Conta padrão para Taxa',
- )
- cnab_sequence_id = fields.Many2one(
- comodel_name='ir.sequence',
- string=u'Sequencia do CNAB')
- boleto_byte_idt = fields.Char(
- string='Byte IDT', size=1,
- help='Byte de identificação do cedente do bloqueto'
- ' utilizado para compor o nosso número,'
- ' usado pelos bancos Sicred/Unicred e Sicoob'
- )
- boleto_post = fields.Char(
- string='Posto da Cooperativa de Crédito', size=2,
- help='Código do Posto da Cooperativa de Crédito,'
- ' usado pelos bancos Sicred/Unicred e Sicoob.'
- )
- # Field used to make invisible banks specifics fields
- bank_code_bc = fields.Char(related='fixed_journal_id.bank_id.code_bc')
- own_number_sequence = fields.Many2one(
- comodel_name='ir.sequence', string='Sequência do Nosso Número',
- help='Para usar essa Sequencia é preciso definir o campo Tipo do'
- ' Nosso Número como Sequencial Único por Carteira no cadastro da'
- ' empresa ',
- )
- boleto_interest_code = fields.Char(
- size=1,
- string='Código da Mora',
- help='Código adotado pela FEBRABAN para identificação'
- ' do tipo de pagamento de mora de juros.',
- )
- boleto_interest_perc = fields.Float(
- string='Percentual de Juros de Mora',
- digits=dp.get_precision('Account')
- )
- boleto_fee_code = fields.Char(
- size=1,
- string='Código da Multa',
- help='Código adotado pela FEBRABAN para identificação'
- ' do tipo de pagamento de multa.',
- )
- boleto_fee_perc = fields.Float(
- string='Percentual de Multa',
- digits=dp.get_precision('Account')
- )
-
- @api.onchange('product_tax_id')
- def _onchange_product_tax_id(self):
- if not self.product_tax_id:
- self.tax_account_id = False
-
- @api.constrains('product_override')
- def _constrains_product_override(self):
- if self.product_override and self.product_override_value <= 0:
- raise ValidationError('O valor da Taxa deve ser maior que 0 (zero)')
-
- @api.constrains(
- 'boleto_type',
- 'boleto_wallet',
- 'boleto_modality',
- 'boleto_convetion',
- 'boleto_variation',
- 'boleto_accept',
- )
- def boleto_restriction(self):
- if self.boleto_type == '6' and not self.boleto_wallet:
- raise ValidationError('Carteira no banco Itaú é obrigatória')
-
- @api.multi
- def get_own_number_sequence(self):
- self.ensure_one()
- return self.own_number_sequence.next_by_id()
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml b/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
deleted file mode 100644
index e1a781d0e26c..000000000000
--- a/l10n_br_account_payment_cobranca/views/account_payment_mode.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
- cnab.payment.mode.l10n_br_payment.form.inherit
-
- account.payment.mode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 650a2b1bf172..162e2f098b86 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -3,7 +3,18 @@
# @author Renato Lima - renato.lima@akretion.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import _, fields, models
+from odoo import _, api, fields, models
+from odoo.addons import decimal_precision as dp
+from odoo.exceptions import ValidationError
+
+from ..constants import (
+ AVISO_FAVORECIDO,
+ CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO,
+ FORMA_LANCAMENTO,
+ TIPO_SERVICO,
+ BOLETO_ESPECIE,
+)
class AccountPaymentMode(models.Model):
@@ -22,9 +33,259 @@ class AccountPaymentMode(models.Model):
string='Gerar relatorio na conclusão da fatura?'
)
+ condition_issuing_paper = fields.Selection(
+ selection=[
+ ('1', 'Banco emite e Processa'),
+ ('2', 'Cliente emite e banco processa')],
+ string='Condição Emissão de Papeleta',
+ default='1',
+ )
+
+ cnab_percent_interest = fields.Float(
+ string='Percentual de Juros',
+ digits=dp.get_precision('Account'),
+ )
+
+ communication_2 = fields.Char(
+ string='Comunicação para o sacador avalista',
+ )
+
+ service_type = fields.Selection(
+ selection=TIPO_SERVICO,
+ string='Tipo de Serviço',
+ help='Campo G025 do CNAB',
+ )
+
+ release_form = fields.Selection(
+ selection=FORMA_LANCAMENTO,
+ string='Forma Lançamento',
+ help='Campo G029 do CNAB',
+ )
+
+ code_convetion = fields.Char(
+ string='Código do Convênio no Banco',
+ size=20,
+ help='Campo G007 do CNAB',
+ default='0001222130126',
+ )
+
+ doc_finality_code = fields.Selection(
+ selection=COMPLEMENTO_TIPO_SERVICO,
+ string='Complemento do Tipo de Serviço',
+ help='Campo P005 do CNAB',
+ )
+
+ ted_finality_code = fields.Selection(
+ selection=CODIGO_FINALIDADE_TED,
+ string='Código Finalidade da TED',
+ help='Campo P011 do CNAB',
+ )
+
+ complementary_finality_code = fields.Char(
+ string='Código de finalidade complementar',
+ size=2,
+ help='Campo P013 do CNAB',
+ )
+
+ favored_warning = fields.Selection(
+ selection=AVISO_FAVORECIDO,
+ string='Aviso ao Favorecido',
+ help='Campo P006 do CNAB',
+ default=0,
+ )
+
+ # A exportação CNAB não se encaixa somente nos parâmetros de
+ # débito e crédito.
+ boleto_wallet = fields.Char(
+ string='Carteira',
+ size=3,
+ )
+
+ boleto_modality = fields.Char(
+ string='Modalidade',
+ size=2,
+ )
+
+ boleto_convetion = fields.Char(
+ string='Codigo convênio',
+ size=10,
+ )
+
+ boleto_variation = fields.Char(
+ string='Variação',
+ size=2,
+ )
+
+ boleto_cnab_code = fields.Char(
+ string='Código Cnab',
+ size=20,
+ )
+
+ boleto_accept = fields.Selection(
+ selection=[
+ ('S', 'Sim'),
+ ('N', 'Não')],
+ string='Aceite',
+ default='N',
+ )
+
+ boleto_type = fields.Selection(
+ selection=[],
+ string='Boleto',
+ )
+
+ boleto_species = fields.Selection(
+ selection=BOLETO_ESPECIE,
+ string='Espécie do Título',
+ default='01',
+ )
+
+ # Na configuração ou implementação de outros campos é
+ # melhor seguir a idéia abaixo pois os campos não são usados com
+ # frequencia e incluir um campo do tipo Char permitindo que seja
+ # informado o valor de acordo com a configuração do Boleto ao
+ # invês de diversos campos do Tipo Select para cada Banco parece
+ # ser melhor.
+ # [ Deixado manualmente, pois cada banco parece ter sua tabela.
+ # ('0', u'Sem instrução'),
+ # ('1', u'Protestar (Dias Corridos)'),
+ # ('2', u'Protestar (Dias Úteis)'),
+ # ('3', u'Não protestar'),
+ # ('7', u'Negativar (Dias Corridos)'),
+ # ('8', u'Não Negativar')
+ # ]
+ boleto_protest_code = fields.Char(
+ string='Código de Protesto',
+ default='0',
+ help='Código adotado pela FEBRABAN para identificar o tipo '
+ 'de prazo a ser considerado para o protesto.',
+ )
+
+ boleto_days_protest = fields.Char(
+ string='Número de Dias para Protesto',
+ size=2,
+ help='Número de dias decorrentes após a data de vencimento '
+ 'para inicialização do processo de cobrança via protesto.'
+ )
+
+ generate_own_number = fields.Boolean(
+ string='Gerar nosso número?',
+ default=True,
+ help='Dependendo da carteira, banco, etc. '
+ 'O nosso número pode ser gerado pelo banco.',
+ )
+
+ default_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Padrão',
+ help='Conta padrão para recebimentos',
+ )
+
+ default_tax_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Padrão para Taxas Bancárias',
+ help='Conta padrão para recebimentos de Taxas Bancárias',
+ )
+
+ product_tax_id = fields.Many2one(
+ comodel_name='product.product',
+ string='Taxa Adicional',
+ )
+
+ tax_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Padrão',
+ help='Conta padrão para Taxa',
+ )
+
+ cnab_sequence_id = fields.Many2one(
+ comodel_name='ir.sequence',
+ string='Sequencia do CNAB',
+ )
+
+ boleto_byte_idt = fields.Char(
+ string='Byte IDT',
+ size=1,
+ help='Byte de identificação do cedente do bloqueto '
+ 'utilizado para compor o nosso número, '
+ 'usado pelos bancos Sicred/Unicred e Sicoob.',
+ )
+
+ boleto_post = fields.Char(
+ string='Posto da Cooperativa de Crédito',
+ size=2,
+ help='Código do Posto da Cooperativa de Crédito,'
+ ' usado pelos bancos Sicred/Unicred e Sicoob.',
+ )
+
+ # Field used to make invisible banks specifics fields
+ bank_code_bc = fields.Char(
+ related='fixed_journal_id.bank_id.code_bc',
+ )
+
+ own_number_sequence = fields.Many2one(
+ comodel_name='ir.sequence',
+ string='Sequência do Nosso Número',
+ help='Para usar essa Sequencia é preciso definir o campo Tipo do '
+ 'Nosso Número como Sequencial Único por Carteira no cadastro da '
+ 'empresa',
+ )
+
+ boleto_interest_code = fields.Char(
+ string='Código da Mora',
+ size=1,
+ help='Código adotado pela FEBRABAN para identificação '
+ 'do tipo de pagamento de mora de juros.',
+ )
+
+ boleto_interest_perc = fields.Float(
+ string='Percentual de Juros de Mora',
+ digits=dp.get_precision('Account'),
+ )
+
+ boleto_fee_code = fields.Char(
+ string='Código da Multa',
+ size=1,
+ help='Código adotado pela FEBRABAN para identificação '
+ 'do tipo de pagamento de multa.',
+ )
+
+ boleto_fee_perc = fields.Float(
+ string='Percentual de Multa',
+ digits=dp.get_precision('Account'),
+ )
+
_sql_constraints = [(
"internal_sequence_id_unique",
"unique(internal_sequence_id)",
_("Sequência já usada! Crie uma sequência unica para cada modo"),
)
]
+
+
+ @api.constrains('product_override')
+ def _constrains_product_override(self):
+ if self.product_override and self.product_override_value <= 0:
+ raise ValidationError('O valor da Taxa deve ser maior que 0 (zero)')
+
+ @api.constrains(
+ 'boleto_type',
+ 'boleto_wallet',
+ 'boleto_modality',
+ 'boleto_convetion',
+ 'boleto_variation',
+ 'boleto_accept',
+ )
+ def boleto_restriction(self):
+ if self.boleto_type == '6' and not self.boleto_wallet:
+ raise ValidationError('Carteira no banco Itaú é obrigatória')
+
+ @api.onchange('product_tax_id')
+ def _onchange_product_tax_id(self):
+ if not self.product_tax_id:
+ self.tax_account_id = False
+
+ @api.multi
+ def get_own_number_sequence(self):
+ self.ensure_one()
+ return self.own_number_sequence.next_by_id()
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 08008b341d54..cbe94f1d5c27 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -21,6 +21,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From d071c9426497fb6496645573d726f23c42058c61 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:47:12 -0300
Subject: [PATCH 242/612] Move account payment order and line fields to
l10n_br_account_payment_order
---
.../models/account_payment_line.py | 73 -----------
.../models/account_payment_order.py | 108 ----------------
.../views/account_payment_order.xml | 57 --------
.../models/account_payment_line.py | 113 ++++++++++++++--
.../models/account_payment_order.py | 122 +++++++++++++++++-
.../views/account_move_line.xml | 7 +-
.../views/account_payment_order.xml | 41 ++++++
7 files changed, 267 insertions(+), 254 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/account_payment_line.py
delete mode 100644 l10n_br_account_payment_cobranca/models/account_payment_order.py
delete mode 100644 l10n_br_account_payment_cobranca/views/account_payment_order.xml
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_line.py b/l10n_br_account_payment_cobranca/models/account_payment_line.py
deleted file mode 100644
index 17b2fe0ffdf0..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_payment_line.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import api, fields, models
-
-from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
- COMPLEMENTO_TIPO_SERVICO)
-
-
-class AccountPaymentLine(models.Model):
- _inherit = 'account.payment.line'
-
- @api.model
- def default_get(self, fields_list):
- res = super().default_get(fields_list)
- mode = (
- self.env['account.payment.order']
- .browse(self.env.context.get('order_id'))
- .payment_mode_id
- )
- if mode.doc_finality_code:
- res.update({'doc_finality_code': mode.doc_finality_code})
- if mode.ted_finality_code:
- res.update({'ted_finality_code': mode.ted_finality_code})
- if mode.complementary_finality_code:
- res.update(
- {'complementary_finality_code': mode.complementary_finality_code}
- )
- if mode.favored_warning:
- res.update({'favored_warning': mode.favored_warning})
- return res
-
- own_number = fields.Char(string='Nosso Numero')
- document_number = fields.Char(string='Número documento')
- company_title_identification = fields.Char(string='Identificação Titulo Empresa')
- doc_finality_code = fields.Selection(
- selection=COMPLEMENTO_TIPO_SERVICO,
- string='Complemento do Tipo de Serviço',
- help='Campo P005 do CNAB',
- )
- ted_finality_code = fields.Selection(
- selection=CODIGO_FINALIDADE_TED,
- string='Código Finalidade da TED',
- help='Campo P011 do CNAB',
- )
- complementary_finality_code = fields.Char(
- size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
- )
- favored_warning = fields.Selection(
- selection=AVISO_FAVORECIDO,
- string='Aviso ao Favorecido',
- help='Campo P006 do CNAB',
- default='0',
- )
- rebate_value = fields.Float(
- digits=(13, 2),
- string='Valor do Abatimento',
- help='Campo G045 do CNAB',
- default=0.00,
- )
- discount_value = fields.Float(
- digits=(13, 2),
- string='Valor do Desconto',
- help='Campo G046 do CNAB',
- default=0.00,
- )
- interest_value = fields.Float(
- digits=(13, 2), string='Valor da Mora', help='Campo G047 do CNAB', default=0.00
- )
- fee_value = fields.Float(
- digits=(13, 2), string='Valor da Multa', help='Campo G048 do CNAB', default=0.00
- )
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_order.py b/l10n_br_account_payment_cobranca/models/account_payment_order.py
deleted file mode 100644
index 1835aa847804..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_payment_order.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Fernando Marcato
-# @author Hendrix Costa
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-
-import logging
-
-from odoo import api, fields, models
-
-from ..constantes import (CODIGO_INSTRUCAO_MOVIMENTO, FORMA_LANCAMENTO,
- INDICATIVO_FORMA_PAGAMENTO, TIPO_MOVIMENTO,
- TIPO_SERVICO)
-
-_logger = logging.getLogger(__name__)
-
-
-class PaymentOrder(models.Model):
- _inherit = 'account.payment.order'
-
- active = fields.Boolean(string='Ativo', default=True)
-
- file_number = fields.Integer(string='Número sequencial do arquivo')
-
- cnab_file = fields.Binary(string='CNAB File', readonly=True)
-
- cnab_filename = fields.Char('CNAB Filename')
-
- service_type = fields.Selection(
- selection=TIPO_SERVICO,
- string='Tipo de Serviço',
- help='Campo G025 do CNAB',
- default='30',
- )
- release_form = fields.Selection(
- selection=FORMA_LANCAMENTO, string='Forma Lançamento', help='Campo G029 do CNAB'
- )
- code_convetion = fields.Char(
- size=20,
- string='Código do Convênio no Banco',
- help='Campo G007 do CNAB',
- default='0001222130126',
- )
- indicative_form_payment = fields.Selection(
- selection=INDICATIVO_FORMA_PAGAMENTO,
- string='Indicativo de Forma de Pagamento',
- help='Campo P014 do CNAB',
- default='01',
- )
- movement_type = fields.Selection(
- selection=TIPO_MOVIMENTO,
- string='Tipo de Movimento',
- help='Campo G060 do CNAB',
- default='0',
- )
- movement_instruction_code = fields.Selection(
- selection=CODIGO_INSTRUCAO_MOVIMENTO,
- string='Código da Instrução para Movimento',
- help='Campo G061 do CNAB',
- default='00',
- )
- bank_line_error_ids = fields.One2many(
- comodel_name='bank.payment.line',
- inverse_name='order_id',
- string='Bank Payment Error Lines',
- readonly=True,
- domain=[('is_export_error', '=', True)],
- )
-
- def _confirm_debit_orders_api(self):
- '''
- Method create to confirm all bank_api exclusive account.payment.order
- :return:
- '''
- _logger.info('_confirm_debit_orders_api()')
-
- order_ids = self.search(
- [('active', '=', False), ('state', '=', 'draft'), ('name', 'ilike', 'api')]
- )
-
- for order_id in order_ids:
- try:
- order_id.draft2open()
- order_id.active = True
- except Exception as e:
- _logger.warn(str(e))
-
- @api.model
- def _prepare_bank_payment_line(self, paylines):
- result = super()._prepare_bank_payment_line(paylines)
- result['own_number'] = paylines[0].own_number
- result['document_number'] = paylines[0].document_number
- result['company_title_identification'] =\
- paylines[0].company_title_identification
- result['last_state_cnab'] = paylines[0].move_line_id.state_cnab
- return result
-
- @api.multi
- def open2generated(self):
- result = super(PaymentOrder, self).open2generated()
-
- if self.bank_line_error_ids:
- self.message_post(
- 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
- )
- return False
- self.message_post('Arquivo gerado com sucesso')
- return result
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order.xml b/l10n_br_account_payment_cobranca/views/account_payment_order.xml
deleted file mode 100644
index 67bceeab7f54..000000000000
--- a/l10n_br_account_payment_cobranca/views/account_payment_order.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
- payment.order.form.sequence
- account.payment.order
- primary
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {'default_payment_type': payment_type, 'tree_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_tree', 'form_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_form'}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index ed81983fab62..1a3ac4df8699 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -6,19 +6,15 @@
from odoo.addons import decimal_precision as dp
from odoo.tools.float_utils import float_round as round # TODO check round methods in 12.0
+from ..constantes import (
+ AVISO_FAVORECIDO,
+ CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO,
+)
-class PaymentLine(models.Model):
- _inherit = 'account.payment.line'
- @api.multi
- @api.depends('percent_interest', 'amount_currency')
- def _compute_interest(self):
- for record in self:
- precision = record.env[
- 'decimal.precision'].precision_get('Account')
- record.amount_interest = round(
- record.amount_currency * (
- record.percent_interest / 100), precision)
+class AccountPaymentLine(models.Model):
+ _inherit = 'account.payment.line'
linha_digitavel = fields.Char(
string='Linha Digitável',
@@ -34,3 +30,98 @@ def _compute_interest(self):
compute='_compute_interest',
digits=dp.get_precision('Account'),
)
+
+ own_number = fields.Char(
+ string='Nosso Numero',
+ )
+
+ document_number = fields.Char(
+ string='Número documento',
+ )
+
+ company_title_identification = fields.Char(
+ string='Identificação Titulo Empresa',
+ )
+
+ doc_finality_code = fields.Selection(
+ selection=COMPLEMENTO_TIPO_SERVICO,
+ string='Complemento do Tipo de Serviço',
+ help='Campo P005 do CNAB',
+ )
+
+ ted_finality_code = fields.Selection(
+ selection=CODIGO_FINALIDADE_TED,
+ string='Código Finalidade da TED',
+ help='Campo P011 do CNAB',
+ )
+
+ complementary_finality_code = fields.Char(
+ string='Código de finalidade complementar',
+ size=2,
+ help='Campo P013 do CNAB',
+ )
+
+ favored_warning = fields.Selection(
+ selection=AVISO_FAVORECIDO,
+ string='Aviso ao Favorecido',
+ help='Campo P006 do CNAB',
+ default='0',
+ )
+
+ rebate_value = fields.Float(
+ string='Valor do Abatimento',
+ help='Campo G045 do CNAB',
+ default=0.00,
+ digits=(13, 2),
+ )
+
+ discount_value = fields.Float(
+ string='Valor do Desconto',
+ digits=(13, 2),
+ default=0.00,
+ help='Campo G046 do CNAB',
+ )
+
+ interest_value = fields.Float(
+ string='Valor da Mora',
+ digits=(13, 2),
+ default=0.00,
+ help='Campo G047 do CNAB',
+ )
+
+ fee_value = fields.Float(
+ string='Valor da Multa',
+ digits=(13, 2),
+ default=0.00,
+ help='Campo G048 do CNAB',
+ )
+
+ @api.multi
+ @api.depends('percent_interest', 'amount_currency')
+ def _compute_interest(self):
+ for record in self:
+ precision = record.env[
+ 'decimal.precision'].precision_get('Account')
+ record.amount_interest = round(
+ record.amount_currency * (
+ record.percent_interest / 100), precision)
+
+ @api.model
+ def default_get(self, fields_list):
+ res = super().default_get(fields_list)
+ mode = (
+ self.env['account.payment.order']
+ .browse(self.env.context.get('order_id'))
+ .payment_mode_id
+ )
+ if mode.doc_finality_code:
+ res.update({'doc_finality_code': mode.doc_finality_code})
+ if mode.ted_finality_code:
+ res.update({'ted_finality_code': mode.ted_finality_code})
+ if mode.complementary_finality_code:
+ res.update(
+ {'complementary_finality_code': mode.complementary_finality_code}
+ )
+ if mode.favored_warning:
+ res.update({'favored_warning': mode.favored_warning})
+ return res
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 8ca0b0f3581f..8c54dcee76c7 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -1,9 +1,129 @@
+# © 2012 KMEE INFORMATICA LTDA
+# @author Fernando Marcato
+# @author Hendrix Costa
# Copyright (C) 2020 - KMEE ().
# author Daniel Sadamo
+# Copyright (C) 2020 - Akretion ().
+# author Magno Costa
+# author Renato Lima
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import fields, models
+import logging
+
+from odoo import api, fields, models
+
+from ..constantes import (
+ CODIGO_INSTRUCAO_MOVIMENTO,
+ FORMA_LANCAMENTO,
+ INDICATIVO_FORMA_PAGAMENTO,
+ TIPO_MOVIMENTO,
+ TIPO_SERVICO,
+)
+
+_logger = logging.getLogger(__name__)
class AccountPaymentOrder(models.Model):
_inherit = 'account.payment.order'
+
+ file_number = fields.Integer(
+ string='Número sequencial do arquivo',
+ )
+
+ cnab_file = fields.Binary(
+ string='CNAB File',
+ readonly=True,
+ )
+
+ cnab_filename = fields.Char(
+ string='CNAB Filename',
+ )
+
+ service_type = fields.Selection(
+ selection=TIPO_SERVICO,
+ string='Tipo de Serviço',
+ help='Campo G025 do CNAB',
+ default='30',
+ )
+
+ release_form = fields.Selection(
+ selection=FORMA_LANCAMENTO,
+ string='Forma Lançamento',
+ help='Campo G029 do CNAB',
+ )
+
+ code_convetion = fields.Char(
+ string='Código do Convênio no Banco',
+ size=20,
+ help='Campo G007 do CNAB',
+ default='0001222130126',
+ )
+
+ indicative_form_payment = fields.Selection(
+ selection=INDICATIVO_FORMA_PAGAMENTO,
+ string='Indicativo de Forma de Pagamento',
+ help='Campo P014 do CNAB',
+ default='01',
+ )
+
+ movement_type = fields.Selection(
+ selection=TIPO_MOVIMENTO,
+ string='Tipo de Movimento',
+ help='Campo G060 do CNAB',
+ default='0',
+ )
+
+ movement_instruction_code = fields.Selection(
+ selection=CODIGO_INSTRUCAO_MOVIMENTO,
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ default='00',
+ )
+
+ bank_line_error_ids = fields.One2many(
+ comodel_name='bank.payment.line',
+ inverse_name='order_id',
+ string='Bank Payment Error Lines',
+ readonly=True,
+ domain=[('is_export_error', '=', True)],
+ )
+
+ def _confirm_debit_orders_api(self):
+ '''
+ Method create to confirm all bank_api exclusive account.payment.order
+ :return:
+ '''
+ _logger.info('_confirm_debit_orders_api()')
+
+ order_ids = self.search(
+ [('active', '=', False), ('state', '=', 'draft'), ('name', 'ilike', 'api')]
+ )
+
+ for order_id in order_ids:
+ try:
+ order_id.draft2open()
+ order_id.active = True
+ except Exception as e:
+ _logger.warn(str(e))
+
+ @api.model
+ def _prepare_bank_payment_line(self, paylines):
+ result = super()._prepare_bank_payment_line(paylines)
+ result['own_number'] = paylines[0].own_number
+ result['document_number'] = paylines[0].document_number
+ result['company_title_identification'] =\
+ paylines[0].company_title_identification
+ result['last_state_cnab'] = paylines[0].move_line_id.state_cnab
+ return result
+
+ @api.multi
+ def open2generated(self):
+ result = super().open2generated()
+
+ if self.bank_line_error_ids:
+ self.message_post(
+ 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
+ )
+ return False
+ self.message_post('Arquivo gerado com sucesso')
+ return result
diff --git a/l10n_br_account_payment_order/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
index 67d347142ddb..a08ef740b048 100644
--- a/l10n_br_account_payment_order/views/account_move_line.xml
+++ b/l10n_br_account_payment_order/views/account_move_line.xml
@@ -1,5 +1,6 @@
+
cnab.account.move.line.form.inherit
account.move.line
@@ -20,13 +21,11 @@
-
+
Payments
account.move.line
partner_id
-
+
diff --git a/l10n_br_account_payment_order/views/account_payment_order.xml b/l10n_br_account_payment_order/views/account_payment_order.xml
index 53e2132fd987..323677a7cb35 100644
--- a/l10n_br_account_payment_order/views/account_payment_order.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order.xml
@@ -14,6 +14,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ {'default_payment_type': payment_type, 'tree_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_tree', 'form_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_form'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 41ccee05a23a812574c64f18a873bb03cfe80391 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:54:55 -0300
Subject: [PATCH 243/612] Remove fields from account payment term
---
.../models/account_payment_term.py | 59 -------------------
.../views/account_payment_term_view.xml | 24 --------
2 files changed, 83 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/models/account_payment_term.py
delete mode 100644 l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
diff --git a/l10n_br_account_payment_cobranca/models/account_payment_term.py b/l10n_br_account_payment_cobranca/models/account_payment_term.py
deleted file mode 100644
index 868f8ffaf40f..000000000000
--- a/l10n_br_account_payment_cobranca/models/account_payment_term.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# © 2019 KMEE INFORMATICA LTDA
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-import odoo.addons.decimal_precision as dp
-from odoo import api, fields, models
-from odoo.exceptions import Warning as UserError
-
-PAYMENT_SELECTION = [
- ("boleto", "Boleto"),
- ("cartao", "Cartão"),
- ("cheque", "Cheque"),
- ("dinheiro", "Dinheiro"),
- ("outros", "Outros"),
-]
-
-
-class AccountPaymentTerm(models.Model):
- _inherit = "account.payment.term"
-
- payment_mode_selection = fields.Selection(
- selection=PAYMENT_SELECTION, string="Modo de Pagamento"
- )
-
- has_interest = fields.Boolean(string="Juros?", default=False)
-
- interest_rate = fields.Float(
- string="Taxa de Juros(%)", digits=dp.get_precision("Account"), default=0.0
- )
-
- interest_account_id = fields.Many2one(
- comodel_name="account.account", string="Conta", help="Conta padrão para Juros"
- )
-
- discount_perc = fields.Float(
- string=u"Percentual de Desconto até a Data de Vencimento",
- digits=dp.get_precision('Account'))
- instrucao_discount_perc = fields.Text(
- u'Instrução de Desconto antes do Vencimento',
- help=u'Percentual de Desconto concedido antes da Data de Vencimento',
- default=u'CONCEDER ABATIMENTO PERCENTUAL DE '
- )
-
- @api.constrains('discount_perc')
- def _check_discount_perc(self):
- for record in self:
- if record.discount_perc > 100 or record.discount_perc < 0:
- raise UserError(
- _('O percentual deve ser um valor entre 0 a 100.'))
-
-
- @api.onchange("payment_mode_selection")
- def _onchange_payment_mode(self):
- if self.payment_mode_selection not in ["cartao"]:
- self.has_interest = False
-
- @api.onchange("has_interest")
- def _onchange_has_interest(self):
- if not self.has_interest:
- self.interest_rate = 0
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml b/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
deleted file mode 100644
index 572c914b19dd..000000000000
--- a/l10n_br_account_payment_cobranca/views/account_payment_term_view.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
- l10n_br_account_product.payment.term.form
- account.payment.term
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From f80306365314230a196e6f79feb6ec6c07d291d6 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:58:12 -0300
Subject: [PATCH 244/612] call super method
---
.../models/account_payment.py | 2 +-
.../views/account_payment_line.xml | 53 -------------------
.../views/account_payment_line.xml | 11 ++++
3 files changed, 12 insertions(+), 54 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/views/account_payment_line.xml
diff --git a/l10n_br_account_payment_cobranca/models/account_payment.py b/l10n_br_account_payment_cobranca/models/account_payment.py
index f3f36ad4535b..551c9e6f393e 100644
--- a/l10n_br_account_payment_cobranca/models/account_payment.py
+++ b/l10n_br_account_payment_cobranca/models/account_payment.py
@@ -11,6 +11,6 @@ class AccountPayment(models.Model):
@api.multi
def post(self):
- super(AccountPayment, self).post()
+ super().post()
for record in self:
record.invoice_ids.create_account_payment_line_baixa()
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_line.xml b/l10n_br_account_payment_cobranca/views/account_payment_line.xml
deleted file mode 100644
index b59d32d0384e..000000000000
--- a/l10n_br_account_payment_cobranca/views/account_payment_line.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
- account.payment.line.tree
- account.payment.line
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.payment.line.form
-
- primary
- account.payment.line
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/account_payment_line.xml b/l10n_br_account_payment_order/views/account_payment_line.xml
index cb8c9d5e0865..ce90a3edf396 100644
--- a/l10n_br_account_payment_order/views/account_payment_line.xml
+++ b/l10n_br_account_payment_order/views/account_payment_line.xml
@@ -16,6 +16,17 @@
+
+
+
+
+
+
+
+
+
+
+
From 313b2d6cf2bcd721991523ce88494996f8421bb7 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 17:59:55 -0300
Subject: [PATCH 245/612] Move account payment to l10n_br_account_payment_order
---
.../models/account_payment.py | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/models/account_payment.py (100%)
diff --git a/l10n_br_account_payment_cobranca/models/account_payment.py b/l10n_br_account_payment_order/models/account_payment.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/models/account_payment.py
rename to l10n_br_account_payment_order/models/account_payment.py
From 258a3104c7b8f9892b9bfa8910367398a18d5bcb Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:17:45 -0300
Subject: [PATCH 246/612] Move data, demo, report and test files to
l10n_br_account_payment_order
---
.../demo/account_journal_demo.xml | 61 -------
.../data/account_analytic_tag_data.xml | 0
.../data/boleto_data.xml | 0
.../data/cnab_data.xml | 0
.../data/ir_cron.xml | 0
.../data/l10n_br_payment_export_type.xml | 0
.../demo/account_invoice.xml | 0
.../demo/account_journal.xml | 68 ++++++--
.../demo/account_payment_mode_demo.xml | 155 ++++++++++++++++++
.../demo/res_user.xml | 0
.../reports/report_print_button_view.xml | 0
.../tests/__init__.py | 1 +
.../tests/test_payment_order_inbound.py | 0
.../tests/test_remessa.REM | 0
14 files changed, 206 insertions(+), 79 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/data/account_analytic_tag_data.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/data/boleto_data.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/data/cnab_data.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/data/ir_cron.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/data/l10n_br_payment_export_type.xml (100%)
rename l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml => l10n_br_account_payment_order/demo/account_invoice.xml (100%)
rename l10n_br_account_payment_cobranca/demo/res_users_demo.xml => l10n_br_account_payment_order/demo/res_user.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/reports/report_print_button_view.xml (100%)
rename l10n_br_account_payment_cobranca/tests/test_payment_order.py => l10n_br_account_payment_order/tests/test_payment_order_inbound.py (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/tests/test_remessa.REM (100%)
diff --git a/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml b/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
deleted file mode 100644
index 439d503920de..000000000000
--- a/l10n_br_account_payment_cobranca/demo/account_journal_demo.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
- Banco Bradesco
- bank
- BNC2
-
-
-
-
-
-
- Banco Unicred
- bank
- BNC3
-
-
-
-
-
-
- Banco Itau
- bank
- BNC4
-
-
-
-
-
-
- Banco do Brasil
- bank
- BNC5
-
-
-
-
-
-
- Banco Caixa Economica Federal
- bank
- BNC6
-
-
-
-
-
diff --git a/l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml b/l10n_br_account_payment_order/data/account_analytic_tag_data.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/data/account_analytic_tag_data.xml
rename to l10n_br_account_payment_order/data/account_analytic_tag_data.xml
diff --git a/l10n_br_account_payment_cobranca/data/boleto_data.xml b/l10n_br_account_payment_order/data/boleto_data.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/data/boleto_data.xml
rename to l10n_br_account_payment_order/data/boleto_data.xml
diff --git a/l10n_br_account_payment_cobranca/data/cnab_data.xml b/l10n_br_account_payment_order/data/cnab_data.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/data/cnab_data.xml
rename to l10n_br_account_payment_order/data/cnab_data.xml
diff --git a/l10n_br_account_payment_cobranca/data/ir_cron.xml b/l10n_br_account_payment_order/data/ir_cron.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/data/ir_cron.xml
rename to l10n_br_account_payment_order/data/ir_cron.xml
diff --git a/l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml b/l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/data/l10n_br_payment_export_type.xml
rename to l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml
diff --git a/l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/demo/account_invoice_demo.xml
rename to l10n_br_account_payment_order/demo/account_invoice.xml
diff --git a/l10n_br_account_payment_order/demo/account_journal.xml b/l10n_br_account_payment_order/demo/account_journal.xml
index 85df64a250b4..bb1857cbef5f 100644
--- a/l10n_br_account_payment_order/demo/account_journal.xml
+++ b/l10n_br_account_payment_order/demo/account_journal.xml
@@ -1,28 +1,60 @@
-
-
- Diário de Banco(teste l10n_br_account_payment_order)
- TPO
- sale
-
+
+
+
+ Banco Bradesco
+ bank
+ BNC2
+
+
-
-
- Diário de Banco(teste l10n_br_account_payment_order)
- TPO
- sale
-
+
+
+ Banco Unicred
+ bank
+ BNC3
+
+
-
-
- Diário de Banco(teste l10n_br_account_payment_order)
- TPO
- sale
-
+
+
+ Banco Itau
+ bank
+ BNC4
+
+
+
+
+
+
+ Banco do Brasil
+ bank
+ BNC5
+
+
+
+
+
+
+ Banco Caixa Economica Federal
+ bank
+ BNC6
+
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
index 99cebad83765..1ea3f1f3e729 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
@@ -141,5 +141,160 @@
ref="account.account_payment_method_manual_in"/>
+
+
+
+
+ Cobrança Bradesco400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Unicred400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 21
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Unicred240
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Itau240
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Caixa Economica Federal 240
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Itau400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Banco do Brasil 400
+
+ Pagavel em qualquer banco ate o
+ vencimento
+
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
diff --git a/l10n_br_account_payment_cobranca/demo/res_users_demo.xml b/l10n_br_account_payment_order/demo/res_user.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/demo/res_users_demo.xml
rename to l10n_br_account_payment_order/demo/res_user.xml
diff --git a/l10n_br_account_payment_cobranca/reports/report_print_button_view.xml b/l10n_br_account_payment_order/reports/report_print_button_view.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/reports/report_print_button_view.xml
rename to l10n_br_account_payment_order/reports/report_print_button_view.xml
diff --git a/l10n_br_account_payment_order/tests/__init__.py b/l10n_br_account_payment_order/tests/__init__.py
index c1180c63ef51..479d51fe9ee3 100644
--- a/l10n_br_account_payment_order/tests/__init__.py
+++ b/l10n_br_account_payment_order/tests/__init__.py
@@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import test_payment_order
+from . import test_payment_order_inbound
diff --git a/l10n_br_account_payment_cobranca/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/tests/test_payment_order.py
rename to l10n_br_account_payment_order/tests/test_payment_order_inbound.py
diff --git a/l10n_br_account_payment_cobranca/tests/test_remessa.REM b/l10n_br_account_payment_order/tests/test_remessa.REM
similarity index 100%
rename from l10n_br_account_payment_cobranca/tests/test_remessa.REM
rename to l10n_br_account_payment_order/tests/test_remessa.REM
From a776b74f7ceeee69e800f2d4467df31b3145cf2c Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:24:01 -0300
Subject: [PATCH 247/612] Move security and wizard to
l10n_br_account_payment_order
---
.../security/cnab_cobranca_security.xml | 0
.../security/ir.model.access.csv | 0
.../wizard => l10n_br_account_payment_order/wizards}/__init__.py | 0
.../wizards/account_payment_line_create.py | 0
.../wizards/account_payment_line_create_view.xml | 0
5 files changed, 0 insertions(+), 0 deletions(-)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/security/cnab_cobranca_security.xml (100%)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/security/ir.model.access.csv (100%)
rename {l10n_br_account_payment_cobranca/wizard => l10n_br_account_payment_order/wizards}/__init__.py (100%)
rename l10n_br_account_payment_cobranca/wizard/payment_order_create.py => l10n_br_account_payment_order/wizards/account_payment_line_create.py (100%)
rename l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml => l10n_br_account_payment_order/wizards/account_payment_line_create_view.xml (100%)
diff --git a/l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml b/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/security/cnab_cobranca_security.xml
rename to l10n_br_account_payment_order/security/cnab_cobranca_security.xml
diff --git a/l10n_br_account_payment_cobranca/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
similarity index 100%
rename from l10n_br_account_payment_cobranca/security/ir.model.access.csv
rename to l10n_br_account_payment_order/security/ir.model.access.csv
diff --git a/l10n_br_account_payment_cobranca/wizard/__init__.py b/l10n_br_account_payment_order/wizards/__init__.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/wizard/__init__.py
rename to l10n_br_account_payment_order/wizards/__init__.py
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create.py b/l10n_br_account_payment_order/wizards/account_payment_line_create.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/wizard/payment_order_create.py
rename to l10n_br_account_payment_order/wizards/account_payment_line_create.py
diff --git a/l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml b/l10n_br_account_payment_order/wizards/account_payment_line_create_view.xml
similarity index 100%
rename from l10n_br_account_payment_cobranca/wizard/payment_order_create_wizard.xml
rename to l10n_br_account_payment_order/wizards/account_payment_line_create_view.xml
From bdb26f80373962dd56e6ec7d7fbde5b6fb1bef18 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:28:20 -0300
Subject: [PATCH 248/612] move migration script to
l10n_br_account_payment_order
---
.../migrations/12.0.2.0.0/pre-migration.py | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {l10n_br_account_payment_cobranca => l10n_br_account_payment_order}/migrations/12.0.2.0.0/pre-migration.py (100%)
diff --git a/l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
similarity index 100%
rename from l10n_br_account_payment_cobranca/migrations/12.0.2.0.0/pre-migration.py
rename to l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
From 90dd5f346a4122d492de3225eceeb4f961d65ee6 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:29:37 -0300
Subject: [PATCH 249/612] Update manifest files
---
l10n_br_account_payment_order/__init__.py | 1 +
l10n_br_account_payment_order/__manifest__.py | 31 ++++++++++++++++++-
.../models/__init__.py | 9 +++++-
.../wizards/__init__.py | 2 +-
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/__init__.py b/l10n_br_account_payment_order/__init__.py
index 11edac49f06d..c50673613615 100644
--- a/l10n_br_account_payment_order/__init__.py
+++ b/l10n_br_account_payment_order/__init__.py
@@ -3,4 +3,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
+from . import wizards
from . import tests
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index abbbd1e2e0f7..7a33858ec8a2 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -17,17 +17,46 @@
'account_cancel',
],
'data': [
+ # Security]
+ 'security/cnab_cobranca_security.xml',
+ 'security/ir.model.access.csv',
+
+ # Data
+ 'data/cnab_data.xml',
+ 'data/l10n_br_payment_export_type.xml',
+ 'data/boleto_data.xml',
+ 'data/ir_cron.xml',
+ 'data/account_analytic_tag_data.xml',
+
+ # Reports
+ 'reports/report_print_button_view.xml',
+
+ # Views
'views/account_due_list.xml',
'views/account_payment_order.xml',
- # 'views/account_payment_order_menu_views.xml',
'views/account_payment_line.xml',
'views/account_payment_mode.xml',
+ 'views/res_company.xml',
+ 'views/bank_payment_line.xml',
+ 'views/l10n_br_cnab_retorno_view.xml',
+ 'views/l10n_br_cnab_evento_views.xml',
+ 'views/account_invoice.xml',
+ 'views/account_move_line.xml',
+ # 'views/l10n_br_payment_cnab.xml',
+ # 'views/l10n_br_cobranca_cnab.xml',
+ # 'views/l10n_br_cobranca_cnab_lines.xml',
+ # 'views/account_payment_order_menu_views.xml', TODO REMOVE
+
+ # Wizards
+ 'wizard/account_payment_line_create_view.xml',
],
'demo': [
'demo/res_partner_bank.xml',
'demo/account_journal.xml',
'demo/account_payment_mode.xml',
'demo/account_payment_order.xml',
+ 'demo/res_users.xml',
+ 'demo/account_invoice.xml',
],
'installable': True,
}
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 02dd0fe79663..294ec9ed6c56 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -2,9 +2,16 @@
# Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
+from . import res_company
+from . import account_invoice
+from . import account_move
from . import account_move_line
from . import account_payment_mode
from . import account_payment_order
from . import account_payment_line
+from . import account_payment
from . import res_partner_bank
+from . import bank_payment_line
+from . import l10n_br_cnab
+from . import l10n_br_cnab_evento
+from . import l10n_br_cnab_lote
diff --git a/l10n_br_account_payment_order/wizards/__init__.py b/l10n_br_account_payment_order/wizards/__init__.py
index a6fa4dddced1..649d0fc86a5e 100644
--- a/l10n_br_account_payment_order/wizards/__init__.py
+++ b/l10n_br_account_payment_order/wizards/__init__.py
@@ -4,4 +4,4 @@
# @author Fernando Marcato
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from . import payment_order_create
+from . import account_payment_line_create
From c708c240f46cea758a572b14f2a44ee562a85f7c Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:30:48 -0300
Subject: [PATCH 250/612] Remove l10n_br_account_payment_cobranca
---
l10n_br_account_payment_cobranca/README.rst | 73 --------
l10n_br_account_payment_cobranca/__init__.py | 10 --
.../__manifest__.py | 53 ------
.../demo/account_payment_mode_demo.xml | 159 ------------------
.../models/__init__.py | 16 --
.../readme/CONFIGURE.rst | 2 -
.../readme/CONTRIBUTORS.rst | 3 -
.../readme/CREDITS.rst | 3 -
.../readme/DESCRIPTION.rst | 2 -
.../readme/HISTORY.rst | 0
.../readme/INSTALL.rst | 2 -
.../readme/ROADMAP.rst | 0
.../readme/USAGE.rst | 1 -
.../reports/__init__.py | 5 -
.../reports/report.py | 54 ------
.../tests/__init__.py | 5 -
.../account_payment_order_menu_views.xml | 24 ---
17 files changed, 412 deletions(-)
delete mode 100644 l10n_br_account_payment_cobranca/README.rst
delete mode 100644 l10n_br_account_payment_cobranca/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/__manifest__.py
delete mode 100644 l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
delete mode 100644 l10n_br_account_payment_cobranca/models/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/CREDITS.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/HISTORY.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/INSTALL.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/ROADMAP.rst
delete mode 100644 l10n_br_account_payment_cobranca/readme/USAGE.rst
delete mode 100644 l10n_br_account_payment_cobranca/reports/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/reports/report.py
delete mode 100644 l10n_br_account_payment_cobranca/tests/__init__.py
delete mode 100644 l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
diff --git a/l10n_br_account_payment_cobranca/README.rst b/l10n_br_account_payment_cobranca/README.rst
deleted file mode 100644
index 30ecee924f4a..000000000000
--- a/l10n_br_account_payment_cobranca/README.rst
+++ /dev/null
@@ -1,73 +0,0 @@
-.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :alt: License: AGPL-3
-
-
-Account Banking Brazillian - Payments Export Infrastructure
-=============================================================
-
-This module provide an infrastructure to export payment and debit orders in
-Febraban layout.
-
-Installation
-============
-
-This module depends on :
-* account_banking_payment_export
-* account_direct_debit
-
-This modules is part of the odoo-brazil/odoo-brazil-banking suite.
-
-Configuration
-=============
-
- + In a multicompany environment, make sure the sequences payment line and payment order are with the company set to the one you'll use to export the payments and charges.
- If they are not set like this, you'll not be able to add payment lines with regular users.
-
-Usage
-=====
-
-This module provides a menu to configure payment order types : Accounting > Configuration > Miscellaneous > Payment Export Types
-
-For further information, please visit:
-
- * https://www.odoo.com/forum/help-1
-
-Known issues / Roadmap
-======================
-
- * no known issues
-
-Bug Tracker
-===========
-
-Bugs are tracked on `GitHub Issues `_. In case of trouble, please
-check there if your issue has already been reported.
-If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
-`here `_.
-
-
-Credits
-=======
-
-Contributors
-------------
-
-* Luis Felipe Mileo
-* Fernando Marcato Rodrigues
-* Daniel Sadamo
-
-
-Maintainer
-----------
-
-.. image:: https://brasil.odoo.com/logo.png
- :alt: Odoo Brazil
- :target: http://brazil.odoo.com
-
-This module is maintained by the Odoo Brazil.
-
-the Odoo Brazil Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
-
-To contribute to this module, please visit http://brazil.odoo.com
diff --git a/l10n_br_account_payment_cobranca/__init__.py b/l10n_br_account_payment_cobranca/__init__.py
deleted file mode 100644
index 4b1fb7e9bc51..000000000000
--- a/l10n_br_account_payment_cobranca/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from . import wizard
-from . import models
-from . import reports
-from . import tests
diff --git a/l10n_br_account_payment_cobranca/__manifest__.py b/l10n_br_account_payment_cobranca/__manifest__.py
deleted file mode 100644
index d98cc2081d93..000000000000
--- a/l10n_br_account_payment_cobranca/__manifest__.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# @author Daniel Sadamo
-# @author Fernando Marcato
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-
-{
- 'name': 'Account Payment CNAB',
- 'version': '12.0.2.0.0',
- 'category': 'Banking addons',
- 'license': 'AGPL-3',
- 'author': 'KMEE, Odoo Community Association (OCA)',
- 'website': 'http://www.kmee.com.br',
- 'depends': ['l10n_br_account_payment_order'],
- 'data': [
- 'data/l10n_br_payment_export_type.xml',
- 'data/boleto_data.xml',
- 'data/ir_cron.xml',
- 'data/account_analytic_tag_data.xml',
- 'security/cnab_cobranca_security.xml',
- 'views/res_company.xml',
- 'views/account_payment_mode.xml',
- 'views/account_payment_order.xml',
- 'views/account_payment_order_menu_views.xml',
- 'views/account_payment_line.xml',
- 'views/account_payment_term_view.xml',
- 'views/bank_payment_line.xml',
- 'views/account_invoice.xml',
- # 'views/bank_api_operation_views.xml',
- 'views/account_move_line.xml',
- 'views/l10n_br_cnab_retorno_view.xml',
- 'views/l10n_br_cnab_evento_views.xml',
- # 'views/l10n_br_payment_cnab.xml',
- # 'views/l10n_br_cobranca_cnab.xml',
- # 'views/l10n_br_cobranca_cnab_lines.xml',
- 'wizard/payment_order_create_wizard.xml',
- 'reports/report_print_button_view.xml',
- 'security/ir.model.access.csv',
- 'data/cnab_data.xml',
- ],
- 'demo': [
- 'demo/res_users_demo.xml',
- 'demo/account_journal_demo.xml',
- 'demo/account_payment_mode_demo.xml',
- 'demo/account_invoice_demo.xml',
- ],
- 'test': [
- # 'tests/invoice_create.yml'
- ],
- 'installable': True,
- 'auto_install': False,
-}
diff --git a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
deleted file mode 100644
index 1aad702d2ba9..000000000000
--- a/l10n_br_account_payment_cobranca/demo/account_payment_mode_demo.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
-
-
- Cobrança Bradesco400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 03
- DM
- 19
- S
-
-
-
-
-
- Cobrança Unicred400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 21
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Unicred240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Itau240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Caixa Economica Federal 240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Itau400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Banco do Brasil 400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
diff --git a/l10n_br_account_payment_cobranca/models/__init__.py b/l10n_br_account_payment_cobranca/models/__init__.py
deleted file mode 100644
index 8224bbc4da0b..000000000000
--- a/l10n_br_account_payment_cobranca/models/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from . import account_invoice
-from . import account_move
-from . import account_move_line
-from . import account_payment
-from . import account_payment_line
-from . import account_payment_mode
-from . import account_payment_order
-from . import account_payment_term
-from . import bank_payment_line
-from . import l10n_br_cnab
-from . import l10n_br_cnab_evento
-from . import l10n_br_cnab_lote
-from . import res_company
-from . import res_partner_bank
diff --git a/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst b/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
deleted file mode 100644
index e696e12f1b14..000000000000
--- a/l10n_br_account_payment_cobranca/readme/CONFIGURE.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-+ In a multicompany environment, make sure the sequences payment line and payment order are with the company set to the one you'll use to export the payments and charges.
- If they are not set like this, you'll not be able to add payment lines with regular users.
diff --git a/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst b/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
deleted file mode 100644
index 05178524a5a4..000000000000
--- a/l10n_br_account_payment_cobranca/readme/CONTRIBUTORS.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-* Luis Felipe Mileo
-* Fernando Marcato Rodrigues
-* Daniel Sadamo
diff --git a/l10n_br_account_payment_cobranca/readme/CREDITS.rst b/l10n_br_account_payment_cobranca/readme/CREDITS.rst
deleted file mode 100644
index f41358165b2f..000000000000
--- a/l10n_br_account_payment_cobranca/readme/CREDITS.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The development of this module has been financially supported by:
-
-* KMEE INFORMATICA LTDA - www.kmee.com.br
diff --git a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst b/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
deleted file mode 100644
index 20192db33f48..000000000000
--- a/l10n_br_account_payment_cobranca/readme/DESCRIPTION.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-This module provide an infrastructure to export payment and debit orders in
-Febraban layout.
diff --git a/l10n_br_account_payment_cobranca/readme/HISTORY.rst b/l10n_br_account_payment_cobranca/readme/HISTORY.rst
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/l10n_br_account_payment_cobranca/readme/INSTALL.rst b/l10n_br_account_payment_cobranca/readme/INSTALL.rst
deleted file mode 100644
index 1ab71ca70369..000000000000
--- a/l10n_br_account_payment_cobranca/readme/INSTALL.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-This module depends on :
-* l10n_br_account_payment_order
diff --git a/l10n_br_account_payment_cobranca/readme/ROADMAP.rst b/l10n_br_account_payment_cobranca/readme/ROADMAP.rst
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/l10n_br_account_payment_cobranca/readme/USAGE.rst b/l10n_br_account_payment_cobranca/readme/USAGE.rst
deleted file mode 100644
index 96bfc78306b3..000000000000
--- a/l10n_br_account_payment_cobranca/readme/USAGE.rst
+++ /dev/null
@@ -1 +0,0 @@
-This module adds a Payment type "Cobrança" and related configuration fields in Payment Mode
diff --git a/l10n_br_account_payment_cobranca/reports/__init__.py b/l10n_br_account_payment_cobranca/reports/__init__.py
deleted file mode 100644
index 75f46ebc3d19..000000000000
--- a/l10n_br_account_payment_cobranca/reports/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from . import report
diff --git a/l10n_br_account_payment_cobranca/reports/report.py b/l10n_br_account_payment_cobranca/reports/report.py
deleted file mode 100644
index d3e8ad7137aa..000000000000
--- a/l10n_br_account_payment_cobranca/reports/report.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# © 2012 KMEE INFORMATICA LTDA
-# @author Luis Felipe Mileo
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-#
-# from odoo.api import Environment
-# from odoo.report.interface import report_int
-# from odoo.report.render import render
-#
-#
-# class ExternalPdf(render):
-# def __init__(self, pdf):
-# render.__init__(self)
-# self.pdf = pdf
-# self.output_type = "pdf"
-#
-# def _render(self):
-# return self.pdf
-#
-#
-# class ReportCustom(report_int):
-# """
-# Custom report for return boletos
-# """
-#
-# def create(self, cr, uid, ids, datas, context=False):
-# if not context:
-# context = {}
-#
-# env = Environment(cr, uid, {})
-#
-# active_ids = context.get("active_ids")
-# active_model = context.get("active_model")
-#
-# ids_move_lines = []
-#
-# if active_model == "account.invoice":
-# for invoices in env["account.invoice"].browse(active_ids):
-# receivable_ids = invoices.mapped("move_line_receivable_ids")
-# if receivable_ids:
-# ids_move_lines = receivable_ids
-# elif active_model == "account.move.line":
-# ids_move_lines = env["account.move.line"].browse(active_ids)
-#
-# if not ids_move_lines:
-# return False
-#
-# pdf_string = ids_move_lines.generate_boleto()
-# self.obj = ExternalPdf(pdf_string)
-# self.obj.render()
-# return self.obj.pdf, "pdf"
-#
-#
-# ReportCustom("report.l10n_br_account_payment_boleto.report")
diff --git a/l10n_br_account_payment_cobranca/tests/__init__.py b/l10n_br_account_payment_cobranca/tests/__init__.py
deleted file mode 100644
index 7707a125036e..000000000000
--- a/l10n_br_account_payment_cobranca/tests/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# @ 2020 Akretion - www.akretion.com.br -
-# Magno Costa
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-
-from . import test_payment_order
diff --git a/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml b/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
deleted file mode 100644
index ad260acf8e90..000000000000
--- a/l10n_br_account_payment_cobranca/views/account_payment_order_menu_views.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
- Cobrança
- account.payment.order
- tree,form,pivot,graph
-
- [('payment_type', '=', 'inbound'),('operation_type', '=', '3')]
- {'default_payment_type': 'inbound','default_operation_type': '3'}
-
-
-
-
-
-
From 84dcf49009bc91717d0c02e524b664cb69b3c5be Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:50:01 -0300
Subject: [PATCH 251/612] [FIX] imports
---
l10n_br_account_payment_order/models/account_invoice.py | 7 +++++--
l10n_br_account_payment_order/models/account_payment.py | 2 +-
.../models/account_payment_line.py | 2 +-
.../models/account_payment_order.py | 2 +-
.../models/bank_payment_line.py | 9 ++++++---
l10n_br_account_payment_order/models/l10n_br_cnab.py | 2 +-
.../models/l10n_br_cnab_evento.py | 2 +-
.../models/l10n_br_cnab_lote.py | 2 +-
l10n_br_account_payment_order/models/res_company.py | 9 ++++++---
l10n_br_account_payment_order/models/res_partner_bank.py | 2 +-
10 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index fa4d94922f26..099f0069e59b 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -8,8 +8,11 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
-from ..constantes import (SEQUENCIAL_CARTEIRA, SEQUENCIAL_EMPRESA,
- SEQUENCIAL_FATURA)
+from ..constants import (
+ SEQUENCIAL_CARTEIRA,
+ SEQUENCIAL_EMPRESA,
+ SEQUENCIAL_FATURA,
+)
_logger = logging.getLogger(__name__)
diff --git a/l10n_br_account_payment_order/models/account_payment.py b/l10n_br_account_payment_order/models/account_payment.py
index 551c9e6f393e..71b5d7f4c89f 100644
--- a/l10n_br_account_payment_order/models/account_payment.py
+++ b/l10n_br_account_payment_order/models/account_payment.py
@@ -7,7 +7,7 @@
class AccountPayment(models.Model):
- _inherit = "account.payment"
+ _inherit = 'account.payment'
@api.multi
def post(self):
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index 1a3ac4df8699..6530b9564a97 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -6,7 +6,7 @@
from odoo.addons import decimal_precision as dp
from odoo.tools.float_utils import float_round as round # TODO check round methods in 12.0
-from ..constantes import (
+from ..constants import (
AVISO_FAVORECIDO,
CODIGO_FINALIDADE_TED,
COMPLEMENTO_TIPO_SERVICO,
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 8c54dcee76c7..21dff1f8f4bc 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -12,7 +12,7 @@
from odoo import api, fields, models
-from ..constantes import (
+from ..constants import (
CODIGO_INSTRUCAO_MOVIMENTO,
FORMA_LANCAMENTO,
INDICATIVO_FORMA_PAGAMENTO,
diff --git a/l10n_br_account_payment_order/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
index d64b291895f7..38c93745fd01 100644
--- a/l10n_br_account_payment_order/models/bank_payment_line.py
+++ b/l10n_br_account_payment_order/models/bank_payment_line.py
@@ -3,9 +3,12 @@
from odoo import api, fields, models
-from ..constantes import (AVISO_FAVORECIDO, CODIGO_FINALIDADE_TED,
- COMPLEMENTO_TIPO_SERVICO)
-from .account_move_line import ESTADOS_CNAB
+from ..constants import (
+ AVISO_FAVORECIDO,
+ CODIGO_FINALIDADE_TED,
+ COMPLEMENTO_TIPO_SERVICO,
+ ESTADOS_CNAB,
+)
class BankPaymentLine(models.Model):
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
index a9fb389be893..bd390637a6c4 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab.py
@@ -9,7 +9,7 @@
from odoo import api, fields, models
-from ..constantes import (
+from ..constants import (
CODIGO_OCORRENCIAS, STATE_CNAB, RETORNO_400_CONFIRMADA, RETORNO_400_REJEITADA,
RETORNO_400_LIQUIDACAO, RETORNO_400_BAIXA, RETORNOS_TRATADOS,
COD_REGISTROS_REJEITADOS_CNAB400, CODIGO_OCORRENCIAS_CNAB200, STR_EVENTO_FORMAT)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
index ed7a4dd743ec..5837a6edb86d 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
@@ -6,7 +6,7 @@
from odoo import fields, models
-from ..constantes import STATE_CNAB
+from ..constants import STATE_CNAB
_logger = logging.getLogger(__name__)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
index 8eb6b8ddfa76..3966fd4e65b8 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
@@ -6,7 +6,7 @@
from odoo import fields, models
-from ..constantes import STATE_CNAB
+from ..constants import STATE_CNAB
_logger = logging.getLogger(__name__)
diff --git a/l10n_br_account_payment_order/models/res_company.py b/l10n_br_account_payment_order/models/res_company.py
index e6dd7cae73d2..85b284af71b5 100644
--- a/l10n_br_account_payment_order/models/res_company.py
+++ b/l10n_br_account_payment_order/models/res_company.py
@@ -4,12 +4,15 @@
from odoo import api, fields, models
-from ..constantes import (SEQUENCIAL_CARTEIRA, SEQUENCIAL_EMPRESA,
- SEQUENCIAL_FATURA)
+from ..constants import (
+ SEQUENCIAL_CARTEIRA,
+ SEQUENCIAL_EMPRESA,
+ SEQUENCIAL_FATURA,
+)
class ResCompany(models.Model):
- _inherit = "res.company"
+ _inherit = 'res.company'
own_number_type = fields.Selection(
selection=[
diff --git a/l10n_br_account_payment_order/models/res_partner_bank.py b/l10n_br_account_payment_order/models/res_partner_bank.py
index 0d4c1f802d46..9cf868f73429 100644
--- a/l10n_br_account_payment_order/models/res_partner_bank.py
+++ b/l10n_br_account_payment_order/models/res_partner_bank.py
@@ -4,7 +4,7 @@
# Magno Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-from odoo import _, api, models
+from odoo import fields, models
class ResPartnerBank(models.Model):
From b6cacc4862d21d26e1537a6044d6811bc5bab9af Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 18:54:00 -0300
Subject: [PATCH 252/612] [FIX] security permissions
---
.../security/cnab_cobranca_security.xml | 9 +++------
.../security/ir.model.access.csv | 2 --
.../wizards/account_payment_line_create.py | 9 ++++++---
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/l10n_br_account_payment_order/security/cnab_cobranca_security.xml b/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
index de73aa6b1b93..0cf09df8ca0c 100644
--- a/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
+++ b/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
@@ -3,18 +3,15 @@
CNAB Cobranca
-
+
-
+
-
+
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index e4226cb7088f..78b98435c1ed 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -2,5 +2,3 @@
access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,group_cnab_cobranca,1,1,1,1
access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,group_cnab_cobranca,1,1,1,1
access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,group_cnab_cobranca,1,1,1,1
-access_bank_api_operation,bank.api.operation,model_bank_api_operation,account.group_account_invoice,1,1,1,1
-access_bank_api_operation_error_line,bank.api.operation,model_bank_api_operation_error_line,account.group_account_invoice,1,1,1,1
diff --git a/l10n_br_account_payment_order/wizards/account_payment_line_create.py b/l10n_br_account_payment_order/wizards/account_payment_line_create.py
index 7c226a5e0965..995f92d8c5b9 100644
--- a/l10n_br_account_payment_order/wizards/account_payment_line_create.py
+++ b/l10n_br_account_payment_order/wizards/account_payment_line_create.py
@@ -9,13 +9,16 @@
class AccountPaymentLineCreate(models.TransientModel):
- _inherit = "account.payment.line.create"
+ _inherit = 'account.payment.line.create'
allow_error = fields.Boolean(
string="Permitir linhas com erro na exportação, "
- "já incluidas em outras ordens"
+ "já incluidas em outras ordens",
+ )
+
+ allow_rejected = fields.Boolean(
+ string="Permitir linhas com retorno rejeitado",
)
- allow_rejected = fields.Boolean(string="Permitir linhas com retorno rejeitado")
@api.multi
def _prepare_move_line_domain(self):
From 78732aec5a15d16891788356605a648142388bd4 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 19:34:47 -0300
Subject: [PATCH 253/612] [FIX] refs in demo and data files
---
l10n_br_account_payment_order/__manifest__.py | 3 +-
.../data/l10n_br_payment_export_type.xml | 1 -
.../demo/account_invoice.xml | 39 +-
.../demo/account_journal.xml | 38 +-
.../demo/account_payment_mode_demo.xml | 432 ++++++------------
.../demo/res_partner_bank.xml | 10 +
6 files changed, 182 insertions(+), 341 deletions(-)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 7a33858ec8a2..0a49c759e75a 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -48,7 +48,7 @@
# 'views/account_payment_order_menu_views.xml', TODO REMOVE
# Wizards
- 'wizard/account_payment_line_create_view.xml',
+ 'wizards/account_payment_line_create_view.xml',
],
'demo': [
'demo/res_partner_bank.xml',
@@ -57,6 +57,7 @@
'demo/account_payment_order.xml',
'demo/res_users.xml',
'demo/account_invoice.xml',
+ 'demo/res_users.xml',
],
'installable': True,
}
diff --git a/l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml b/l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml
index 4221e63cac63..35def00374e3 100644
--- a/l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml
+++ b/l10n_br_account_payment_order/data/l10n_br_payment_export_type.xml
@@ -25,7 +25,6 @@
500
Cnab500
True
- payment
False
inbound
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index 81b4352ab16c..aa29b0ee02fb 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -4,12 +4,12 @@
-
-
+
+
-
+
Teste Itau CNAB240
@@ -18,19 +18,18 @@
-
+
[E-COM06] Computador Personalizado (kit)
100
10
-
+
-
+
Teste Itau CNAB400
@@ -39,19 +38,18 @@
-
+
[E-COM06] Computador Personalizado (kit)
100
10
-
+
-
+
Teste Unicred CNAB400
@@ -60,19 +58,18 @@
-
+
[E-COM06] Computador Personalizado (kit)
100
10
-
+
-
+
Teste Caixa Economica Federal CNAB240
@@ -81,19 +78,18 @@
-
+
[E-COM06] Computador Personalizado (kit)
100
10
-
+
-
+
Teste Banco do Brasil CNAB400
@@ -102,15 +98,14 @@
-
+
[E-COM06] Computador Personalizado (kit)
100
10
-
+
diff --git a/l10n_br_account_payment_order/demo/account_journal.xml b/l10n_br_account_payment_order/demo/account_journal.xml
index bb1857cbef5f..de7ff88c5799 100644
--- a/l10n_br_account_payment_order/demo/account_journal.xml
+++ b/l10n_br_account_payment_order/demo/account_journal.xml
@@ -7,10 +7,8 @@
Banco Bradesco
bank
BNC2
-
-
+
+
@@ -18,10 +16,8 @@
Banco Unicred
bank
BNC3
-
-
+
+
@@ -29,10 +25,8 @@
Banco Itau
bank
BNC4
-
-
+
+
@@ -40,10 +34,8 @@
Banco do Brasil
bank
BNC5
-
-
+
+
@@ -51,10 +43,16 @@
Banco Caixa Economica Federal
bank
BNC6
-
-
+
+
+
+
+
+
+ Diário de Banco(teste l10n_br_account_payment_order)
+ TPO
+ sale
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
index 1ea3f1f3e729..6ad5505ac733 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
@@ -1,300 +1,138 @@
+
+
+
+
+ Boleto Bancario
+
+ variable
+
+
+
+
+
+
+ Cobrança Bradesco400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Unicred400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 21
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Unicred240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Itau240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Caixa Economica Federal 240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Itau400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Banco do Brasil 400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
-
-
-
-
- 5384
- 8
- 7030
- 8
-
-
- BANCO DO BRASIL S.A.
-
-
-
- 5162
- 0
- 0100
- 3
-
-
- HSBC BANK BRASIL S.A. - BANCO MULTIPLO
-
-
-
- 15016
- 0
- 8515
- 0
-
-
- BANCO ITAÚ S.A.
-
-
-
- 1333
- 0
- 0707
- 0
-
-
- BANCO SANTANDER (BRASIL) S.A.
-
-
-
- 414
- 3
- 1565
- 1
-
-
- CAIXA ECONOMICA FEDERAL
-
-
-
- 395
- 0
- 1611
- 0
-
-
- BANCO BRADESCO S.A.
-
-
-
- 123
- 0
- 1234
- 0
-
-
- BANCO DO NORDESTE DO BRASIL S.A.
-
-
-
- 321
- 0
- 1234
- 0
-
-
- BANCO DO ESTADO DO RIO GRANDE DO SUL S.A.
-
-
-
- 231
- 0
- 1234
- 0
-
-
- BANESTES S.A. BANCO DO ESTADO DO ESPIRITO SANTO
-
-
-
- 312
- 0
- 1234
- 0
-
-
- BANCO COOPERATIVO DO BRASIL S.A. (SICOOB)
-
-
-
- 331
- 0
- 1234
- 0
-
-
- Sicredi - Instituição Financeira Cooperativa
-
-
-
- 371
- 0
- 1234
- 0
-
-
- Unicred
-
-
-
-
- Diário de Banco(teste l10n_br_account_payment_order)
- TPO
- sale
-
-
-
-
-
- Boleto Bancario
-
- variable
-
-
-
-
-
-
-
-
- Cobrança Bradesco400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 03
- DM
- 19
- S
-
-
-
-
-
- Cobrança Unicred400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 21
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Unicred240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Itau240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Caixa Economica Federal 240
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Itau400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Banco do Brasil 400
-
- Pagavel em qualquer banco ate o
- vencimento
-
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
diff --git a/l10n_br_account_payment_order/demo/res_partner_bank.xml b/l10n_br_account_payment_order/demo/res_partner_bank.xml
index 1d08cd40426e..651121d1bcac 100644
--- a/l10n_br_account_payment_order/demo/res_partner_bank.xml
+++ b/l10n_br_account_payment_order/demo/res_partner_bank.xml
@@ -336,4 +336,14 @@
Sicredi - Instituição Financeira Cooperativa
+
+ 371
+ 0
+ 1234
+ 0
+
+
+ Unicred
+
+
From 2225749bb4056c392c61d579de4e47b33fd2bb23 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 19:35:48 -0300
Subject: [PATCH 254/612] [ADD] description for objects
---
l10n_br_account_payment_order/models/l10n_br_cnab.py | 2 +-
l10n_br_account_payment_order/models/l10n_br_cnab_evento.py | 1 +
l10n_br_account_payment_order/models/l10n_br_cnab_lote.py | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
index bd390637a6c4..04500bc78581 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab.py
@@ -73,7 +73,7 @@
class L10nBrHrCnab(models.Model):
_name = "l10n_br.cnab"
- _rec_name = "display_name"
+ _description = 'l10n_br CNAB'
display_name = fields.Char(compute="_compute_display_name", store=True, index=True)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
index 5837a6edb86d..187395623f91 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
@@ -13,6 +13,7 @@
class L10nBrCnabEvento(models.Model):
_name = 'l10n_br.cnab.evento'
+ _description = 'l10n_br CNAB Event'
bank_payment_line_id = fields.Many2one(
string='Bank Payment Line', comodel_name='bank.payment.line'
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
index 3966fd4e65b8..7f88ac859d06 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
@@ -12,8 +12,8 @@
class L10nBrCnabLote(models.Model):
-
_name = 'l10n_br.cnab.lote'
+ _description = 'l10n_br CNAB Lot'
account_bank_id = fields.Many2one(
string='Conta Bancária', comodel_name='res.partner.bank'
From 0f0721e92b4f20e194658985d5913ef929ff4f7e Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 19:39:19 -0300
Subject: [PATCH 255/612] Rename demo files
---
l10n_br_account_payment_order/__manifest__.py | 1 -
.../demo/account_payment_mode.xml | 131 ++++++++++++++++-
.../demo/account_payment_mode_demo.xml | 138 ------------------
.../demo/{res_user.xml => res_users.xml} | 0
4 files changed, 128 insertions(+), 142 deletions(-)
delete mode 100644 l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
rename l10n_br_account_payment_order/demo/{res_user.xml => res_users.xml} (100%)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 0a49c759e75a..d7573aedd4a2 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -55,7 +55,6 @@
'demo/account_journal.xml',
'demo/account_payment_mode.xml',
'demo/account_payment_order.xml',
- 'demo/res_users.xml',
'demo/account_invoice.xml',
'demo/res_users.xml',
],
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index 6303be6b5dd3..fda59bc066f5 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -1,10 +1,10 @@
-
-
+
+
Boleto Bancario
-
+
variable
@@ -28,4 +28,129 @@
+
+
+ Cobrança Bradesco400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 03
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Unicred400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 21
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Unicred240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ N
+
+ 2
+ 5
+ 72234050
+
+
+
+
+ Cobrança Itau240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Caixa Economica Federal 240
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Itau400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
+
+
+ Cobrança Banco do Brasil 400
+
+ Pagavel em qualquer banco ate o vencimento
+ fixed
+
+ True
+
+ 06
+ 3
+ DM
+ 19
+ S
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml b/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
deleted file mode 100644
index 6ad5505ac733..000000000000
--- a/l10n_br_account_payment_order/demo/account_payment_mode_demo.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
- Boleto Bancario
-
- variable
-
-
-
-
-
-
- Cobrança Bradesco400
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 03
- DM
- 19
- S
-
-
-
-
-
- Cobrança Unicred400
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 21
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Unicred240
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- N
-
- 2
- 5
- 72234050
-
-
-
-
- Cobrança Itau240
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Caixa Economica Federal 240
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Itau400
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
-
- Cobrança Banco do Brasil 400
-
- Pagavel em qualquer banco ate o vencimento
- fixed
-
- True
-
- 06
- 3
- DM
- 19
- S
-
-
-
-
diff --git a/l10n_br_account_payment_order/demo/res_user.xml b/l10n_br_account_payment_order/demo/res_users.xml
similarity index 100%
rename from l10n_br_account_payment_order/demo/res_user.xml
rename to l10n_br_account_payment_order/demo/res_users.xml
From 0821c2e0d545f8a3148da9730602ff0c6dd7a43d Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 19:55:35 -0300
Subject: [PATCH 256/612] [FIX] cleanup objects, views and data
---
l10n_br_account_payment_order/__manifest__.py | 4 +-
.../demo/account_payment_mode.xml | 2 +-
.../demo/res_users.xml | 7 +-
.../models/account_invoice.py | 4 +-
.../models/account_payment_mode.py | 18 -----
.../views/account_invoice.xml | 73 -------------------
.../views/account_payment_mode.xml | 4 +-
.../views/account_payment_order.xml | 3 -
.../account_payment_order_menu_views.xml | 52 -------------
.../views/l10n_br_cnab_retorno_view.xml | 7 +-
.../views/l10n_br_cobranca_cnab.xml | 61 ----------------
.../views/l10n_br_cobranca_cnab_lines.xml | 8 +-
12 files changed, 13 insertions(+), 230 deletions(-)
delete mode 100644 l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index d7573aedd4a2..7dab6eb4ded5 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -7,6 +7,7 @@
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': "KMEE, "
+ "Akretion, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/l10n-brazil',
'category': 'Banking addons',
@@ -17,7 +18,7 @@
'account_cancel',
],
'data': [
- # Security]
+ # Security
'security/cnab_cobranca_security.xml',
'security/ir.model.access.csv',
@@ -45,7 +46,6 @@
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
- # 'views/account_payment_order_menu_views.xml', TODO REMOVE
# Wizards
'wizards/account_payment_line_create_view.xml',
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index fda59bc066f5..dcaa112568f5 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -62,7 +62,7 @@
2
5
- 72234050
+ 72234050
diff --git a/l10n_br_account_payment_order/demo/res_users.xml b/l10n_br_account_payment_order/demo/res_users.xml
index 4f3e08640507..183b54fe2761 100644
--- a/l10n_br_account_payment_order/demo/res_users.xml
+++ b/l10n_br_account_payment_order/demo/res_users.xml
@@ -2,13 +2,8 @@
-
- 1
- 1
-
-
- 1
+
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 099f0069e59b..6df5583f8b49 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -67,7 +67,7 @@ def _compute_receivables(self):
@api.onchange("payment_mode_id")
def _onchange_payment_mode_id(self):
tax_analytic_tag_id = self.env.ref(
- "l10n_br_account_payment_cobranca." "account_analytic_tag_tax"
+ 'l10n_br_account_payment_order.account_analytic_tag_tax'
)
to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
@@ -100,7 +100,7 @@ def _onchange_payment_mode_id(self):
@api.onchange("payment_term_id")
def _onchange_payment_term(self):
interest_analytic_tag_id = self.env.ref(
- "l10n_br_account_payment_cobranca." "account_analytic_tag_interest"
+ 'l10n_br_account_payment_order.account_analytic_tag_interest'
)
to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 162e2f098b86..65dc5a6e1154 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -175,18 +175,6 @@ class AccountPaymentMode(models.Model):
'O nosso número pode ser gerado pelo banco.',
)
- default_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão',
- help='Conta padrão para recebimentos',
- )
-
- default_tax_account_id = fields.Many2one(
- comodel_name='account.account',
- string='Conta Padrão para Taxas Bancárias',
- help='Conta padrão para recebimentos de Taxas Bancárias',
- )
-
product_tax_id = fields.Many2one(
comodel_name='product.product',
string='Taxa Adicional',
@@ -262,12 +250,6 @@ class AccountPaymentMode(models.Model):
)
]
-
- @api.constrains('product_override')
- def _constrains_product_override(self):
- if self.product_override and self.product_override_value <= 0:
- raise ValidationError('O valor da Taxa deve ser maior que 0 (zero)')
-
@api.constrains(
'boleto_type',
'boleto_wallet',
diff --git a/l10n_br_account_payment_order/views/account_invoice.xml b/l10n_br_account_payment_order/views/account_invoice.xml
index 57835888ef94..0d50c27453c7 100644
--- a/l10n_br_account_payment_order/views/account_invoice.xml
+++ b/l10n_br_account_payment_order/views/account_invoice.xml
@@ -11,36 +11,10 @@
1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -57,53 +31,6 @@
[('state','!=','paid')]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index cbe94f1d5c27..9998d80b2d3c 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -66,8 +66,8 @@
-
-
+
diff --git a/l10n_br_account_payment_order/views/account_payment_order.xml b/l10n_br_account_payment_order/views/account_payment_order.xml
index 323677a7cb35..4fcb10321bdf 100644
--- a/l10n_br_account_payment_order/views/account_payment_order.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order.xml
@@ -36,9 +36,6 @@
-
- {'default_payment_type': payment_type, 'tree_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_tree', 'form_view_ref': 'l10n_br_account_payment_cobranca.l10n_br_cobranca_payment_line_form'}
-
diff --git a/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml b/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
deleted file mode 100644
index 4fd5b64785bc..000000000000
--- a/l10n_br_account_payment_order/views/account_payment_order_menu_views.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
- Payment Orders
- account.payment.order
- tree,form,pivot,graph
-
- [('payment_type', '=', 'outbound'),('operation_type', '=', '1')]
- {'default_payment_type': 'outbound','default_operation_type': '1'}
-
-
-
- Debit Orders
- account.payment.order
- tree,form,pivot,graph
-
-
- [('payment_type', '=', 'inbound'),('operation_type', '=', '2')]
- {'default_payment_type': 'inbound','default_operation_type': '2'}
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml b/l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml
index 8b316073d10b..dff8e6839cd6 100644
--- a/l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml
+++ b/l10n_br_account_payment_order/views/l10n_br_cnab_retorno_view.xml
@@ -35,8 +35,7 @@
-
+
@@ -141,7 +140,7 @@
@@ -199,7 +198,7 @@
diff --git a/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml
index 89406e4e7059..1d77a6b31998 100644
--- a/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml
+++ b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab.xml
@@ -1,65 +1,4 @@
-
-
- [('payment_order_type', '=', 'payment')]
-
- {'search_payment_order_type': 'payment'}
-
-
-
-
- Cobranca
- payment.order
- form
- tree,form
- {'search_payment_order_type': 'cobranca',
- 'default_payment_order_type': 'cobranca'}
-
-
- [('payment_order_type', '=', 'cobranca')]
-
- Crie ordens de cobrança CNAB 240.
-
-
-
-
-
- payment.order.form
- payment.order
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [('payment_order_type', '=',
- payment_order_type)]
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml
index 897a20a361ec..095999b6f1f4 100644
--- a/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml
+++ b/l10n_br_account_payment_order/views/l10n_br_cobranca_cnab_lines.xml
@@ -111,10 +111,9 @@
-
-
+
@@ -122,13 +121,10 @@
-
+
-
-
-
From 5fc72132425f2d44dc96e3a579e86ddfc334ed76 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 21:56:22 -0300
Subject: [PATCH 257/612] [FIX] migration file
---
.../migrations/12.0.2.0.0/pre-migration.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index ad0f1fab96de..b3f70ab5da31 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -66,7 +66,7 @@
('identificacao_titulo_empresa', 'company_title_identification'),
('is_erro_exportacao', 'is_export_error'),
('mensagem_erro_exportacao', 'export_error_message'),
- ('ultimo_estado_cnab', 'last_state_cnab')
+ ('ultimo_estado_cnab', 'last_cnab_state')
],
'l10n_br.cnab.evento': [
('data_real_pagamento', 'real_payment_date'),
@@ -116,10 +116,10 @@
('identificacao_titulo_empresa', 'company_title_identification'),
('situacao_pagamento', 'payment_situation'),
('instrucoes', 'instructions'),
- ('ultimo_estado_cnab', 'last_state_cnab')
],
}
+
@openupgrade.migrate(use_env=True)
def migrate(env, version):
openupgrade.rename_columns(env.cr, _column_renames)
From 1696635a085b64ac7a8461c624f8dcff3324283e Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 21:57:20 -0300
Subject: [PATCH 258/612] [FIX] demo data
---
.../demo/account_invoice.xml | 16 +++++++++++++++-
.../demo/account_payment_order.xml | 9 +++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index aa29b0ee02fb..be132a2c78b0 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -2,12 +2,26 @@
-
+ Test Payment Order
+
+
+ out_invoice
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
Teste Itau CNAB240
diff --git a/l10n_br_account_payment_order/demo/account_payment_order.xml b/l10n_br_account_payment_order/demo/account_payment_order.xml
index 3947832957c3..29dfe4aeacb2 100644
--- a/l10n_br_account_payment_order/demo/account_payment_order.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_order.xml
@@ -21,6 +21,15 @@
100
10
+
+
+
+ 3.01.01.01.01.02.00-AVOID_TRAVIS_ERROR*
+ Receita da Venda no Mercado Interno
+ de Produtos de Fabricação Própria - AVOID_TRAVIS_ERROR
+
+
+
From e01a84fe797c64b4ecb891a925ee0141a1198222 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 21:58:20 -0300
Subject: [PATCH 259/612] [FIX] wrong field names
---
.../models/account_invoice.py | 82 ++++++++---------
.../models/account_move_line.py | 53 +++++------
.../models/account_payment_line.py | 2 +-
.../models/account_payment_order.py | 2 +-
.../models/bank_payment_line.py | 87 ++++++++++++-------
.../views/bank_payment_line.xml | 2 +-
6 files changed, 126 insertions(+), 102 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 6df5583f8b49..940e0e99e634 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -3,8 +3,6 @@
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import logging
-
from odoo import _, api, fields, models
from odoo.exceptions import UserError
@@ -14,30 +12,25 @@
SEQUENCIAL_FATURA,
)
-_logger = logging.getLogger(__name__)
-
class AccountInvoice(models.Model):
- _inherit = "account.invoice"
-
- @api.multi
- @api.depends("state", "move_id.line_ids", "move_id.line_ids.account_id")
- def _compute_receivables(self):
- for record in self:
- lines = self.env["account.move.line"]
- for line in record.move_id.line_ids:
- if (
- line.account_id.id == record.account_id.id
- and line.account_id.internal_type in ("receivable", "payable")
- ):
- lines |= line
- record.move_line_receivable_ids = lines.sorted()
+ _inherit = 'account.invoice'
move_line_receivable_ids = fields.Many2many(
- comodel_name="account.move.line",
- string=u"Receivables",
+ comodel_name='account.move.line',
+ string='Receivables',
store=True,
- compute="_compute_receivables",
+ compute='_compute_receivables',
+ )
+
+ eval_payment_mode_instrucoes = fields.Text(
+ string='Instruções de Cobrança do Modo de Pagamento',
+ related='payment_mode_id.instrucoes',
+ readonly=True,
+ )
+
+ instrucoes = fields.Text(
+ string='Instruções de cobrança',
)
# eval_state_cnab = fields.Selection(
@@ -56,19 +49,22 @@ def _compute_receivables(self):
# index=True,
# )
- eval_payment_mode_instrucoes = fields.Text(
- string="Instruções de Cobrança do Modo de Pagamento",
- related="payment_mode_id.instrucoes",
- readonly=True,
- )
-
- instrucoes = fields.Text(string="Instruções de cobrança")
+ @api.multi
+ @api.depends('state', 'move_id.line_ids', 'move_id.line_ids.account_id')
+ def _compute_receivables(self):
+ for record in self:
+ lines = self.env['account.move.line']
+ for line in record.move_id.line_ids:
+ if (line.account_id.id == record.account_id.id
+ and line.account_id.internal_type in ('receivable',
+ 'payable')):
+ lines |= line
+ record.move_line_receivable_ids = lines.sorted()
- @api.onchange("payment_mode_id")
+ @api.onchange('payment_mode_id')
def _onchange_payment_mode_id(self):
tax_analytic_tag_id = self.env.ref(
- 'l10n_br_account_payment_order.account_analytic_tag_tax'
- )
+ 'l10n_br_account_payment_order.account_analytic_tag_tax')
to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
lambda i: tax_analytic_tag_id in i.analytic_tag_ids
@@ -98,7 +94,7 @@ def _onchange_payment_mode_id(self):
)
@api.onchange("payment_term_id")
- def _onchange_payment_term(self):
+ def _onchange_payment_term_id(self):
interest_analytic_tag_id = self.env.ref(
'l10n_br_account_payment_order.account_analytic_tag_interest'
)
@@ -180,14 +176,13 @@ def action_invoice_cancel(self):
record._remove_payment_order_line()
- super(AccountInvoice, self).action_invoice_cancel()
+ super().action_invoice_cancel()
@api.multi
def get_invoice_fiscal_number(self):
""" Como neste modulo nao temos o numero do documento fiscal,
vamos retornar o numero do core e deixar este metodo
para caso alguem queira sobrescrever"""
-
self.ensure_one()
return self.number
@@ -226,7 +221,8 @@ def _pos_action_move_create(self):
interval.transaction_ref = sequence
interval.nosso_numero = (
- sequence if interval.payment_mode_id.gera_nosso_numero else "0"
+ sequence if interval.payment_mode_id.generate_own_number
+ else "0"
)
interval.numero_documento = numero_documento
interval.identificacao_titulo_empresa = hex(interval.id).upper()
@@ -239,20 +235,19 @@ def _pos_action_move_create(self):
@api.multi
def action_move_create(self):
- result = super(AccountInvoice, self).action_move_create()
+ result = super().action_move_create()
self._pos_action_move_create()
return result
@api.multi
def create_account_payment_line_baixa(self):
-
for inv in self:
applicable_lines = inv.move_id.line_ids.filtered(
lambda x: (
x.payment_mode_id.payment_order_ok
- and x.account_id.internal_type in ("receivable", "payable")
+ and x.account_id.internal_type in ('receivable', 'payable')
)
)
@@ -265,7 +260,7 @@ def create_account_payment_line_baixa(self):
% inv.number
)
- payment_modes = applicable_lines.mapped("payment_mode_id")
+ payment_modes = applicable_lines.mapped('payment_mode_id')
if not payment_modes:
raise UserError(_("No Payment Mode on invoice %s") % inv.number)
@@ -312,7 +307,7 @@ def create_account_payment_line_baixa(self):
@api.multi
def invoice_validate(self):
- result = super(AccountInvoice, self).invoice_validate()
+ result = super().invoice_validate()
filtered_invoice_ids = self.filtered(lambda s: s.payment_mode_id)
if filtered_invoice_ids:
filtered_invoice_ids.create_account_payment_line()
@@ -343,15 +338,14 @@ def assign_outstanding_credit(self, credit_aml_id):
"exportada ou aceita no banco."
)
)
- return super(AccountInvoice, self).assign_outstanding_credit(credit_aml_id)
+ return super().assign_outstanding_credit(credit_aml_id)
@api.multi
def register_payment(
self, payment_line, writeoff_acc_id=False, writeoff_journal_id=False
):
- res = super(AccountInvoice, self).register_payment(
- payment_line, writeoff_acc_id, writeoff_journal_id
- )
+ res = super().register_payment(
+ payment_line, writeoff_acc_id, writeoff_journal_id)
self._pos_action_move_create()
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index a18d4588e16f..76ffc2665088 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -54,6 +54,24 @@ class AccountMoveLine(models.Model):
currency_field='company_currency_id',
)
+ journal_entry_ref = fields.Char(
+ string="Journal Entry Ref",
+ compute="_compute_journal_entry_ref",
+ store=True,
+ )
+
+ @api.depends("move_id")
+ def _compute_journal_entry_ref(self):
+ for record in self:
+ if record.name:
+ record.journal_entry_ref = record.name
+ elif record.move_id.name:
+ record.journal_entry_ref = record.move_id.name
+ elif record.invoice_id and record.invoice_id.number:
+ record.journal_entry_ref = record.invoice_id.number
+ else:
+ record.journal_entry_ref = "*" + str(record.move_id.id)
+
@api.multi
def _prepare_payment_line_vals(self, payment_order):
vals = super()._prepare_payment_line_vals(payment_order)
@@ -98,45 +116,28 @@ def _update_check(self):
@api.multi
def write(self, values):
'''
- Sobrescrita do método Write. Não deve ser possível voltar o state_cnab
+ Sobrescrita do método Write. Não deve ser possível voltar o cnab_state
ou a situacao_pagamento para um estado anterior
:param values:
:return:
'''
for record in self:
- state_cnab = values.get('state_cnab')
+ cnab_state = values.get('cnab_state')
- if state_cnab and (
- record.state_cnab == 'done'
+ if cnab_state and (
+ record.cnab_state == 'done'
or (
- record.state_cnab in ['accepted', 'accepted_hml']
- and state_cnab not in ['accepted', 'accepted_hml', 'done']
+ record.cnab_state in ['accepted', 'accepted_hml']
+ and cnab_state not in ['accepted', 'accepted_hml', 'done']
)
):
- values.pop('state_cnab', False)
+ values.pop('cnab_state', False)
- if record.situacao_pagamento not in ['inicial', 'aberta']:
- values.pop('situacao_pagamento', False)
+ if record.payment_situation not in ['inicial', 'aberta']:
+ values.pop('payment_situation', False)
return super().write(values)
-
- # journal_entry_ref = fields.Char(
- # compute="_compute_journal_entry_ref", string="Journal Entry Ref", store=True
- # )
- #
- # @api.depends("move_id")
- # def _compute_journal_entry_ref(self):
- # for record in self:
- # if record.name:
- # record.journal_entry_ref = record.name
- # elif record.move_id.name:
- # record.journal_entry_ref = record.move_id.name
- # elif record.invoice_id and record.invoice_id.number:
- # record.journal_entry_ref = record.invoice_id.number
- # else:
- # record.journal_entry_ref = "*" + str(record.move_id.id)
-
@api.multi
def get_balance(self):
"""
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index 6530b9564a97..e30b7f481715 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -4,7 +4,7 @@
from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
-from odoo.tools.float_utils import float_round as round # TODO check round methods in 12.0
+from odoo.tools.float_utils import float_round as round
from ..constants import (
AVISO_FAVORECIDO,
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 21dff1f8f4bc..3e519f9778c4 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -113,7 +113,7 @@ def _prepare_bank_payment_line(self, paylines):
result['document_number'] = paylines[0].document_number
result['company_title_identification'] =\
paylines[0].company_title_identification
- result['last_state_cnab'] = paylines[0].move_line_id.state_cnab
+ result['last_cnab_state'] = paylines[0].move_line_id.cnab_state
return result
@api.multi
diff --git a/l10n_br_account_payment_order/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
index 38c93745fd01..8519a996fce6 100644
--- a/l10n_br_account_payment_order/models/bank_payment_line.py
+++ b/l10n_br_account_payment_order/models/bank_payment_line.py
@@ -16,21 +16,20 @@ class BankPaymentLine(models.Model):
@api.model
def default_get(self, fields_list):
- res = super(BankPaymentLine, self).default_get(fields_list)
+ res = super().default_get(fields_list)
mode = (
- self.env['account.payment.order']
- .browse(self.env.context.get('order_id'))
- .payment_mode_id
+ self.env['account.payment.order'].browse(
+ self.env.context.get('order_id')).payment_mode_id
)
- if mode.codigo_finalidade_doc:
+ if mode.doc_finality_code:
res.update({'doc_finality_code': mode.doc_finality_code})
- if mode.codigo_finalidade_ted:
+ if mode.ted_finality_code:
res.update({'ted_finality_code': mode.ted_finality_code})
- if mode.codigo_finalidade_complementar:
+ if mode.complementary_finality_code:
res.update(
{'complementary_finality_code': mode.complementary_finality_code}
)
- if mode.aviso_ao_favorecido:
+ if mode.favored_warning:
res.update({'favored_warning': mode.favored_warning})
return res
@@ -39,60 +38,92 @@ def default_get(self, fields_list):
string='Complemento do Tipo de Serviço',
help='Campo P005 do CNAB',
)
+
ted_finality_code = fields.Selection(
selection=CODIGO_FINALIDADE_TED,
string='Código Finalidade da TED',
help='Campo P011 do CNAB',
)
+
complementary_finality_code = fields.Char(
- size=2, string='Código de finalidade complementar', help='Campo P013 do CNAB'
+ string='Código de finalidade complementar',
+ size=2,
+ help='Campo P013 do CNAB',
)
+
favored_warning = fields.Selection(
selection=AVISO_FAVORECIDO,
string='Aviso ao Favorecido',
- help='Campo P006 do CNAB',
default='0',
+ help='Campo P006 do CNAB',
)
+
rebate_value = fields.Float(
- digits=(13, 2),
string='Valor do Abatimento',
- help='Campo G045 do CNAB',
+ digits=(13, 2),
default=0.00,
+ help='Campo G045 do CNAB',
)
+
discount_value = fields.Float(
- digits=(13, 2),
string='Valor do Desconto',
- help='Campo G046 do CNAB',
+ digits=(13, 2),
default=0.00,
+ help='Campo G046 do CNAB',
)
+
interest_value = fields.Float(
- digits=(13, 2), string='Valor da Mora', help='Campo G047 do CNAB', default=0.00
+ string='Valor da Mora',
+ digits=(13, 2),
+ default=0.00,
+ help='Campo G047 do CNAB',
)
+
fee_value = fields.Float(
- digits=(13, 2), string='Valor da Multa', help='Campo G048 do CNAB', default=0.00
+ string='Valor da Multa',
+ digits=(13, 2),
+ default=0.00,
+ help='Campo G048 do CNAB',
)
+
event_id = fields.One2many(
string='Eventos CNAB',
comodel_name='l10n_br.cnab.evento',
inverse_name='bank_payment_line_id',
readonly=True,
)
- own_number = fields.Char(string='Nosso Numero')
- document_number = fields.Char(string='Número documento')
- company_title_identification = fields.Char(string='Identificação Titulo Empresa')
- is_export_error = fields.Boolean(string='Contem erro de exportação')
- export_error_message = fields.Char(string='Mensagem de erro')
- last_state_cnab = fields.Selection(
+
+ own_number = fields.Char(
+ string='Nosso Numero',
+ )
+
+ document_number = fields.Char(
+ string='Número documento',
+ )
+
+ company_title_identification = fields.Char(
+ string='Identificação Titulo Empresa',
+ )
+
+ is_export_error = fields.Boolean(
+ string='Contem erro de exportação',
+ )
+
+ export_error_message = fields.Char(
+ string='Mensagem de erro',
+ )
+
+ last_cnab_state = fields.Selection(
selection=ESTADOS_CNAB,
string='Último Estado do CNAB',
help='Último Estado do CNAB antes da confirmação de '
- 'pagamento nas Ordens de Pagamento',
+ 'pagamento nas Ordens de Pagamento',
)
@api.multi
def unlink(self):
for record in self:
- if not record.last_state_cnab:
+ if not record.last_cnab_state:
continue
move_line_id = self.env['account.move.line'].search(
@@ -104,9 +135,9 @@ def unlink(self):
)
]
)
- move_line_id.state_cnab = record.last_state_cnab
+ move_line_id.state_cnab = record.last_cnab_state
- return super(BankPaymentLine, self).unlink()
+ return super().unlink()
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
@@ -116,9 +147,7 @@ def same_fields_payment_line_and_bank_payment_line(self):
to bank payment line
The fields must have the same name on the 2 objects
"""
- same_fields = super(
- BankPaymentLine, self
- ).same_fields_payment_line_and_bank_payment_line()
+ same_fields = super().same_fields_payment_line_and_bank_payment_line()
# TODO: Implementar campo brasileiros que permitem mesclar linhas
diff --git a/l10n_br_account_payment_order/views/bank_payment_line.xml b/l10n_br_account_payment_order/views/bank_payment_line.xml
index b41f1311fa88..4b0d81cd2f3b 100644
--- a/l10n_br_account_payment_order/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_order/views/bank_payment_line.xml
@@ -11,7 +11,7 @@
-
+
From cf5edbc91d657b7a19c25729c19e6bb329d8ed1b Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 21:58:33 -0300
Subject: [PATCH 260/612] [FIX] tests
---
.../tests/test_payment_order.py | 50 +++++++++----------
.../tests/test_payment_order_inbound.py | 4 +-
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order.py
index e0674b800c7a..b227d00bc4c3 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order.py
@@ -13,12 +13,13 @@ def setUp(self):
super().setUp()
# Get Invoice for test
self.invoice_customer_original = self.env.ref(
- 'l10n_br_account_payment_order.demo_invoice_payment_order'
+ 'l10n_br_account_payment_order.'
+ 'demo_invoice_payment_order_itau_cnab400'
)
# Payment Mode
self.payment_mode = self.env.ref(
- 'l10n_br_account_payment_order.main_company_payment_mode_boleto'
+ 'l10n_br_account_payment_order.payment_mode_cobranca_itau400'
)
self.env['account.payment.order'].search([])
@@ -72,18 +73,19 @@ def test_implemented_fields_payment_order(self):
"Error with compute field journal_entry_ref")
test_balance_value = line.get_balance()
- self.assertEqual(
- test_balance_value, 700.0,
+ self.assertEquals(
+ test_balance_value, 300.0,
"Error with method get_balance()")
def test_cancel_payment_order(self):
""" Test create and cancel a Payment Order."""
# Add to payment order
- self.invoice_customer_original.create_account_payment_line()
+ payment_order = self.env['account.payment.order'].search([
+ ('payment_mode_id', '=', self.payment_mode.id)])
+
+ bank_journal = self.env.ref(
+ 'l10n_br_account_payment_order.itau_journal')
- payment_order = self.env['account.payment.order'].search([])
- bank_journal = self.env['account.journal'].search(
- [('type', '=', 'bank')], limit=1)
# Set journal to allow cancelling entries
bank_journal.update_posted = True
@@ -96,39 +98,37 @@ def test_cancel_payment_order(self):
for line in payment_order.payment_line_ids:
line.percent_interest = 1.5
- self.assertEqual(line._get_info_partner(
- self.invoice_customer_original.partner_id),
- 'AKRETION LTDA',
- "Error with method _get_info_partner"
- )
+
test_amount_interest = line.amount_interest
- self.assertEqual(
- test_amount_interest, 10.5,
+ self.assertEquals(
+ test_amount_interest, 4.5,
"Error with compute field amount_interest.")
# Open payment order
payment_order.draft2open()
- self.assertEqual(len(payment_order.bank_line_ids), 2)
+ self.assertEquals(len(payment_order.bank_line_ids), 1)
+ # TODO
# Generate and upload
- payment_order.open2generated()
- payment_order.generated2uploaded()
-
- self.assertEqual(payment_order.state, 'uploaded')
- with self.assertRaises(UserError):
- payment_order.unlink()
+ # payment_order.open2generated()
+ # payment_order.generated2uploaded()
+ # self.assertEquals(payment_order.state, 'uploaded')
+ # with self.assertRaises(UserError):
+ # payment_order.unlink()
bank_line = payment_order.bank_line_ids
- with self.assertRaises(UserError):
- bank_line.unlink()
+ # with self.assertRaises(UserError):
+ bank_line.unlink()
payment_order.action_done_cancel()
self.assertEqual(payment_order.state, 'cancel')
payment_order.unlink()
- self.assertEqual(len(self.env['account.payment.order'].search([])), 0)
+
+ self.assertEquals(len(self.env['account.payment.order'].search([
+ ('payment_mode_id', '=', self.payment_mode.id)])), 0)
def test_bra_number_constrains(self):
""" Test bra_number constrains. """
diff --git a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index 3faae109961e..d46711f2c0fd 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -6,10 +6,10 @@
from odoo.tests.common import TransactionCase
-class TestPaymentOrder(TransactionCase):
+class TestPaymentOrderInbound(TransactionCase):
def setUp(self):
- super(TestPaymentOrder, self).setUp()
+ super().setUp()
# Get Invoice for test
self.invoice_customer_original = self.env.ref(
From 07956cba95adabd09c027fc6b39bac5022d32c19 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 22:03:57 -0300
Subject: [PATCH 261/612] Rename demo file
---
l10n_br_account_payment_order/__manifest__.py | 2 +-
.../demo/{account_payment_order.xml => account_account.xml} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename l10n_br_account_payment_order/demo/{account_payment_order.xml => account_account.xml} (100%)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 7dab6eb4ded5..453e801b0aef 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -52,9 +52,9 @@
],
'demo': [
'demo/res_partner_bank.xml',
+ 'demo/account_account.xml',
'demo/account_journal.xml',
'demo/account_payment_mode.xml',
- 'demo/account_payment_order.xml',
'demo/account_invoice.xml',
'demo/res_users.xml',
],
diff --git a/l10n_br_account_payment_order/demo/account_payment_order.xml b/l10n_br_account_payment_order/demo/account_account.xml
similarity index 100%
rename from l10n_br_account_payment_order/demo/account_payment_order.xml
rename to l10n_br_account_payment_order/demo/account_account.xml
From d9ebbcfed30830f423447c69a47990ba9d96f608 Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 19 Aug 2020 22:08:02 -0300
Subject: [PATCH 262/612] pep8
---
.../models/account_invoice.py | 80 +++++++++----------
.../tests/test_payment_order.py | 6 +-
2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 940e0e99e634..6871f834a0b0 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -93,38 +93,38 @@ def _onchange_payment_mode_id(self):
}
)
- @api.onchange("payment_term_id")
- def _onchange_payment_term_id(self):
- interest_analytic_tag_id = self.env.ref(
- 'l10n_br_account_payment_order.account_analytic_tag_interest'
- )
-
- to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
- lambda i: interest_analytic_tag_id in i.analytic_tag_ids
- )
-
- self.invoice_line_ids -= to_remove_invoice_line_ids
-
- payment_term_id = self.payment_term_id
- amount_total = self.amount_total
- if payment_term_id.has_interest and amount_total > 0:
- invoice_line_data = {
- "name": "Taxa de juros por parcelamento no cartão",
- "partner_id": self.partner_id.id,
- "account_id": payment_term_id.interest_account_id.id,
- "analytic_tag_ids": [(6, 0, [interest_analytic_tag_id.id])],
- "quantity": 1,
- "price_unit": amount_total * payment_term_id.interest_rate / 100,
- }
-
- self.update(
- {
- "invoice_line_ids": [
- (6, 0, self.invoice_line_ids.ids),
- (0, 0, invoice_line_data),
- ]
- }
- )
+ # @api.onchange("payment_term_id")
+ # def _onchange_payment_term_id(self):
+ # interest_analytic_tag_id = self.env.ref(
+ # 'l10n_br_account_payment_order.account_analytic_tag_interest'
+ # )
+ #
+ # to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
+ # lambda i: interest_analytic_tag_id in i.analytic_tag_ids
+ # )
+ #
+ # self.invoice_line_ids -= to_remove_invoice_line_ids
+ #
+ # payment_term_id = self.payment_term_id
+ # amount_total = self.amount_total
+ # if payment_term_id.has_interest and amount_total > 0:
+ # invoice_line_data = {
+ # "name": "Taxa de juros por parcelamento no cartão",
+ # "partner_id": self.partner_id.id,
+ # "account_id": payment_term_id.interest_account_id.id,
+ # "analytic_tag_ids": [(6, 0, [interest_analytic_tag_id.id])],
+ # "quantity": 1,
+ # "price_unit": amount_total * payment_term_id.interest_rate / 100,
+ # }
+ #
+ # self.update(
+ # {
+ # "invoice_line_ids": [
+ # (6, 0, self.invoice_line_ids.ids),
+ # (0, 0, invoice_line_data),
+ # ]
+ # }
+ # )
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_ids = self.move_line_receivable_ids
@@ -222,7 +222,7 @@ def _pos_action_move_create(self):
interval.transaction_ref = sequence
interval.nosso_numero = (
sequence if interval.payment_mode_id.generate_own_number
- else "0"
+ else "0"
)
interval.numero_documento = numero_documento
interval.identificacao_titulo_empresa = hex(interval.id).upper()
@@ -317,13 +317,13 @@ def invoice_validate(self):
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
- if self.payment_term_id.payment_mode_selection == "cartao":
- raise UserError(
- _(
- "Não é possível adicionar pagamentos em uma fatura "
- "parcelada no cartão de crédito"
- )
- )
+ # if self.payment_term_id.payment_mode_selection == "cartao":
+ # raise UserError(
+ # _(
+ # "Não é possível adicionar pagamentos em uma fatura "
+ # "parcelada no cartão de crédito"
+ # )
+ # )
if self.eval_situacao_pagamento in ["paga", "liquidada", "baixa_liquidacao"]:
raise UserError(
_(
diff --git a/l10n_br_account_payment_order/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order.py
index b227d00bc4c3..44d891bd518a 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order.py
@@ -4,7 +4,7 @@
from openerp.tests.common import TransactionCase
-from openerp.exceptions import UserError, ValidationError
+from openerp.exceptions import ValidationError
class TestPaymentOrder(TransactionCase):
@@ -74,7 +74,7 @@ def test_implemented_fields_payment_order(self):
test_balance_value = line.get_balance()
self.assertEquals(
- test_balance_value, 300.0,
+ test_balance_value, 700.0,
"Error with method get_balance()")
def test_cancel_payment_order(self):
@@ -101,7 +101,7 @@ def test_cancel_payment_order(self):
test_amount_interest = line.amount_interest
self.assertEquals(
- test_amount_interest, 4.5,
+ test_amount_interest, 10.5,
"Error with compute field amount_interest.")
# Open payment order
From caafc164d13bc74db32efa45ae543847668b0c6f Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 15:35:23 -0300
Subject: [PATCH 263/612] [MIG][REF] Translate name fields from portuguese to
english.
---
.../demo/account_payment_mode.xml | 14 +-
.../migrations/12.0.2.0.0/pre-migration.py | 6 +
.../models/account_invoice.py | 146 +++++++++---------
.../models/account_payment_line.py | 2 +-
.../models/account_payment_mode.py | 2 +-
.../views/account_payment_mode.xml | 6 +-
6 files changed, 91 insertions(+), 85 deletions(-)
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index dcaa112568f5..711ce8ed9ed3 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -32,7 +32,7 @@
Cobrança Bradesco400
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -49,7 +49,7 @@
Cobrança Unicred400
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -69,7 +69,7 @@
Cobrança Unicred240
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -89,7 +89,7 @@
Cobrança Itau240
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -106,7 +106,7 @@
Cobrança Caixa Economica Federal 240
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -123,7 +123,7 @@
Cobrança Itau400
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
@@ -140,7 +140,7 @@
Cobrança Banco do Brasil 400
- Pagavel em qualquer banco ate o vencimento
+ Pagavel em qualquer banco ate o vencimento
fixed
True
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index b3f70ab5da31..c08a2476651d 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -6,6 +6,7 @@
_column_renames = {
'account.payment.mode': [
+ ('instrucoes', 'instructions'),
('condicao_da_papeleta', 'condition_issuing_paper'),
('comunicacao_2', 'communication_2'),
('tipo_servico', 'service_type'),
@@ -31,6 +32,7 @@
('boleto_perc_multa', 'boleto_fee_perc'),
],
'account.payment.line': [
+ ('linha_digitavel', 'digitable_line'),
('nosso_numero', 'own_number'),
('numero_documento', 'document_number'),
('identificacao_titulo_empresa', 'company_title_identification'),
@@ -117,6 +119,10 @@
('situacao_pagamento', 'payment_situation'),
('instrucoes', 'instructions'),
],
+ 'account.invoice': [
+ ('instrucoes', 'instructions'),
+ ('eval_payment_mode_instrucoes', 'eval_payment_mode_instructions')
+ ],
}
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 6871f834a0b0..b09b7ad61546 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -23,27 +23,27 @@ class AccountInvoice(models.Model):
compute='_compute_receivables',
)
- eval_payment_mode_instrucoes = fields.Text(
+ eval_payment_mode_instructions = fields.Text(
string='Instruções de Cobrança do Modo de Pagamento',
- related='payment_mode_id.instrucoes',
+ related='payment_mode_id.instructions',
readonly=True,
)
- instrucoes = fields.Text(
+ instructions = fields.Text(
string='Instruções de cobrança',
)
# eval_state_cnab = fields.Selection(
- # string=u"Estado CNAB",
- # related="move_line_receivable_id.state_cnab",
+ # string=u'Estado CNAB',
+ # related='move_line_receivable_id.state_cnab',
# readonly=True,
# store=True,
# index=True,
# )
#
# eval_situacao_pagamento = fields.Selection(
- # string=u"Situação do Pagamento",
- # related="move_line_receivable_id.situacao_pagamento",
+ # string=u'Situação do Pagamento',
+ # related='move_line_receivable_id.situacao_pagamento',
# readonly=True,
# store=True,
# index=True,
@@ -75,25 +75,25 @@ def _onchange_payment_mode_id(self):
payment_mode_id = self.payment_mode_id
if payment_mode_id.product_tax_id:
invoice_line_data = {
- "name": "Taxa adicional do modo de pagamento escolhido",
- "partner_id": self.partner_id.id,
- "account_id": payment_mode_id.tax_account_id.id,
- "product_id": payment_mode_id.product_tax_id.id,
- "price_unit": payment_mode_id.product_tax_id.lst_price,
- "quantity": 1,
- "analytic_tag_ids": [(6, 0, [tax_analytic_tag_id.id])],
+ 'name': 'Taxa adicional do modo de pagamento escolhido',
+ 'partner_id': self.partner_id.id,
+ 'account_id': payment_mode_id.tax_account_id.id,
+ 'product_id': payment_mode_id.product_tax_id.id,
+ 'price_unit': payment_mode_id.product_tax_id.lst_price,
+ 'quantity': 1,
+ 'analytic_tag_ids': [(6, 0, [tax_analytic_tag_id.id])],
}
self.update(
{
- "invoice_line_ids": [
+ 'invoice_line_ids': [
(6, 0, self.invoice_line_ids.ids),
(0, 0, invoice_line_data),
]
}
)
- # @api.onchange("payment_term_id")
+ # @api.onchange('payment_term_id')
# def _onchange_payment_term_id(self):
# interest_analytic_tag_id = self.env.ref(
# 'l10n_br_account_payment_order.account_analytic_tag_interest'
@@ -109,17 +109,17 @@ def _onchange_payment_mode_id(self):
# amount_total = self.amount_total
# if payment_term_id.has_interest and amount_total > 0:
# invoice_line_data = {
- # "name": "Taxa de juros por parcelamento no cartão",
- # "partner_id": self.partner_id.id,
- # "account_id": payment_term_id.interest_account_id.id,
- # "analytic_tag_ids": [(6, 0, [interest_analytic_tag_id.id])],
- # "quantity": 1,
- # "price_unit": amount_total * payment_term_id.interest_rate / 100,
+ # 'name': 'Taxa de juros por parcelamento no cartão',
+ # 'partner_id': self.partner_id.id,
+ # 'account_id': payment_term_id.interest_account_id.id,
+ # 'analytic_tag_ids': [(6, 0, [interest_analytic_tag_id.id])],
+ # 'quantity': 1,
+ # 'price_unit': amount_total * payment_term_id.interest_rate / 100,
# }
#
# self.update(
# {
- # "invoice_line_ids": [
+ # 'invoice_line_ids': [
# (6, 0, self.invoice_line_ids.ids),
# (0, 0, invoice_line_data),
# ]
@@ -128,28 +128,28 @@ def _onchange_payment_mode_id(self):
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_ids = self.move_line_receivable_ids
- payment_order_ids = self.env["account.payment.order"].search(
- [("payment_line_ids.move_line_id", "in", [move_line_receivable_ids.id])]
+ payment_order_ids = self.env['account.payment.order'].search(
+ [('payment_line_ids.move_line_id', 'in', [move_line_receivable_ids.id])]
)
if payment_order_ids:
draft_cancel_payment_order_ids = payment_order_ids.filtered(
- lambda p: p.state in ["draft", "cancel"]
+ lambda p: p.state in ['draft', 'cancel']
)
if payment_order_ids - draft_cancel_payment_order_ids:
if _raise:
raise UserError(
_(
- "A fatura não pode ser cancelada pois a mesma já se "
- "encontra exportada por uma ordem de pagamento."
+ 'A fatura não pode ser cancelada pois a mesma já se '
+ 'encontra exportada por uma ordem de pagamento.'
)
)
for po_id in draft_cancel_payment_order_ids:
- p_line_id = self.env["account.payment.line"].search(
+ p_line_id = self.env['account.payment.line'].search(
[
- ("order_id", "=", po_id.id),
- ("move_line_id", "=", move_line_receivable_ids.id),
+ ('order_id', '=', po_id.id),
+ ('move_line_id', '=', move_line_receivable_ids.id),
]
)
po_id.payment_line_ids -= p_line_id
@@ -157,20 +157,20 @@ def _remove_payment_order_line(self, _raise=True):
@api.multi
def action_invoice_cancel(self):
for record in self:
- if record.eval_state_cnab == "accepted":
+ if record.eval_state_cnab == 'accepted':
raise UserError(
_(
- "A fatura não pode ser cancelada pois já foi aprovada "
- "no Banco."
+ 'A fatura não pode ser cancelada pois já foi aprovada '
+ 'no Banco.'
)
)
- if record.eval_state_cnab == "done":
- raise UserError(_("Não é possível cancelar uma fatura finalizada."))
- if record.eval_state_cnab == "exported":
+ if record.eval_state_cnab == 'done':
+ raise UserError(_('Não é possível cancelar uma fatura finalizada.'))
+ if record.eval_state_cnab == 'exported':
raise UserError(
_(
- "A fatura não pode ser cancelada pois já foi exportada "
- "em uma remessa."
+ 'A fatura não pode ser cancelada pois já foi exportada '
+ 'em uma remessa.'
)
)
@@ -192,46 +192,46 @@ def _pos_action_move_create(self):
# inv.transaction_id = sequence
inv._compute_receivables()
for index, interval in enumerate(inv.move_line_receivable_ids):
- inv_number = inv.get_invoice_fiscal_number().split("/")[-1].zfill(8)
- numero_documento = inv_number + "/" + str(index + 1).zfill(2)
+ inv_number = inv.get_invoice_fiscal_number().split('/')[-1].zfill(8)
+ numero_documento = inv_number + '/' + str(index + 1).zfill(2)
# Verificar se é boleto para criar o numero
if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
sequence = inv.company_id.get_own_number_sequence()
elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
- sequence = numero_documento.replace("/", "")
+ sequence = numero_documento.replace('/', '')
elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
if not inv.payment_mode_id.own_number_sequence:
raise UserError(
_(
- "Favor acessar aba Cobrança da configuração"
- " do Modo de Pagamento e determinar o "
- "campo Sequência do Nosso Número."
+ 'Favor acessar aba Cobrança da configuração'
+ ' do Modo de Pagamento e determinar o '
+ 'campo Sequência do Nosso Número.'
)
)
sequence = inv.payment_mode_id.get_own_number_sequence()
else:
raise UserError(
_(
- "Favor acessar aba Cobrança da configuração da"
- " sua empresa para determinar o tipo de "
- "sequencia utilizada nas cobrancas"
+ 'Favor acessar aba Cobrança da configuração da'
+ ' sua empresa para determinar o tipo de '
+ 'sequencia utilizada nas cobrancas'
)
)
interval.transaction_ref = sequence
interval.nosso_numero = (
sequence if interval.payment_mode_id.generate_own_number
- else "0"
+ else '0'
)
interval.numero_documento = numero_documento
interval.identificacao_titulo_empresa = hex(interval.id).upper()
- instrucoes = ""
- if inv.eval_payment_mode_instrucoes:
- instrucoes = inv.eval_payment_mode_instrucoes + "\n"
- if inv.instrucoes:
- instrucoes += inv.instrucoes + "\n"
- interval.instrucoes = instrucoes
+ instructions = ''
+ if inv.eval_payment_mode_instructions:
+ instructions = inv.eval_payment_mode_instructions + '\n'
+ if inv.instructions:
+ instructions += inv.instructions + '\n'
+ interval.instructions = instructions
@api.multi
def action_move_create(self):
@@ -254,7 +254,7 @@ def create_account_payment_line_baixa(self):
if not applicable_lines:
raise UserError(
_(
- "No Payment Line created for invoice %s because "
+ 'No Payment Line created for invoice %s because '
"it's internal type isn't receivable or payable."
)
% inv.number
@@ -262,15 +262,15 @@ def create_account_payment_line_baixa(self):
payment_modes = applicable_lines.mapped('payment_mode_id')
if not payment_modes:
- raise UserError(_("No Payment Mode on invoice %s") % inv.number)
+ raise UserError(_('No Payment Mode on invoice %s') % inv.number)
result_payorder_ids = []
- apoo = self.env["account.payment.order"]
+ apoo = self.env['account.payment.order']
for payment_mode in payment_modes:
payorder = apoo.search(
[
- ("payment_mode_id", "=", payment_mode.id),
- ("state", "=", "draft"),
+ ('payment_mode_id', '=', payment_mode.id),
+ ('state', '=', 'draft'),
],
limit=1,
)
@@ -291,16 +291,16 @@ def create_account_payment_line_baixa(self):
if new_payorder:
inv.message_post(
body=_(
- "%d payment lines added to the new draft payment "
- "order %s which has been automatically created."
+ '%d payment lines added to the new draft payment '
+ 'order %s which has been automatically created.'
)
% (count, payorder.name)
)
else:
inv.message_post(
body=_(
- "%d payment lines added to the existing draft "
- "payment order %s."
+ '%d payment lines added to the existing draft '
+ 'payment order %s.'
)
% (count, payorder.name)
)
@@ -317,25 +317,25 @@ def invoice_validate(self):
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
- # if self.payment_term_id.payment_mode_selection == "cartao":
+ # if self.payment_term_id.payment_mode_selection == 'cartao':
# raise UserError(
# _(
- # "Não é possível adicionar pagamentos em uma fatura "
- # "parcelada no cartão de crédito"
+ # 'Não é possível adicionar pagamentos em uma fatura '
+ # 'parcelada no cartão de crédito'
# )
# )
- if self.eval_situacao_pagamento in ["paga", "liquidada", "baixa_liquidacao"]:
+ if self.eval_situacao_pagamento in ['paga', 'liquidada', 'baixa_liquidacao']:
raise UserError(
_(
- "Não é possível adicionar pagamentos em uma fatura que "
- "já está paga."
+ 'Não é possível adicionar pagamentos em uma fatura que '
+ 'já está paga.'
)
)
- if self.eval_state_cnab in ["accepted", "exported", "done"]:
+ if self.eval_state_cnab in ['accepted', 'exported', 'done']:
raise UserError(
_(
- "Não é possível adicionar pagamentos em uma fatura já "
- "exportada ou aceita no banco."
+ 'Não é possível adicionar pagamentos em uma fatura já '
+ 'exportada ou aceita no banco.'
)
)
return super().assign_outstanding_credit(credit_aml_id)
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index e30b7f481715..4ef9f7575ea1 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -16,7 +16,7 @@
class AccountPaymentLine(models.Model):
_inherit = 'account.payment.line'
- linha_digitavel = fields.Char(
+ digitable_line = fields.Char(
string='Linha Digitável',
)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 65dc5a6e1154..58e19b9c01f7 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -25,7 +25,7 @@ class AccountPaymentMode(models.Model):
string='Sequência',
)
- instrucoes = fields.Text(
+ instructions = fields.Text(
string='Instruções de cobrança',
)
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 9998d80b2d3c..4372be9a84e9 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -14,7 +14,7 @@
-
+
@@ -66,8 +66,8 @@
-
+
+
From dcf21a06f3b268d856e74f0d0e803863ccc49c29 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 15:41:44 -0300
Subject: [PATCH 264/612] [MIG][FIX] Created field to inform Boleto Discount in
the Payment Mode.
---
l10n_br_account_payment_order/models/account_payment_mode.py | 3 +++
l10n_br_account_payment_order/views/account_payment_mode.xml | 1 +
2 files changed, 4 insertions(+)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 58e19b9c01f7..c7e7b49e3de8 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -242,6 +242,9 @@ class AccountPaymentMode(models.Model):
string='Percentual de Multa',
digits=dp.get_precision('Account'),
)
+ boleto_discount_perc = fields.Float(
+ string=u"Percentual de Desconto até a Data de Vencimento",
+ digits=dp.get_precision('Account'))
_sql_constraints = [(
"internal_sequence_id_unique",
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 4372be9a84e9..9063736a6ca0 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -49,6 +49,7 @@
+
From c26f0480360a1140a07c584bf4a2a587b7492207 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 16:06:03 -0300
Subject: [PATCH 265/612] [MIG][IMP] Created fields to inform Discount, Rebate
and Fee/Interest accounting for Boletos.
---
.../models/account_payment_mode.py | 25 ++++++++++++++++++-
.../views/account_payment_mode.xml | 3 +++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index c7e7b49e3de8..7a6724143087 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -231,6 +231,15 @@ class AccountPaymentMode(models.Model):
digits=dp.get_precision('Account'),
)
+ # TODO - criar outro campo para separar a Conta Contabil de Multa ?
+ # o valor vem somado ao Juros Mora no retorno do cnab 400 unicred,
+ # isso seria o padrão dos outros bancos ?
+ interest_fee_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Contabil de Juros Mora e Multa',
+ help='Conta padrão para Juros Mora',
+ )
+
boleto_fee_code = fields.Char(
string='Código da Multa',
size=1,
@@ -242,9 +251,23 @@ class AccountPaymentMode(models.Model):
string='Percentual de Multa',
digits=dp.get_precision('Account'),
)
+
boleto_discount_perc = fields.Float(
string=u"Percentual de Desconto até a Data de Vencimento",
- digits=dp.get_precision('Account'))
+ digits=dp.get_precision('Account')
+ )
+
+ discount_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Contabil de Desconto',
+ help='Conta padrão para Desconto',
+ )
+
+ rebate_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Contabil de Abatimanto',
+ help='Conta padrão para Abatimento',
+ )
_sql_constraints = [(
"internal_sequence_id_unique",
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 9063736a6ca0..e88df910573f 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -69,6 +69,9 @@
+
+
+
From 33be2fa08d7e6d0d4e466ce1113cb8ea4051b2a9 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 16:13:48 -0300
Subject: [PATCH 266/612] [MIG][FIX] Validate discount percent.
---
.../models/account_payment_mode.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 7a6724143087..e196f04a13a3 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -297,3 +297,11 @@ def _onchange_product_tax_id(self):
def get_own_number_sequence(self):
self.ensure_one()
return self.own_number_sequence.next_by_id()
+
+ @api.constrains('boleto_discount_perc')
+ def _check_discount_perc(self):
+ for record in self:
+ if record.boleto_discount_perc > 100 or\
+ record.boleto_discount_perc < 0:
+ raise ValidationError(
+ _('O percentual deve ser um valor entre 0 a 100.'))
From 54a69005495bc4468f52681280b4e176adedff6b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 16:15:28 -0300
Subject: [PATCH 267/612] [MIG][REF] PEP8, single and double quotes.
---
.../models/account_move_line.py | 8 +-
.../models/account_payment_order.py | 4 +-
.../models/l10n_br_cnab.py | 458 +++++++++---------
3 files changed, 235 insertions(+), 235 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 76ffc2665088..4ba5046ec826 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -86,11 +86,11 @@ def _prepare_payment_line_vals(self, payment_order):
@api.multi
def create_payment_line_from_move_line(self, payment_order):
- '''
+ """
Altera estado do cnab para adicionado a ordem
:param payment_order:
:return:
- '''
+ """
cnab_state = 'added'
if self.invoice_id.state == 'paid':
cnab_state = 'added_paid'
@@ -115,12 +115,12 @@ def _update_check(self):
@api.multi
def write(self, values):
- '''
+ """
Sobrescrita do método Write. Não deve ser possível voltar o cnab_state
ou a situacao_pagamento para um estado anterior
:param values:
:return:
- '''
+ """
for record in self:
cnab_state = values.get('cnab_state')
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 3e519f9778c4..51e631d673fa 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -89,10 +89,10 @@ class AccountPaymentOrder(models.Model):
)
def _confirm_debit_orders_api(self):
- '''
+ """
Method create to confirm all bank_api exclusive account.payment.order
:return:
- '''
+ """
_logger.info('_confirm_debit_orders_api()')
order_ids = self.search(
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
index 04500bc78581..737da00c4117 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab.py
@@ -17,97 +17,97 @@
_logger = logging.getLogger(__name__)
TIPO_OPERACAO = {
- "C": "Lançamento a Crédito",
- "D": "Lançamento a Débito",
- "E": "Extrato para Conciliação",
- "G": "Extrato para Gestão de Caixa",
- "I": "Informações de Títulos Capturados do Próprio Banco",
- "R": "Arquivo Remessa",
- "T": "Arquivo Retorno",
+ 'C': 'Lançamento a Crédito',
+ 'D': 'Lançamento a Débito',
+ 'E': 'Extrato para Conciliação',
+ 'G': 'Extrato para Gestão de Caixa',
+ 'I': 'Informações de Títulos Capturados do Próprio Banco',
+ 'R': 'Arquivo Remessa',
+ 'T': 'Arquivo Retorno',
}
TIPO_SERVICO = {
- "01": "Cobrança",
- "03": "Boleto de Pagamento Eletrônico",
- "04": "Conciliação Bancária",
- "05": "Débitos",
- "06": "Custódia de Cheques",
- "07": "Gestão de Caixa",
- "08": "Consulta/Informação Margem",
- "09": "Averbação da Consignação/Retenção",
- "10": "Pagamento Dividendos",
- "11": "Manutenção da Consignação",
- "12": "Consignação de Parcelas",
- "13": "Glosa da Consignação (INSS)",
- "14": "Consulta de Tributos a pagar",
- "20": "Pagamento Fornecedor",
- "22": "Pagamento de Contas, Tributos e Impostos",
- "23": "Interoperabilidade entre Contas de Instituições de Pagamentos",
- "25": "Compror",
- "26": "Compror Rotativo",
- "29": "Alegação do Pagador",
- "30": "Pagamento Salários",
- "32": "Pagamento de honorários",
- "33": "Pagamento de bolsa auxílio",
- "34": "Pagamento de prebenda (remuneração a padres e sacerdotes)",
- "40": "Vendor",
- "41": "Vendor a Termo",
- "50": "Pagamento Sinistros Segurados",
- "60": "Pagamento Despesas Viajante em Trânsito",
- "70": "Pagamento Autorizado",
- "75": "Pagamento Credenciados",
- "77": "Pagamento de Remuneração",
- "80": "Pagamento Representantes / Vendedores Autorizados",
- "90": "Pagamento Benefícios",
- "98": "Pagamentos Diversos",
+ '01': 'Cobrança',
+ '03': 'Boleto de Pagamento Eletrônico',
+ '04': 'Conciliação Bancária',
+ '05': 'Débitos',
+ '06': 'Custódia de Cheques',
+ '07': 'Gestão de Caixa',
+ '08': 'Consulta/Informação Margem',
+ '09': 'Averbação da Consignação/Retenção',
+ '10': 'Pagamento Dividendos',
+ '11': 'Manutenção da Consignação',
+ '12': 'Consignação de Parcelas',
+ '13': 'Glosa da Consignação (INSS)',
+ '14': 'Consulta de Tributos a pagar',
+ '20': 'Pagamento Fornecedor',
+ '22': 'Pagamento de Contas, Tributos e Impostos',
+ '23': 'Interoperabilidade entre Contas de Instituições de Pagamentos',
+ '25': 'Compror',
+ '26': 'Compror Rotativo',
+ '29': 'Alegação do Pagador',
+ '30': 'Pagamento Salários',
+ '32': 'Pagamento de honorários',
+ '33': 'Pagamento de bolsa auxílio',
+ '34': 'Pagamento de prebenda (remuneração a padres e sacerdotes)',
+ '40': 'Vendor',
+ '41': 'Vendor a Termo',
+ '50': 'Pagamento Sinistros Segurados',
+ '60': 'Pagamento Despesas Viajante em Trânsito',
+ '70': 'Pagamento Autorizado',
+ '75': 'Pagamento Credenciados',
+ '77': 'Pagamento de Remuneração',
+ '80': 'Pagamento Representantes / Vendedores Autorizados',
+ '90': 'Pagamento Benefícios',
+ '98': 'Pagamentos Diversos',
}
TIPO_INSCRICAO_EMPRESA = {
- 0: "Isento / Não informado",
- 1: "CPF",
- 2: "CGC / CNPJ",
- 3: "PIS / PASEP",
- 9: "Outros",
+ 0: 'Isento / Não informado',
+ 1: 'CPF',
+ 2: 'CGC / CNPJ',
+ 3: 'PIS / PASEP',
+ 9: 'Outros',
}
class L10nBrHrCnab(models.Model):
- _name = "l10n_br.cnab"
+ _name = 'l10n_br.cnab'
_description = 'l10n_br CNAB'
- display_name = fields.Char(compute="_compute_display_name", store=True, index=True)
+ display_name = fields.Char(compute='_compute_display_name', store=True, index=True)
- return_file = fields.Binary(string="Arquivo Retorno")
- filename = fields.Char(string="Filename")
+ return_file = fields.Binary(string='Arquivo Retorno')
+ filename = fields.Char(string='Filename')
bank_account_id = fields.Many2one(
- string="Conta cedente", comodel_name="res.partner.bank"
+ string='Conta cedente', comodel_name='res.partner.bank'
)
cnab_date = fields.Date(
- string="Data CNAB", required=True, default=datetime.now().date())
- date_file = fields.Date(string="Data Criação no Banco")
- sequential_file = fields.Char(string="Sequencial do Arquivo")
- reason_error = fields.Char(string="Motivo do Erro")
+ string='Data CNAB', required=True, default=datetime.now().date())
+ date_file = fields.Date(string='Data Criação no Banco')
+ sequential_file = fields.Char(string='Sequencial do Arquivo')
+ reason_error = fields.Char(string='Motivo do Erro')
lot_id = fields.One2many(
- string="Lotes", comodel_name="l10n_br.cnab.lote", inverse_name="cnab_id"
+ string='Lotes', comodel_name='l10n_br.cnab.lote', inverse_name='cnab_id'
)
- name = fields.Char(string="Name")
- number_events = fields.Integer(string="Número de Eventos")
- number_lots = fields.Integer(string="Número de Lotes")
- state = fields.Selection(string="Estágio", selection=STATE_CNAB, default="draft")
+ name = fields.Char(string='Name')
+ number_events = fields.Integer(string='Número de Eventos')
+ number_lots = fields.Integer(string='Número de Lotes')
+ state = fields.Selection(string='Estágio', selection=STATE_CNAB, default='draft')
@api.one
- @api.depends("name")
+ @api.depends('name')
def _compute_display_name(self):
self.display_name = self.name
def _busca_conta(self, banco, agencia, conta):
return (
- self.env["res.partner.bank"]
+ self.env['res.partner.bank']
.search(
[
# ('acc_number', '=', str(banco)),
- ("bra_number", "=", str(agencia)),
- ("acc_number", "=", str(conta)),
+ ('bra_number', '=', str(agencia)),
+ ('acc_number', '=', str(conta)),
]
)
.id
@@ -125,67 +125,67 @@ def _cria_lote(self, header, lote, evento, trailer):
lote_bank_account_id = self.bank_account_id
vals = {
- "account_bank_id": lote_bank_account_id.id,
- "servico_operacao": header.literal_retorno,
- "tipo_servico": header.literal_servico,
- "qtd_registros": trailer.totais_quantidade_registros,
- "total_valores": float(trailer.valor_total_titulos) / 100,
- "cnab_id": self.id,
+ 'account_bank_id': lote_bank_account_id.id,
+ 'servico_operacao': header.literal_retorno,
+ 'tipo_servico': header.literal_servico,
+ 'qtd_registros': trailer.totais_quantidade_registros,
+ 'total_valores': float(trailer.valor_total_titulos) / 100,
+ 'cnab_id': self.id,
}
- lote_id = self.env["l10n_br.cnab.lote"].create(vals)
+ lote_id = self.env['l10n_br.cnab.lote'].create(vals)
return lote_id, lote_bank_account_id
def _lote_400(self, evento, lote_id):
- bank_payment_line_id = self.env["bank.payment.line"].search(
- [("nosso_numero", "=", evento.nosso_numero)], limit=1
+ bank_payment_line_id = self.env['bank.payment.line'].search(
+ [('nosso_numero', '=', evento.nosso_numero)], limit=1
)
vals_evento = {
- "bank_payment_line_id": bank_payment_line_id.id,
- "data_ocorrencia": datetime.strptime(
+ 'bank_payment_line_id': bank_payment_line_id.id,
+ 'data_ocorrencia': datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_ocorrencia
- else "",
- "data_real_pagamento": datetime.strptime(
+ else '',
+ 'data_real_pagamento': datetime.strptime(
str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_credito
- else "",
- "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
- "invoice_id": bank_payment_line_id.payment_line_ids[
+ else '',
+ 'identificacao_titulo_empresa': evento.identificacao_titulo_empresa,
+ 'invoice_id': bank_payment_line_id.payment_line_ids[
:1
].move_line_id.invoice_id.id,
- "juros_mora_multa": float(evento.juros_mora_multa) / 100,
- "lote_id": lote_id.id,
- "nosso_numero": str(evento.nosso_numero),
- "ocorrencias": CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
- "outros_creditos": float(evento.outros_creditos) / 100,
- "partner_id": bank_payment_line_id.partner_id.id,
- "seu_numero": evento.numero_documento,
- "str_motiv_a": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
+ 'juros_mora_multa': float(evento.juros_mora_multa) / 100,
+ 'lote_id': lote_id.id,
+ 'nosso_numero': str(evento.nosso_numero),
+ 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'outros_creditos': float(evento.outros_creditos) / 100,
+ 'partner_id': bank_payment_line_id.partner_id.id,
+ 'seu_numero': evento.numero_documento,
+ 'str_motiv_a': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
if evento.erros[0:2]
- else "",
- "str_motiv_b": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
+ else '',
+ 'str_motiv_b': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
if evento.erros[2:4]
- else "",
- "str_motiv_c": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
+ else '',
+ 'str_motiv_c': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
if evento.erros[4:6]
- else "",
- "str_motiv_d": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
+ else '',
+ 'str_motiv_d': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8]
- else "",
- "tarifa_cobranca": float(evento.tarifa_cobranca),
- "valor": float(evento.valor) / 100,
- "valor_abatimento": float(evento.valor_abatimento) / 100,
- "valor_desconto": float(evento.valor_desconto) / 100,
- "valor_iof": float(evento.valor_iof) / 100,
- "valor_pagamento": evento.valor_principal,
+ else '',
+ 'tarifa_cobranca': float(evento.tarifa_cobranca),
+ 'valor': float(evento.valor) / 100,
+ 'valor_abatimento': float(evento.valor_abatimento) / 100,
+ 'valor_desconto': float(evento.valor_desconto) / 100,
+ 'valor_iof': float(evento.valor_iof) / 100,
+ 'valor_pagamento': evento.valor_principal,
}
- cnab_event_id = self.env["l10n_br.cnab.evento"].create(vals_evento)
+ cnab_event_id = self.env['l10n_br.cnab.evento'].create(vals_evento)
amount = 0.0
line_values = []
@@ -195,23 +195,23 @@ def _lote_400(self, evento, lote_id):
cnab_state = False
bank_state = False
if codigo_ocorrencia in RETORNO_400_CONFIRMADA:
- cnab_state = "accepted"
- bank_state = "aberta"
+ cnab_state = 'accepted'
+ bank_state = 'aberta'
elif codigo_ocorrencia in RETORNO_400_REJEITADA:
- cnab_state = "not_accepted"
- bank_state = "inicial"
+ cnab_state = 'not_accepted'
+ bank_state = 'inicial'
elif codigo_ocorrencia in RETORNO_400_LIQUIDACAO:
- cnab_state = "accepted"
- bank_state = "liquidada"
+ cnab_state = 'accepted'
+ bank_state = 'liquidada'
elif codigo_ocorrencia in RETORNO_400_BAIXA:
- cnab_state = "accepted"
+ cnab_state = 'accepted'
if codigo_ocorrencia == 9:
- bank_state = "baixa"
+ bank_state = 'baixa'
else:
- bank_state = "baixa_liquidacao"
+ bank_state = 'baixa_liquidacao'
else:
cnab_event_id.str_motiv_e = (
- str(codigo_ocorrencia) + ": Ocorrência não tratada"
+ str(codigo_ocorrencia) + ': Ocorrência não tratada'
)
if cnab_state:
@@ -224,29 +224,29 @@ def _lote_400(self, evento, lote_id):
move_line = pay_order_line_id.move_line_id
invoice = move_line.invoice_id
payment_mode = invoice.payment_mode_id
- if bank_state == "liquidada" and invoice.state == "open":
+ if bank_state == 'liquidada' and invoice.state == 'open':
line_dict = {
- "name": evento.nosso_numero,
- "nosso_numero": evento.nosso_numero,
- "numero_documento": evento.numero_documento,
- "identificacao_titulo_empresa":
+ 'name': evento.nosso_numero,
+ 'nosso_numero': evento.nosso_numero,
+ 'numero_documento': evento.numero_documento,
+ 'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
- "credit": float(evento.valor_principal)
+ 'credit': float(evento.valor_principal)
+ float(evento.tarifa_cobranca),
- "account_id": payment_mode.default_account_id.id
+ 'account_id': payment_mode.default_account_id.id
or invoice.account_id.id,
- "journal_id": bank_payment_line_id.order_id.journal_id.id,
- "date_maturity": datetime.strptime(
+ 'journal_id': bank_payment_line_id.order_id.journal_id.id,
+ 'date_maturity': datetime.strptime(
str(evento.data_vencimento).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_vencimento
- else "",
- "date": datetime.strptime(
+ else '',
+ 'date': datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_ocorrencia
- else "",
- "partner_id": bank_payment_line_id.partner_id.id,
+ else '',
+ 'partner_id': bank_payment_line_id.partner_id.id,
}
line_values.append((0, 0, line_dict))
@@ -262,10 +262,10 @@ def _lote_400(self, evento, lote_id):
line_dict_tarifa = dict(line_dict)
line_dict_tarifa.update(
{
- "name": str(evento.nosso_numero) + " - Tarifa",
- "credit": 0,
- "debit": float(evento.tarifa_cobranca),
- "account_id":
+ 'name': str(evento.nosso_numero) + ' - Tarifa',
+ 'credit': 0,
+ 'debit': float(evento.tarifa_cobranca),
+ 'account_id':
payment_mode.default_tax_account_id.id
or invoice.account_id.id,
}
@@ -294,27 +294,27 @@ def _lote_400(self, evento, lote_id):
def _lote_240(self, evento, lote_id):
data_evento = str(evento.credito_data_real)
data_evento = fields.Date.from_string(
- data_evento[4:] + "-" + data_evento[2:4] + "-" + data_evento[0:2]
+ data_evento[4:] + '-' + data_evento[2:4] + '-' + data_evento[0:2]
)
- lote_bank_account_id = self.env["res.partner.bank"].search(
+ lote_bank_account_id = self.env['res.partner.bank'].search(
[
- ("bra_number", "=", evento.favorecido_agencia),
- ("bra_number_dig", "=", evento.favorecido_agencia_dv),
- ("acc_number", "=", evento.favorecido_conta),
- ("acc_number_dig", "=", evento.favorecido_conta_dv),
+ ('bra_number', '=', evento.favorecido_agencia),
+ ('bra_number_dig', '=', evento.favorecido_agencia_dv),
+ ('acc_number', '=', evento.favorecido_conta),
+ ('acc_number_dig', '=', evento.favorecido_conta_dv),
]
)
lote_bank_account_id = (
lote_bank_account_id.ids[0] if lote_bank_account_id else False
)
- favorecido_partner = self.env["res.partner.bank"].search(
- [("owner_name", "ilike", evento.favorecido_nome)]
+ favorecido_partner = self.env['res.partner.bank'].search(
+ [('owner_name', 'ilike', evento.favorecido_nome)]
)
favorecido_partner = (
favorecido_partner[0].partner_id.id if favorecido_partner else False
)
- bank_payment_line_id = self.env["bank.payment.line"].search(
- [("name", "=", evento.credito_seu_numero)]
+ bank_payment_line_id = self.env['bank.payment.line'].search(
+ [('name', '=', evento.credito_seu_numero)]
)
ocorrencias_dic = dict(CODIGO_OCORRENCIAS)
ocorrencias = [
@@ -325,106 +325,106 @@ def _lote_240(self, evento, lote_id):
evento.ocorrencias[8:10],
]
vals_evento = {
- "data_real_pagamento": data_evento,
- "segmento": evento.servico_segmento,
- "favorecido_nome": favorecido_partner,
- "favorecido_conta_bancaria": lote_bank_account_id,
- "nosso_numero": str(evento.credito_nosso_numero),
- "seu_numero": evento.credito_seu_numero,
- "tipo_moeda": evento.credito_moeda_tipo,
- "valor_pagamento": evento.credito_valor_pagamento,
- "ocorrencias": evento.ocorrencias,
- "str_motiv_a": ocorrencias_dic[ocorrencias[0]] if ocorrencias[0] else "",
- "str_motiv_b": ocorrencias_dic[ocorrencias[1]] if ocorrencias[1] else "",
- "str_motiv_c": ocorrencias_dic[ocorrencias[2]] if ocorrencias[2] else "",
- "str_motiv_d": ocorrencias_dic[ocorrencias[3]] if ocorrencias[3] else "",
- "str_motiv_e": ocorrencias_dic[ocorrencias[4]] if ocorrencias[4] else "",
- "lote_id": lote_id.id,
- "bank_payment_line_id": bank_payment_line_id.id,
+ 'data_real_pagamento': data_evento,
+ 'segmento': evento.servico_segmento,
+ 'favorecido_nome': favorecido_partner,
+ 'favorecido_conta_bancaria': lote_bank_account_id,
+ 'nosso_numero': str(evento.credito_nosso_numero),
+ 'seu_numero': evento.credito_seu_numero,
+ 'tipo_moeda': evento.credito_moeda_tipo,
+ 'valor_pagamento': evento.credito_valor_pagamento,
+ 'ocorrencias': evento.ocorrencias,
+ 'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if ocorrencias[0] else '',
+ 'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if ocorrencias[1] else '',
+ 'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if ocorrencias[2] else '',
+ 'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if ocorrencias[3] else '',
+ 'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if ocorrencias[4] else '',
+ 'lote_id': lote_id.id,
+ 'bank_payment_line_id': bank_payment_line_id.id,
}
- self.env["l10n_br.cnab.evento"].create(vals_evento)
+ self.env['l10n_br.cnab.evento'].create(vals_evento)
if evento.ocorrencias and bank_payment_line_id:
- if "00" in ocorrencias:
- bank_state = "paid"
- cnab_state = "accepted"
+ if '00' in ocorrencias:
+ bank_state = 'paid'
+ cnab_state = 'accepted'
else:
- bank_state = "exception"
- cnab_state = "not_accepted"
+ bank_state = 'exception'
+ cnab_state = 'not_accepted'
bank_payment_line_id.state2 = bank_state
for payment_line in bank_payment_line_id.payment_line_ids:
payment_line.move_line_id.state_cnab = cnab_state
def _reprocessa_lote_240(self, evento, lote_id):
- raise NotImplementedError("FALTA FAZER")
+ raise NotImplementedError('FALTA FAZER')
def _reprocessa_lote_400(self, evento, lote_id):
- bank_payment_line_id = self.env["bank.payment.line"].search(
+ bank_payment_line_id = self.env['bank.payment.line'].search(
[
(
- "identificacao_titulo_empresa",
- "=",
+ 'identificacao_titulo_empresa',
+ '=',
evento.identificacao_titulo_empresa,
)
],
limit=1,
)
- cnab_event_id = self.env["l10n_br.cnab.evento"].search(
+ cnab_event_id = self.env['l10n_br.cnab.evento'].search(
[
- ("lote_id", "=", lote_id.id),
- ("bank_payment_line_id", "!=", False),
- ("bank_payment_line_id", "=", bank_payment_line_id.id),
+ ('lote_id', '=', lote_id.id),
+ ('bank_payment_line_id', '!=', False),
+ ('bank_payment_line_id', '=', bank_payment_line_id.id),
]
)
vals_evento = {
- "bank_payment_line_id": cnab_event_id.bank_payment_line_id.id
+ 'bank_payment_line_id': cnab_event_id.bank_payment_line_id.id
or bank_payment_line_id.id,
- "data_ocorrencia": datetime.strptime(
+ 'data_ocorrencia': datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_ocorrencia
- else "",
- "data_real_pagamento": datetime.strptime(
+ else '',
+ 'data_real_pagamento': datetime.strptime(
str(evento.data_credito).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_credito
- else "",
- "identificacao_titulo_empresa": evento.identificacao_titulo_empresa,
- "invoice_id": cnab_event_id.invoice_id.id
+ else '',
+ 'identificacao_titulo_empresa': evento.identificacao_titulo_empresa,
+ 'invoice_id': cnab_event_id.invoice_id.id
or bank_payment_line_id.payment_line_ids[:1].move_line_id.invoice_id.id,
- "juros_mora_multa": cnab_event_id.juros_mora_multa
+ 'juros_mora_multa': cnab_event_id.juros_mora_multa
or float(evento.juros_mora_multa) / 100,
- "lote_id": cnab_event_id.lote_id.id or lote_id.id,
- "nosso_numero": str(evento.nosso_numero),
- "ocorrencias": CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
- "outros_creditos": cnab_event_id.outros_creditos
+ 'lote_id': cnab_event_id.lote_id.id or lote_id.id,
+ 'nosso_numero': str(evento.nosso_numero),
+ 'ocorrencias': CODIGO_OCORRENCIAS_CNAB200[evento.codigo_ocorrencia],
+ 'outros_creditos': cnab_event_id.outros_creditos
or float(evento.outros_creditos) / 100,
- "partner_id": bank_payment_line_id.partner_id.id,
- "seu_numero": evento.numero_documento,
- "str_motiv_a": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
+ 'partner_id': bank_payment_line_id.partner_id.id,
+ 'seu_numero': evento.numero_documento,
+ 'str_motiv_a': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[0:2]))
if evento.erros[0:2]
- else "",
- "str_motiv_b": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
+ else '',
+ 'str_motiv_b': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[2:4]))
if evento.erros[2:4]
- else "",
- "str_motiv_c": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
+ else '',
+ 'str_motiv_c': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[4:6]))
if evento.erros[4:6]
- else "",
- "str_motiv_d": COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
+ else '',
+ 'str_motiv_d': COD_REGISTROS_REJEITADOS_CNAB400.get(int(evento.erros[6:8]))
if evento.erros[6:8]
- else "",
- "tarifa_cobranca": cnab_event_id.tarifa_cobranca
+ else '',
+ 'tarifa_cobranca': cnab_event_id.tarifa_cobranca
or float(evento.tarifa_cobranca),
- "valor": cnab_event_id.valor or float(evento.valor) / 100,
- "valor_abatimento": cnab_event_id.valor_abatimento
+ 'valor': cnab_event_id.valor or float(evento.valor) / 100,
+ 'valor_abatimento': cnab_event_id.valor_abatimento
or float(evento.valor_abatimento) / 100,
- "valor_desconto": cnab_event_id.valor_desconto
+ 'valor_desconto': cnab_event_id.valor_desconto
or float(evento.valor_desconto) / 100,
- "valor_iof": cnab_event_id.valor_iof or float(evento.valor_iof) / 100,
- "valor_pagamento": cnab_event_id.valor_pagamento or evento.valor_principal,
+ 'valor_iof': cnab_event_id.valor_iof or float(evento.valor_iof) / 100,
+ 'valor_pagamento': cnab_event_id.valor_pagamento or evento.valor_principal,
}
if not cnab_event_id:
@@ -437,7 +437,7 @@ def _reprocessa_lote_400(self, evento, lote_id):
if not any(codigo_ocorrencia in x for x in RETORNOS_TRATADOS):
cnab_event_id.str_motiv_e = (
- str(codigo_ocorrencia) + ": Ocorrência não tratada"
+ str(codigo_ocorrencia) + ': Ocorrência não tratada'
)
bank_payment_line_id.nosso_numero = str(evento.nosso_numero)
@@ -445,12 +445,12 @@ def _reprocessa_lote_400(self, evento, lote_id):
pay_order_line_id.move_line_id.nosso_numero = str(evento.nosso_numero)
pay_order_line_id.nosso_numero = str(evento.nosso_numero)
debit_move_line = pay_order_line_id.move_line_id
- credit_move_line = self.env["account.move.line"].search(
+ credit_move_line = self.env['account.move.line'].search(
[
- "|",
- ("nosso_numero", "=", evento.nosso_numero),
- ("name", "=", evento.nosso_numero),
- ("credit", ">", 0),
+ '|',
+ ('nosso_numero', '=', evento.nosso_numero),
+ ('name', '=', evento.nosso_numero),
+ ('credit', '>', 0),
]
)
@@ -463,43 +463,43 @@ def _reprocessa_lote_400(self, evento, lote_id):
if not credit_move_line:
return
# raise UserError(
- # "Não foi encontrada uma linha correspondente para a "
- # "linha de nosso_numero: %s" % evento.nosso_numero)
+ # 'Não foi encontrada uma linha correspondente para a '
+ # 'linha de nosso_numero: %s' % evento.nosso_numero)
line_values = {
- "name": evento.nosso_numero,
- "nosso_numero": evento.nosso_numero,
- "numero_documento": evento.numero_documento,
- "identificacao_titulo_empresa":
+ 'name': evento.nosso_numero,
+ 'nosso_numero': evento.nosso_numero,
+ 'numero_documento': evento.numero_documento,
+ 'identificacao_titulo_empresa':
evento.identificacao_titulo_empresa,
- "date_maturity": datetime.strptime(
+ 'date_maturity': datetime.strptime(
str(evento.data_vencimento).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_vencimento
- else "",
- "date": datetime.strptime(
+ else '',
+ 'date': datetime.strptime(
str(evento.data_ocorrencia).zfill(6), STR_EVENTO_FORMAT
)
if evento.data_ocorrencia
- else "",
+ else '',
}
credit_move_line.with_context(reprocessing=True).write(line_values)
@api.model
def processar_retorno_multi(self):
- active_ids = self._context.get("active_ids")
+ active_ids = self._context.get('active_ids')
for cnab_id in self.browse(active_ids):
- if cnab_id.state in ["draft"]:
+ if cnab_id.state in ['draft']:
cnab_id.processar_arquivo_retorno()
@api.model
def reprocessar_retorno_multi(self):
- active_ids = self._context.get("active_ids")
+ active_ids = self._context.get('active_ids')
for cnab_id in self.browse(active_ids):
- if cnab_id.state in ["done"]:
+ if cnab_id.state in ['done']:
cnab_id.reprocessar_arquivo_retorno()
def reprocessar_arquivo_retorno(self):
@@ -509,41 +509,41 @@ def processar_arquivo_retorno(self):
raise NotImplementedError
def _get_name(self, data, filename):
- cnab_ids = self.search([("data", "=", data)], order="id desc")
+ cnab_ids = self.search([('data', '=', data)], order='id desc')
cnab_idx = 1
if cnab_ids:
search_result = list(
filter(
lambda x: x is not None,
[
- re.search(r"\((\d)\)", name)
+ re.search(r'\((\d)\)', name)
for name in self.search(
- [("data", "=", data), ("id", "!=", self.id)],
- order="id desc",
- ).mapped("name")
+ [('data', '=', data), ('id', '!=', self.id)],
+ order='id desc',
+ ).mapped('name')
],
)
)
if search_result:
cnab_idx = max(int(result.group(1)) for result in search_result) + 1
- cnab_name = "{}({}){}".format(
- data, cnab_idx, " - " + filename if filename else ""
+ cnab_name = '{}({}){}'.format(
+ data, cnab_idx, ' - ' + filename if filename else ''
)
return cnab_name
@api.multi
def write(self, vals):
- if any(v in vals for v in ["data", "filename"]):
- data = vals.get("data") or self.data
- filename = vals.get("filename") or self.filename
+ if any(v in vals for v in ['data', 'filename']):
+ data = vals.get('data') or self.data
+ filename = vals.get('filename') or self.filename
name = self._get_name(data, filename)
- vals.update({"name": name})
+ vals.update({'name': name})
return super(L10nBrHrCnab, self).write(vals)
@api.model
def create(self, vals):
- name = self._get_name(vals.get("data"), vals.get("filename"))
- vals.update({"name": name})
+ name = self._get_name(vals.get('data'), vals.get('filename'))
+ vals.update({'name': name})
return super(L10nBrHrCnab, self).create(vals)
From 6ddde2fc05ef0434b075efb8b27b99bc1f3355aa Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 16:22:00 -0300
Subject: [PATCH 268/612] [MIG][REF] Field refer to 'Codigo Beneficiario' are
informed in payment mode.
---
.../models/__init__.py | 1 -
.../models/res_partner_bank.py | 18 ------------------
2 files changed, 19 deletions(-)
delete mode 100644 l10n_br_account_payment_order/models/res_partner_bank.py
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 294ec9ed6c56..8532f3b8c04e 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -10,7 +10,6 @@
from . import account_payment_order
from . import account_payment_line
from . import account_payment
-from . import res_partner_bank
from . import bank_payment_line
from . import l10n_br_cnab
from . import l10n_br_cnab_evento
diff --git a/l10n_br_account_payment_order/models/res_partner_bank.py b/l10n_br_account_payment_order/models/res_partner_bank.py
deleted file mode 100644
index 9cf868f73429..000000000000
--- a/l10n_br_account_payment_order/models/res_partner_bank.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2012 KMEE - Fernando Marcato Rodrigues
-# Copyright 2017 KMEE - Hendrix Costa
-# @ 2018 Akretion - www.akretion.com.br
-# Magno Costa
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-
-from odoo import fields, models
-
-
-class ResPartnerBank(models.Model):
- _inherit = 'res.partner.bank'
-
- codigo_da_empresa = fields.Integer(
- string='Código da empresa',
- size=20,
- help="Será informado pelo banco depois do cadastro do beneficiário "
- "na agência",
- )
From 84e957678e307d6c41a5c227b306601502d2c5e0 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 17:34:01 -0300
Subject: [PATCH 269/612] [MIG][FIX] Methods after change name fields.
---
l10n_br_account_payment_order/models/account_invoice.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index b09b7ad61546..5c8147c6305d 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -220,12 +220,12 @@ def _pos_action_move_create(self):
)
interval.transaction_ref = sequence
- interval.nosso_numero = (
+ interval.own_number = (
sequence if interval.payment_mode_id.generate_own_number
else '0'
)
- interval.numero_documento = numero_documento
- interval.identificacao_titulo_empresa = hex(interval.id).upper()
+ interval.document_number = numero_documento
+ interval.company_title_identification = hex(interval.id).upper()
instructions = ''
if inv.eval_payment_mode_instructions:
instructions = inv.eval_payment_mode_instructions + '\n'
From 7ce5ea04d6a6235097441b8a14014a0e5527a354 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 17:56:45 -0300
Subject: [PATCH 270/612] [MIG][REF] Removed unnecessary constant.
---
l10n_br_account_payment_order/constants.py | 5 ----
.../models/account_invoice.py | 15 +++++-------
.../models/res_company.py | 24 +++++++------------
3 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/l10n_br_account_payment_order/constants.py b/l10n_br_account_payment_order/constants.py
index 2032176f79c4..69060eae3345 100644
--- a/l10n_br_account_payment_order/constants.py
+++ b/l10n_br_account_payment_order/constants.py
@@ -2,11 +2,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-SEQUENCIAL_EMPRESA = "0"
-SEQUENCIAL_FATURA = "1"
-SEQUENCIAL_CARTEIRA = "2"
-
-
COBRANCA = "01"
BOLETO_PAGAMENTO_ELETRONICO = "03"
CONCILIACAO_BANCARIA = "04"
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 5c8147c6305d..38ea45647d18 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -6,12 +6,6 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
-from ..constants import (
- SEQUENCIAL_CARTEIRA,
- SEQUENCIAL_EMPRESA,
- SEQUENCIAL_FATURA,
-)
-
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
@@ -196,11 +190,14 @@ def _pos_action_move_create(self):
numero_documento = inv_number + '/' + str(index + 1).zfill(2)
# Verificar se é boleto para criar o numero
- if inv.company_id.own_number_type == SEQUENCIAL_EMPRESA:
+ if inv.company_id.own_number_type == '0':
+ # SEQUENCIAL_EMPRESA
sequence = inv.company_id.get_own_number_sequence()
- elif inv.company_id.own_number_type == SEQUENCIAL_FATURA:
+ elif inv.company_id.own_number_type == '1':
+ # SEQUENCIAL_FATURA
sequence = numero_documento.replace('/', '')
- elif inv.company_id.own_number_type == SEQUENCIAL_CARTEIRA:
+ elif inv.company_id.own_number_type == '2':
+ # SEQUENCIAL_CARTEIRA
if not inv.payment_mode_id.own_number_sequence:
raise UserError(
_(
diff --git a/l10n_br_account_payment_order/models/res_company.py b/l10n_br_account_payment_order/models/res_company.py
index 85b284af71b5..397b58543272 100644
--- a/l10n_br_account_payment_order/models/res_company.py
+++ b/l10n_br_account_payment_order/models/res_company.py
@@ -4,34 +4,28 @@
from odoo import api, fields, models
-from ..constants import (
- SEQUENCIAL_CARTEIRA,
- SEQUENCIAL_EMPRESA,
- SEQUENCIAL_FATURA,
-)
-
class ResCompany(models.Model):
_inherit = 'res.company'
own_number_type = fields.Selection(
selection=[
- (SEQUENCIAL_EMPRESA, "Sequêncial único por empresa"),
- (SEQUENCIAL_FATURA, "Numero sequêncial da Fatura"),
- (SEQUENCIAL_CARTEIRA, "Sequêncial único por carteira"),
+ ('0', 'Sequêncial único por empresa'),
+ ('1', 'Numero sequêncial da Fatura'),
+ ('2', 'Sequêncial único por carteira'),
],
- string="Tipo de nosso número",
- default=SEQUENCIAL_FATURA,
+ string='Tipo de nosso número',
+ default='1',
)
own_number_sequence = fields.Many2one(
- comodel_name="ir.sequence", string="Sequência do Nosso Número"
+ comodel_name='ir.sequence', string='Sequência do Nosso Número'
)
environment = fields.Selection(
- string="Ambiente",
- selection=[("1", "HOMOLOGAÇÃO"), ("2", "PRODUÇÃO")],
- default="1",
+ string='Ambiente',
+ selection=[('1', 'HOMOLOGAÇÃO'), ('2', 'PRODUÇÃO')],
+ default='1',
)
@api.multi
From d510c938400fa09a911974da0a7507772bbe1380 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 20 Aug 2020 19:34:31 -0300
Subject: [PATCH 271/612] [MIG][FIX] Change name fields.
---
.../migrations/12.0.2.0.0/pre-migration.py | 1 +
l10n_br_account_payment_order/models/l10n_br_cnab.py | 4 ++--
l10n_br_account_payment_order/models/l10n_br_cnab_evento.py | 4 ++--
l10n_br_account_payment_order/models/l10n_br_cnab_lote.py | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index c08a2476651d..a27d1a1033ac 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -91,6 +91,7 @@
('valor_desconto', 'discount_value'),
('valor_iof', 'iof_value'),
('valor_pagamento', 'payment_value'),
+ ('lote_id', 'lot_id'),
],
'l10n_br.cnab.lote': [
('empresa_inscricao_numero', 'company_registration_number'),
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
index 737da00c4117..16bac80d02f5 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab.py
@@ -509,7 +509,7 @@ def processar_arquivo_retorno(self):
raise NotImplementedError
def _get_name(self, data, filename):
- cnab_ids = self.search([('data', '=', data)], order='id desc')
+ cnab_ids = self.search([('cnab_date', '=', data)], order='id desc')
cnab_idx = 1
if cnab_ids:
search_result = list(
@@ -518,7 +518,7 @@ def _get_name(self, data, filename):
[
re.search(r'\((\d)\)', name)
for name in self.search(
- [('data', '=', data), ('id', '!=', self.id)],
+ [('cnab_date', '=', data), ('id', '!=', self.id)],
order='id desc',
).mapped('name')
],
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
index 187395623f91..0d51320c41a3 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
@@ -30,7 +30,7 @@ class L10nBrCnabEvento(models.Model):
)
invoice_id = fields.Many2one(comodel_name='account.invoice', string='Fatura')
interest_fee_value = fields.Float(string='Juros de Mora/Multa')
- lote_id = fields.Many2one(
+ lot_id = fields.Many2one(
string='Lote', comodel_name='l10n_br.cnab.lote', ondelete='cascade'
)
own_number = fields.Char(string='Nosso Número')
@@ -40,7 +40,7 @@ class L10nBrCnabEvento(models.Model):
segment = fields.Char(string='Segmento')
your_number = fields.Char(string='Seu Número')
state = fields.Selection(
- string='State', related='lote_id.state', selection=STATE_CNAB, default='draft'
+ string='State', related='lot_id.state', selection=STATE_CNAB, default='draft'
)
str_motiv_a = fields.Char('Motivo da ocorrência 01')
str_motiv_b = fields.Char('Motivo de ocorrência 02')
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
index 7f88ac859d06..ce09e9929f62 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
@@ -24,7 +24,7 @@ class L10nBrCnabLote(models.Model):
company_registration_number = fields.Char(string='Número de Inscrição')
company_registration_type = fields.Char(string='Tipo de Inscrição')
event_id = fields.One2many(
- string='Eventos', comodel_name='l10n_br.cnab.evento', inverse_name='lote_id'
+ string='Eventos', comodel_name='l10n_br.cnab.evento', inverse_name='lot_id'
)
message = fields.Char(string='Mensagem')
register_qty = fields.Integer(string='Quantidade de Registros')
From 400b676125d02ab2e219f6c3dcbbaf330cb4f186 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 21 Aug 2020 13:00:39 -0300
Subject: [PATCH 272/612] [MIG][FIX] Process of canceling invoice.
---
.../models/account_invoice.py | 53 +++++--------------
1 file changed, 14 insertions(+), 39 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 38ea45647d18..28f8af6d368e 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -27,14 +27,6 @@ class AccountInvoice(models.Model):
string='Instruções de cobrança',
)
- # eval_state_cnab = fields.Selection(
- # string=u'Estado CNAB',
- # related='move_line_receivable_id.state_cnab',
- # readonly=True,
- # store=True,
- # index=True,
- # )
- #
# eval_situacao_pagamento = fields.Selection(
# string=u'Situação do Pagamento',
# related='move_line_receivable_id.situacao_pagamento',
@@ -122,9 +114,12 @@ def _onchange_payment_mode_id(self):
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_ids = self.move_line_receivable_ids
- payment_order_ids = self.env['account.payment.order'].search(
- [('payment_line_ids.move_line_id', 'in', [move_line_receivable_ids.id])]
- )
+ payment_order_ids = self.env['account.payment.order']
+
+ for line in move_line_receivable_ids:
+ payment_order_ids |= self.env['account.payment.order'].search(
+ [('payment_line_ids.move_line_id', 'in', [line.id])]
+ )
if payment_order_ids:
draft_cancel_payment_order_ids = payment_order_ids.filtered(
@@ -132,42 +127,22 @@ def _remove_payment_order_line(self, _raise=True):
)
if payment_order_ids - draft_cancel_payment_order_ids:
if _raise:
- raise UserError(
- _(
- 'A fatura não pode ser cancelada pois a mesma já se '
- 'encontra exportada por uma ordem de pagamento.'
- )
- )
+ raise UserError(_(
+ 'A fatura não pode ser cancelada pois a mesma já se '
+ 'encontra exportada por uma ordem de pagamento.'))
for po_id in draft_cancel_payment_order_ids:
- p_line_id = self.env['account.payment.line'].search(
- [
+ p_line_id = self.env['account.payment.line']
+ for line in move_line_receivable_ids:
+ p_line_id |= self.env['account.payment.line'].search([
('order_id', '=', po_id.id),
- ('move_line_id', '=', move_line_receivable_ids.id),
- ]
- )
+ ('move_line_id', '=', line.id)])
+
po_id.payment_line_ids -= p_line_id
@api.multi
def action_invoice_cancel(self):
for record in self:
- if record.eval_state_cnab == 'accepted':
- raise UserError(
- _(
- 'A fatura não pode ser cancelada pois já foi aprovada '
- 'no Banco.'
- )
- )
- if record.eval_state_cnab == 'done':
- raise UserError(_('Não é possível cancelar uma fatura finalizada.'))
- if record.eval_state_cnab == 'exported':
- raise UserError(
- _(
- 'A fatura não pode ser cancelada pois já foi exportada '
- 'em uma remessa.'
- )
- )
-
record._remove_payment_order_line()
super().action_invoice_cancel()
From a127ba8a8598d02235cd6ff1527f03f51a8eafb6 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 21 Aug 2020 13:29:20 -0300
Subject: [PATCH 273/612] [MIG][REF] Separation of Tariff Charge Account from
Product Tax Account.
---
.../migrations/12.0.2.0.0/pre-migration.py | 1 +
.../models/account_payment_mode.py | 12 +++++++++---
.../views/account_payment_mode.xml | 4 ++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index a27d1a1033ac..5aa639306d0a 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -30,6 +30,7 @@
('boleto_perc_mora', 'boleto_interest_perc'),
('boleto_cod_multa', 'boleto_fee_code'),
('boleto_perc_multa', 'boleto_fee_perc'),
+ ('tax_account_id', 'product_tax_account_id'),
],
'account.payment.line': [
('linha_digitavel', 'digitable_line'),
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index e196f04a13a3..870d5da87846 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -180,10 +180,10 @@ class AccountPaymentMode(models.Model):
string='Taxa Adicional',
)
- tax_account_id = fields.Many2one(
+ product_tax_account_id = fields.Many2one(
comodel_name='account.account',
- string='Conta Padrão',
- help='Conta padrão para Taxa',
+ string='Conta de Taxa do Produto',
+ help='Conta padrão para a Taxa do Produto',
)
cnab_sequence_id = fields.Many2one(
@@ -269,6 +269,12 @@ class AccountPaymentMode(models.Model):
help='Conta padrão para Abatimento',
)
+ tariff_charge_account_id = fields.Many2one(
+ comodel_name='account.account',
+ string='Conta Contabil Tarifa Bancaria',
+ help='Conta padrão para a Tarifa Bancaria',
+ )
+
_sql_constraints = [(
"internal_sequence_id_unique",
"unique(internal_sequence_id)",
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index e88df910573f..70cba5f78afb 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -24,7 +24,7 @@
-
+
@@ -68,7 +68,7 @@
-
+
From 78bc74972e4e503895223c16082dc784bf749d50 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Sat, 22 Aug 2020 13:35:51 -0300
Subject: [PATCH 274/612] [MIG][REF] Move method to get own number sequence
from invoice to payment mode.
---
.../models/account_invoice.py | 41 +++++++------------
.../models/account_payment_mode.py | 28 +++++++++++--
.../models/res_company.py | 7 +---
.../views/account_payment_mode.xml | 3 +-
4 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 28f8af6d368e..1721ff77b80f 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -158,38 +158,25 @@ def get_invoice_fiscal_number(self):
@api.multi
def _pos_action_move_create(self):
for inv in self:
- # inv.transaction_id = sequence
+
+ # TODO - apesar do campo move_line_receivable_ids ser do tipo
+ # compute esta sendo preciso chamar o metodo porque as vezes
+ # ocorre da linha vir vazia o que impede de entrar no FOR
+ # abaixo causando o não preenchimento de dados usados no Boleto,
+ # isso deve ser melhor investigado
inv._compute_receivables()
+
+ # TODO - Verificar se é boleto, existe uma
+ # forma melhor ou outro campo ?
+ if not inv.payment_mode_id.code_convetion:
+ return
+
for index, interval in enumerate(inv.move_line_receivable_ids):
inv_number = inv.get_invoice_fiscal_number().split('/')[-1].zfill(8)
numero_documento = inv_number + '/' + str(index + 1).zfill(2)
- # Verificar se é boleto para criar o numero
- if inv.company_id.own_number_type == '0':
- # SEQUENCIAL_EMPRESA
- sequence = inv.company_id.get_own_number_sequence()
- elif inv.company_id.own_number_type == '1':
- # SEQUENCIAL_FATURA
- sequence = numero_documento.replace('/', '')
- elif inv.company_id.own_number_type == '2':
- # SEQUENCIAL_CARTEIRA
- if not inv.payment_mode_id.own_number_sequence:
- raise UserError(
- _(
- 'Favor acessar aba Cobrança da configuração'
- ' do Modo de Pagamento e determinar o '
- 'campo Sequência do Nosso Número.'
- )
- )
- sequence = inv.payment_mode_id.get_own_number_sequence()
- else:
- raise UserError(
- _(
- 'Favor acessar aba Cobrança da configuração da'
- ' sua empresa para determinar o tipo de '
- 'sequencia utilizada nas cobrancas'
- )
- )
+ sequence = inv.payment_mode_id.get_own_number_sequence(
+ inv, numero_documento)
interval.transaction_ref = sequence
interval.own_number = (
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 870d5da87846..87e11f7a3039 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -5,7 +5,7 @@
from odoo import _, api, fields, models
from odoo.addons import decimal_precision as dp
-from odoo.exceptions import ValidationError
+from odoo.exceptions import ValidationError, UserError
from ..constants import (
AVISO_FAVORECIDO,
@@ -219,6 +219,11 @@ class AccountPaymentMode(models.Model):
'empresa',
)
+ # Field used to make invisible own_number_sequence
+ own_number_type = fields.Selection(
+ related='fixed_journal_id.company_id.own_number_type',
+ )
+
boleto_interest_code = fields.Char(
string='Código da Mora',
size=1,
@@ -300,9 +305,24 @@ def _onchange_product_tax_id(self):
self.tax_account_id = False
@api.multi
- def get_own_number_sequence(self):
- self.ensure_one()
- return self.own_number_sequence.next_by_id()
+ def get_own_number_sequence(self, inv, numero_documento):
+ if inv.company_id.own_number_type == '0':
+ # SEQUENCIAL_EMPRESA
+ sequence = inv.company_id.own_number_sequence.next_by_id()
+ elif inv.company_id.own_number_type == '1':
+ # SEQUENCIAL_FATURA
+ sequence = numero_documento.replace('/', '')
+ elif inv.company_id.own_number_type == '2':
+ # SEQUENCIAL_CARTEIRA
+ sequence = inv.payment_mode_id.own_number_sequence.next_by_id()
+ else:
+ raise UserError(_(
+ 'Favor acessar aba Cobrança da configuração da'
+ ' sua empresa para determinar o tipo de '
+ 'sequencia utilizada nas cobrancas'
+ ))
+
+ return sequence
@api.constrains('boleto_discount_perc')
def _check_discount_perc(self):
diff --git a/l10n_br_account_payment_order/models/res_company.py b/l10n_br_account_payment_order/models/res_company.py
index 397b58543272..5fcdaf677701 100644
--- a/l10n_br_account_payment_order/models/res_company.py
+++ b/l10n_br_account_payment_order/models/res_company.py
@@ -2,7 +2,7 @@
# @author Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models
+from odoo import fields, models
class ResCompany(models.Model):
@@ -27,8 +27,3 @@ class ResCompany(models.Model):
selection=[('1', 'HOMOLOGAÇÃO'), ('2', 'PRODUÇÃO')],
default='1',
)
-
- @api.multi
- def get_own_number_sequence(self):
- self.ensure_one()
- return self.own_number_sequence.next_by_id()
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 70cba5f78afb..07b004d620bf 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -39,7 +39,8 @@
-
+
+
From 4f860b786198f172aec74d8fc0cbf88b7c8a7ba9 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 24 Aug 2020 13:04:41 -0300
Subject: [PATCH 275/612] [MIG][FIX] Field missing in extract to API module.
---
l10n_br_account_payment_order/models/res_company.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/l10n_br_account_payment_order/models/res_company.py b/l10n_br_account_payment_order/models/res_company.py
index 5fcdaf677701..eae8df4a2d87 100644
--- a/l10n_br_account_payment_order/models/res_company.py
+++ b/l10n_br_account_payment_order/models/res_company.py
@@ -21,9 +21,3 @@ class ResCompany(models.Model):
own_number_sequence = fields.Many2one(
comodel_name='ir.sequence', string='Sequência do Nosso Número'
)
-
- environment = fields.Selection(
- string='Ambiente',
- selection=[('1', 'HOMOLOGAÇÃO'), ('2', 'PRODUÇÃO')],
- default='1',
- )
From 063ab0970e7247da0aad4aa87832a1a7ea44d0f8 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 24 Aug 2020 13:09:56 -0300
Subject: [PATCH 276/612] [MIG][FIX] Name of class.
---
l10n_br_account_payment_order/models/l10n_br_cnab.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab.py b/l10n_br_account_payment_order/models/l10n_br_cnab.py
index 16bac80d02f5..f0630ad2b8b9 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab.py
@@ -71,7 +71,7 @@
}
-class L10nBrHrCnab(models.Model):
+class L10nBrCnab(models.Model):
_name = 'l10n_br.cnab'
_description = 'l10n_br CNAB'
@@ -540,10 +540,10 @@ def write(self, vals):
name = self._get_name(data, filename)
vals.update({'name': name})
- return super(L10nBrHrCnab, self).write(vals)
+ return super().write(vals)
@api.model
def create(self, vals):
name = self._get_name(vals.get('data'), vals.get('filename'))
vals.update({'name': name})
- return super(L10nBrHrCnab, self).create(vals)
+ return super().create(vals)
From f8ceed8133f0c1428bb9dcda1dc70ff444969845 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 24 Aug 2020 15:46:27 -0300
Subject: [PATCH 277/612] [MIG][FIX] Validate Invoice without Payment Mode or
Payment Mode that don't generate Payment Order.
---
.../models/account_invoice.py | 10 ++++++----
.../views/account_payment_mode.xml | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 1721ff77b80f..29352a40b465 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -166,9 +166,8 @@ def _pos_action_move_create(self):
# isso deve ser melhor investigado
inv._compute_receivables()
- # TODO - Verificar se é boleto, existe uma
- # forma melhor ou outro campo ?
- if not inv.payment_mode_id.code_convetion:
+ # Verifica se gera Ordem de Pagamento
+ if not inv.payment_mode_id.payment_order_ok:
return
for index, interval in enumerate(inv.move_line_receivable_ids):
@@ -269,7 +268,10 @@ def invoice_validate(self):
result = super().invoice_validate()
filtered_invoice_ids = self.filtered(lambda s: s.payment_mode_id)
if filtered_invoice_ids:
- filtered_invoice_ids.create_account_payment_line()
+ for filtered_invoice_id in filtered_invoice_ids:
+ # Verifica se gera Ordem de Pagamento
+ if filtered_invoice_id.payment_mode_id.payment_order_ok:
+ filtered_invoice_id.create_account_payment_line()
return result
@api.multi
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 07b004d620bf..7ef3e1558226 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -40,7 +40,8 @@
-
+
From 9d6ceaf400e95e3317c4b68b0c7ceaf478456915 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 24 Aug 2020 15:59:56 -0300
Subject: [PATCH 278/612] [MIG][REF] Removed deprecated code.
---
.../models/account_invoice.py | 40 -------------------
1 file changed, 40 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 29352a40b465..21f6421802f5 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -79,39 +79,6 @@ def _onchange_payment_mode_id(self):
}
)
- # @api.onchange('payment_term_id')
- # def _onchange_payment_term_id(self):
- # interest_analytic_tag_id = self.env.ref(
- # 'l10n_br_account_payment_order.account_analytic_tag_interest'
- # )
- #
- # to_remove_invoice_line_ids = self.invoice_line_ids.filtered(
- # lambda i: interest_analytic_tag_id in i.analytic_tag_ids
- # )
- #
- # self.invoice_line_ids -= to_remove_invoice_line_ids
- #
- # payment_term_id = self.payment_term_id
- # amount_total = self.amount_total
- # if payment_term_id.has_interest and amount_total > 0:
- # invoice_line_data = {
- # 'name': 'Taxa de juros por parcelamento no cartão',
- # 'partner_id': self.partner_id.id,
- # 'account_id': payment_term_id.interest_account_id.id,
- # 'analytic_tag_ids': [(6, 0, [interest_analytic_tag_id.id])],
- # 'quantity': 1,
- # 'price_unit': amount_total * payment_term_id.interest_rate / 100,
- # }
- #
- # self.update(
- # {
- # 'invoice_line_ids': [
- # (6, 0, self.invoice_line_ids.ids),
- # (0, 0, invoice_line_data),
- # ]
- # }
- # )
-
def _remove_payment_order_line(self, _raise=True):
move_line_receivable_ids = self.move_line_receivable_ids
payment_order_ids = self.env['account.payment.order']
@@ -278,13 +245,6 @@ def invoice_validate(self):
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
- # if self.payment_term_id.payment_mode_selection == 'cartao':
- # raise UserError(
- # _(
- # 'Não é possível adicionar pagamentos em uma fatura '
- # 'parcelada no cartão de crédito'
- # )
- # )
if self.eval_situacao_pagamento in ['paga', 'liquidada', 'baixa_liquidacao']:
raise UserError(
_(
From 242594cca5d4d256a76067cd63e41bda19ed1628 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 25 Aug 2020 13:49:52 -0300
Subject: [PATCH 279/612] [MIG][FIX] Name of field has changed.
---
l10n_br_account_payment_order/models/account_invoice.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 21f6421802f5..7d54039f614a 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -63,7 +63,7 @@ def _onchange_payment_mode_id(self):
invoice_line_data = {
'name': 'Taxa adicional do modo de pagamento escolhido',
'partner_id': self.partner_id.id,
- 'account_id': payment_mode_id.tax_account_id.id,
+ 'account_id': payment_mode_id.product_tax_account_id.id,
'product_id': payment_mode_id.product_tax_id.id,
'price_unit': payment_mode_id.product_tax_id.lst_price,
'quantity': 1,
From 0d73d3c4bbe34be830d22b067b0b469717b9d36b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 25 Aug 2020 13:52:43 -0300
Subject: [PATCH 280/612] [MIG][IMP] Demo data.
---
.../demo/account_account.xml | 8 +++++++
.../demo/account_invoice.xml | 20 ++++++++++++++++
.../demo/account_journal.xml | 8 +++++++
.../demo/account_payment_mode.xml | 24 +++++++++++++++++++
4 files changed, 60 insertions(+)
diff --git a/l10n_br_account_payment_order/demo/account_account.xml b/l10n_br_account_payment_order/demo/account_account.xml
index 29dfe4aeacb2..d5b6286060e9 100644
--- a/l10n_br_account_payment_order/demo/account_account.xml
+++ b/l10n_br_account_payment_order/demo/account_account.xml
@@ -32,4 +32,12 @@
+
+ 3.01.01.01.01.03.00-AVOID_TRAVIS_ERROR*
+ Taxa do Boleto - AVOID_TRAVIS_ERROR
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index be132a2c78b0..86c4ec003c0c 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -122,4 +122,24 @@
+
+
+ Teste Cheque - quando o Modo de Pagto não gera Ordem de Pagto
+
+
+ out_invoice
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_journal.xml b/l10n_br_account_payment_order/demo/account_journal.xml
index de7ff88c5799..5c66bdbe25a8 100644
--- a/l10n_br_account_payment_order/demo/account_journal.xml
+++ b/l10n_br_account_payment_order/demo/account_journal.xml
@@ -55,4 +55,12 @@
+
+
+ Diário Cheque
+ DCQ
+ sale
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index 711ce8ed9ed3..ed1cc415cdaa 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -136,6 +136,18 @@
+
+
+ Produto Taxa Boleto
+
+ 5.0
+ 5.0
+ service
+
+
+ TAX_BOLETO
+
+
Cobrança Banco do Brasil 400
@@ -151,6 +163,18 @@
19
S
+
+
+
+
+
+
+ Cheque
+
+ fixed
+
+ False
+
From 79ff1c2840d751f0cfe89bb16549a41ed2f4a5a0 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 25 Aug 2020 14:00:30 -0300
Subject: [PATCH 281/612] [MIG][IMP] Tests.
---
.../tests/test_payment_order.py | 19 +++++++++++--
.../tests/test_payment_order_inbound.py | 28 +++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order.py
index 44d891bd518a..98506f32421a 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order.py
@@ -22,13 +22,13 @@ def setUp(self):
'l10n_br_account_payment_order.payment_mode_cobranca_itau400'
)
- self.env['account.payment.order'].search([])
-
# Configure to be possibile create Payment Order
self.payment_mode.payment_order_ok = True
self.invoice_customer_original.payment_mode_id = self.payment_mode.id
+ self.invoice_customer_original._onchange_payment_mode_id()
+
# Configure Journal to update posted
self.invoice_customer_original.journal_id.update_posted = True
@@ -45,6 +45,9 @@ def setUp(self):
assert self.invoice_customer_original.move_id,\
"Move not created for open invoice"
+ payment_order = self.env['account.payment.order'].search([])
+ assert payment_order, "Payment Order not created."
+
def test_implemented_fields_payment_order(self):
""" Test implemented fields in object account.move.line """
# Check Payment Mode field
@@ -68,7 +71,10 @@ def test_implemented_fields_payment_order(self):
for line in self.invoice_customer_original.move_id.line_ids.filtered(
lambda l: l.account_id.id ==
self.invoice_customer_original.account_id.id):
- self.assertEqual(
+
+ assert line.own_number,\
+ 'own_number field is not filled in created Move Line.'
+ self.assertEquals(
line.journal_entry_ref, line.invoice_id.name,
"Error with compute field journal_entry_ref")
test_balance_value = line.get_balance()
@@ -141,3 +147,10 @@ def test_bra_number_constrains(self):
partner_id=self.ref('l10n_br_base.res_partner_akretion'),
bra_number='12345'
))
+
+ def test_cancel_invoice(self):
+ """ Test Cancel Invoice """
+ self.invoice_customer_original.action_invoice_cancel()
+
+ # I check that the invoice state is "Cancel"
+ self.assertEquals(self.invoice_customer_original.state, 'cancel')
diff --git a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index d46711f2c0fd..173db1288f9c 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -18,6 +18,16 @@ def setUp(self):
self.invoice_customer_original.journal_id.update_posted = True
+ # Product Tax Boleto
+ self.invoice_product_tax_boleto = self.env.ref(
+ 'l10n_br_account_payment_order.demo_invoice_payment_order_bb_cnab400'
+ )
+
+ # Product Tax Boleto
+ self.invoice_cheque = self.env.ref(
+ 'l10n_br_account_payment_order.demo_invoice_payment_order_cheque'
+ )
+
def test_payment_order(self):
"""Test automatic creation of Payment Order."""
@@ -40,3 +50,21 @@ def test_payment_order(self):
payment_order.draft2open()
# The file generation need additional module to use BRCobranca or PyBoleto
# payment_order.open2generated()
+
+ def test_product_tax_boleto(self):
+ """ Test Invoice where Payment Mode has Product Tax. """
+ self.invoice_product_tax_boleto._onchange_payment_mode_id()
+ # I validate invoice by creating on
+ self.invoice_customer_original.action_invoice_open()
+
+ # I check that the invoice state is "Open"
+ self.assertEquals(self.invoice_customer_original.state, 'open')
+
+ def test_payment_mode_without_payment_order(self):
+ """ Test Invoice when Payment Mode not generate Payment Order. """
+ self.invoice_cheque._onchange_payment_mode_id()
+ # I validate invoice by creating on
+ self.invoice_cheque.action_invoice_open()
+
+ # I check that the invoice state is "Open"
+ self.assertEquals(self.invoice_cheque.state, 'open')
From 6eb91379e5b0a184279f1220e5e26bfd69c61432 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 25 Aug 2020 15:52:27 -0300
Subject: [PATCH 282/612] [MIG][FIX] Method missing in extract to Bank API
module.
---
.../models/account_payment_order.py | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 51e631d673fa..c89d40fb543c 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -88,24 +88,6 @@ class AccountPaymentOrder(models.Model):
domain=[('is_export_error', '=', True)],
)
- def _confirm_debit_orders_api(self):
- """
- Method create to confirm all bank_api exclusive account.payment.order
- :return:
- """
- _logger.info('_confirm_debit_orders_api()')
-
- order_ids = self.search(
- [('active', '=', False), ('state', '=', 'draft'), ('name', 'ilike', 'api')]
- )
-
- for order_id in order_ids:
- try:
- order_id.draft2open()
- order_id.active = True
- except Exception as e:
- _logger.warn(str(e))
-
@api.model
def _prepare_bank_payment_line(self, paylines):
result = super()._prepare_bank_payment_line(paylines)
From 9b83c94770326ea555bd455cf049775b4c5a83f9 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 3 Sep 2020 15:19:11 -0300
Subject: [PATCH 283/612] [FIX][DEMO] Don't generate paymets after confirm
order
Signed-off-by: Luis Felipe Mileo
---
.../demo/account_payment_mode.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index ed1cc415cdaa..d9a307f73707 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -43,6 +43,8 @@
19
S
+ False
+ False
@@ -63,6 +65,8 @@
2
5
72234050
+ False
+ False
@@ -83,6 +87,8 @@
2
5
72234050
+ False
+ False
@@ -100,6 +106,8 @@
19
S
+ False
+ False
@@ -117,6 +125,8 @@
19
S
+ False
+ False
@@ -134,6 +144,8 @@
19
S
+ False
+ False
@@ -165,6 +177,8 @@
+ False
+ False
@@ -175,6 +189,8 @@
False
+ False
+ False
From 9c34ebb0a682229b7c054227c3aa46dfb187201d Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 3 Sep 2020 19:02:56 -0300
Subject: [PATCH 284/612] [MIG][FIX] Demo data after rebase.
---
.../demo/account_account.xml | 21 ----------------
.../demo/account_invoice.xml | 3 ++-
.../demo/account_journal.xml | 24 +++++++++++++++++++
3 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/l10n_br_account_payment_order/demo/account_account.xml b/l10n_br_account_payment_order/demo/account_account.xml
index d5b6286060e9..d136b49389bb 100644
--- a/l10n_br_account_payment_order/demo/account_account.xml
+++ b/l10n_br_account_payment_order/demo/account_account.xml
@@ -1,27 +1,6 @@
-
-
- Test Payment Order
-
-
- out_invoice
-
-
-
-
-
-
-
-
- [E-COM06] Computador Personalizado (kit)
-
-
- 100
- 10
-
-
3.01.01.01.01.02.00-AVOID_TRAVIS_ERROR*
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index 86c4ec003c0c..b06aaed03f56 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -1,7 +1,8 @@
-
+
+
Test Payment Order
diff --git a/l10n_br_account_payment_order/demo/account_journal.xml b/l10n_br_account_payment_order/demo/account_journal.xml
index 5c66bdbe25a8..314520389747 100644
--- a/l10n_br_account_payment_order/demo/account_journal.xml
+++ b/l10n_br_account_payment_order/demo/account_journal.xml
@@ -2,6 +2,30 @@
+
+
+ Diário de Banco - Empresa Principal
+ TPO
+ sale
+
+
+
+
+
+ Diário de Banco - Simples Nacional
+ TPO
+ sale
+
+
+
+
+
+ Diário de Banco - Lucro Presumido
+ TPO
+ sale
+
+
+
Banco Bradesco
From 0464e1998e4c879aef09ce98db88dc1ef0ed6462 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 3 Sep 2020 19:26:03 -0300
Subject: [PATCH 285/612] [MIG][REF] Removed deprecated fields.
---
l10n_br_account_payment_order/__manifest__.py | 1 -
.../models/account_move_line.py | 15 ---------------
.../views/account_due_list.xml | 15 ---------------
.../views/account_move_line.xml | 14 --------------
4 files changed, 45 deletions(-)
delete mode 100644 l10n_br_account_payment_order/views/account_due_list.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 453e801b0aef..8dddc408fe17 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -33,7 +33,6 @@
'reports/report_print_button_view.xml',
# Views
- 'views/account_due_list.xml',
'views/account_payment_order.xml',
'views/account_payment_line.xml',
'views/account_payment_mode.xml',
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 4ba5046ec826..8c906cee565a 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -10,21 +10,12 @@
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
- date_scheduled = fields.Date(
- string='Data Prevista',
- )
-
cnab_state = fields.Selection(
selection=ESTADOS_CNAB,
string='Estados CNAB',
default='draft',
)
- date_payment_created = fields.Date(
- string='Data da criação do pagamento',
- readonly=True,
- )
-
own_number = fields.Char(
string='Nosso Numero',
)
@@ -48,12 +39,6 @@ class AccountMoveLine(models.Model):
readonly=True,
)
- residual = fields.Monetary(
- string='Valor Residual',
- default=0.0,
- currency_field='company_currency_id',
- )
-
journal_entry_ref = fields.Char(
string="Journal Entry Ref",
compute="_compute_journal_entry_ref",
diff --git a/l10n_br_account_payment_order/views/account_due_list.xml b/l10n_br_account_payment_order/views/account_due_list.xml
deleted file mode 100644
index 1d5f7c830876..000000000000
--- a/l10n_br_account_payment_order/views/account_due_list.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- l10n_br_account_payment_order.move.line.payments.tree
- account.move.line
-
-
-
-
-
-
-
-
-
diff --git a/l10n_br_account_payment_order/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
index a08ef740b048..08d06e1ccc59 100644
--- a/l10n_br_account_payment_order/views/account_move_line.xml
+++ b/l10n_br_account_payment_order/views/account_move_line.xml
@@ -15,21 +15,7 @@
-
-
-
-
- Payments
- account.move.line
- partner_id
-
-
-
-
-
-
-
From 3d23976e99b47a5a5fcf39c0e364610b61d212f2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 16 Sep 2020 10:30:22 -0300
Subject: [PATCH 286/612] [MIG][IMP] New class create to allow registering the
return movement code of the CNAB.
---
l10n_br_account_payment_order/__manifest__.py | 2 +
.../data/cnab_return_move_code_data.xml | 113 ++++++++++++++++++
.../models/__init__.py | 1 +
.../models/account_payment_mode.py | 7 ++
.../models/cnab_return_move_code.py | 37 ++++++
.../security/ir.model.access.csv | 1 +
.../views/account_payment_mode.xml | 3 +
.../views/cnab_return_move_code_view.xml | 46 +++++++
8 files changed, 210 insertions(+)
create mode 100644 l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
create mode 100644 l10n_br_account_payment_order/models/cnab_return_move_code.py
create mode 100644 l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 8dddc408fe17..501fe420eed3 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -28,6 +28,7 @@
'data/boleto_data.xml',
'data/ir_cron.xml',
'data/account_analytic_tag_data.xml',
+ 'data/cnab_return_move_code_data.xml',
# Reports
'reports/report_print_button_view.xml',
@@ -45,6 +46,7 @@
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
+ 'views/cnab_return_move_code_view.xml',
# Wizards
'wizards/account_payment_line_create_view.xml',
diff --git a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
new file mode 100644
index 000000000000..a2b3549d9d2b
--- /dev/null
+++ b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+ Pago (Título protestado pago em cartório)
+ 01
+
+
+
+
+
+ Instrução Confirmada*
+ 02
+
+
+
+
+
+ Instrução Rejeitada*
+ 03
+
+
+
+
+
+ Sustado Judicial (Título protestado sustado judicialmente)
+ 04
+
+
+
+
+
+ Liquidação Normal *
+ 06
+
+
+
+
+
+ Liquidação em Condicional (Título liquidado em cartório com cheque do próprio devedor)
+ 07
+
+
+
+
+
+ Sustado Definitivo (Título protestado sustado judicialmente)
+ 08
+
+
+
+
+
+ Liquidação de Título Descontado
+ 09
+
+
+
+
+
+ Liquidação de Título Descontado
+ 10
+
+
+
+
+
+ Protesto Em cartório
+ 11
+
+
+
+
+
+ Sustação solicitada
+ 12
+
+
+
+
+
+
+ Liquidação Normal *
+ 06
+
+
+
+
+
+ Liquidação *Atualizar Tabela
+ 17
+
+
+
+
+
+
+ Liquidação Normal *
+ 06
+
+
+
+
+
+ Liquidação *Atualizar Tabela
+ 10
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 8532f3b8c04e..b0912c2a2fcd 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -14,3 +14,4 @@
from . import l10n_br_cnab
from . import l10n_br_cnab_evento
from . import l10n_br_cnab_lote
+from . import cnab_return_move_code
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 87e11f7a3039..2ec532aa42ab 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -280,6 +280,13 @@ class AccountPaymentMode(models.Model):
help='Conta padrão para a Tarifa Bancaria',
)
+ cnab_liq_return_move_code_ids = fields.Many2many(
+ comodel_name='cnab.return.move.code',
+ relation='cnab_return_liquidity_move_code_rel',
+ column1='cnab_liq_return_move_code_id',
+ column2='payment_mode_id',
+ string='CNAB Liquidity Return Move Code')
+
_sql_constraints = [(
"internal_sequence_id_unique",
"unique(internal_sequence_id)",
diff --git a/l10n_br_account_payment_order/models/cnab_return_move_code.py b/l10n_br_account_payment_order/models/cnab_return_move_code.py
new file mode 100644
index 000000000000..1c31bc0dbb66
--- /dev/null
+++ b/l10n_br_account_payment_order/models/cnab_return_move_code.py
@@ -0,0 +1,37 @@
+# Copyright 2020 Akretion
+# @author Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import models, api, fields, _
+
+
+class CNABReturnMoveCode(models.Model):
+ """
+ CNAB return code, each Bank can has a list of Codes
+ """
+ _name = 'cnab.return.move.code'
+ _description = 'CNAB Return Move Code'
+
+ name = fields.Char(string='Name')
+ code = fields.Char(string='Code')
+ bank_id = fields.Many2one(
+ string='Bank', comodel_name='res.bank'
+ )
+ payment_method_id = fields.Many2one(
+ 'account.payment.method', string='Payment Method'
+ )
+ # Fields used to create domain
+ bank_code_bc = fields.Char(
+ related='bank_id.code_bc',
+ )
+ payment_method_code = fields.Char(related='payment_method_id.code')
+
+ @api.multi
+ def name_get(self):
+ result = []
+ for record in self:
+ result.append((
+ record.id, '%s - %s' % (
+ record.code, record.name)
+ ))
+ return result
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index 78b98435c1ed..a42c8b36703f 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -2,3 +2,4 @@
access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,group_cnab_cobranca,1,1,1,1
access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,group_cnab_cobranca,1,1,1,1
access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,group_cnab_cobranca,1,1,1,1
+access_cnab_return_move_code,access_cnab_return_move_code,model_cnab_return_move_code,group_cnab_cobranca,1,1,1,1
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 7ef3e1558226..19d7a72d3962 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -54,6 +54,9 @@
+
+
diff --git a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
new file mode 100644
index 000000000000..2ebef9fe354a
--- /dev/null
+++ b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ cnab.return.log.tree
+ cnab.return.move.code
+
+
+
+
+
+
+
+
+
+
+
+ cnab.return.log.form.view
+ cnab.return.move.code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CNAB Return Move Code
+ cnab.return.move.code
+ form
+ tree,form
+
+
+
+
+
From d42e443aeb7af0ab1750aa06821037fc6bd54187 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 16 Sep 2020 16:02:50 -0300
Subject: [PATCH 287/612] [MIG][REF] Commented deprecated code.
---
.../models/account_invoice.py | 32 +++++++++++--------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 7d54039f614a..82684bf5aceb 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -245,20 +245,24 @@ def invoice_validate(self):
def assign_outstanding_credit(self, credit_aml_id):
self.ensure_one()
- if self.eval_situacao_pagamento in ['paga', 'liquidada', 'baixa_liquidacao']:
- raise UserError(
- _(
- 'Não é possível adicionar pagamentos em uma fatura que '
- 'já está paga.'
- )
- )
- if self.eval_state_cnab in ['accepted', 'exported', 'done']:
- raise UserError(
- _(
- 'Não é possível adicionar pagamentos em uma fatura já '
- 'exportada ou aceita no banco.'
- )
- )
+ # TODO - Existe necessidade de ser feito algo nesse metodo ?
+ # Criar o teste do caso de uso de um Pagto por fora do CNAB
+ # p/ validar
+ # if self.eval_situacao_pagamento in ['paga', 'liquidada',
+ # 'baixa_liquidacao']:
+ # raise UserError(
+ # _(
+ # 'Não é possível adicionar pagamentos em uma fatura que '
+ # 'já está paga.'
+ # )
+ # )
+ # if self.eval_state_cnab in ['accepted', 'exported', 'done']:
+ # raise UserError(
+ # _(
+ # 'Não é possível adicionar pagamentos em uma fatura já '
+ # 'exportada ou aceita no banco.'
+ # )
+ # )
return super().assign_outstanding_credit(credit_aml_id)
@api.multi
From a6785f55603c1f12b7b5db849fbc2acf7bb4afc2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 16 Sep 2020 16:03:19 -0300
Subject: [PATCH 288/612] [MIG][IMP] Demo data.
---
l10n_br_account_payment_order/demo/account_payment_mode.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index d9a307f73707..068e148dcb5b 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -139,7 +139,7 @@
True
06
- 3
+ 175
DM
19
S
@@ -169,8 +169,8 @@
True
- 06
- 3
+ 0123456
+ 18
DM
19
S
From 0af6868c11f226e7c2b1217cb03b9abbc1ff8956 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 10:29:40 -0300
Subject: [PATCH 289/612] [MIG][FIX] When is possible fields used in
Boleto/CNAB should not have default.
---
l10n_br_account_payment_order/models/account_payment_mode.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 2ec532aa42ab..5c2fd1e14703 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -66,7 +66,6 @@ class AccountPaymentMode(models.Model):
string='Código do Convênio no Banco',
size=20,
help='Campo G007 do CNAB',
- default='0001222130126',
)
doc_finality_code = fields.Selection(
From f8c16afd9e3d58f1adbd93d1b532c282e1336771 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 10:36:23 -0300
Subject: [PATCH 290/612] [MIG][FIX] Field has default value what makes
constraint method call even when there is not Boleto/CNAB payment mode.
---
l10n_br_account_payment_order/models/account_payment_mode.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 5c2fd1e14703..3df7b33ffd4e 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -299,7 +299,6 @@ class AccountPaymentMode(models.Model):
'boleto_modality',
'boleto_convetion',
'boleto_variation',
- 'boleto_accept',
)
def boleto_restriction(self):
if self.boleto_type == '6' and not self.boleto_wallet:
From 00bdd50ef4e4d28f4189222bdeaf2cd5e39bc2c2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 10:40:31 -0300
Subject: [PATCH 291/612] [MIG][IMP] Validate fields that should not be used in
Boleto/CNAB payment mode.
---
.../models/account_payment_mode.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 3df7b33ffd4e..cc8ba6782fc0 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -303,6 +303,17 @@ class AccountPaymentMode(models.Model):
def boleto_restriction(self):
if self.boleto_type == '6' and not self.boleto_wallet:
raise ValidationError('Carteira no banco Itaú é obrigatória')
+ if self.group_lines:
+ raise ValidationError(
+ _('The Payment mode can not be used for Boleto/CNAB with the group'
+ ' lines active. \n Please uncheck it to continue.')
+ )
+ if self.generate_move or self.post_move:
+ raise ValidationError(
+ _('The Payment mode can not be used for Boleto/CNAB with the'
+ ' generated moves or post moves active. \n Please uncheck it'
+ ' to continue.')
+ )
@api.onchange('product_tax_id')
def _onchange_product_tax_id(self):
From cc301b6d9b52928b900e19da2f0d8e238443f18b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 10:42:27 -0300
Subject: [PATCH 292/612] [MIG][IMP] CNAB Return Move Code, banks Itau and
Bradesco CNAB400.
---
.../data/cnab_return_move_code_data.xml | 797 +++++++++++++++++-
1 file changed, 791 insertions(+), 6 deletions(-)
diff --git a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
index a2b3549d9d2b..eba90664630d 100644
--- a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
+++ b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
@@ -2,6 +2,7 @@
+
Pago (Título protestado pago em cartório)
@@ -60,7 +61,7 @@
- Liquidação de Título Descontado
+ Protesto solicitado
10
@@ -80,7 +81,21 @@
-
+
+
+ Entrada Confirmada
+ 02
+
+
+
+
+
+ Entrada Rejeitada
+ 03
+
+
+
+
Liquidação Normal *
06
@@ -88,26 +103,796 @@
+
+ Baixado Automat. via Arquivo
+ 09
+
+
+
+
+
+ Baixado conforme instruções da Agência
+ 10
+
+
+
+
+
+ Em Ser - Arquivo de Títulos pendentes
+ 11
+
+
+
+
+
+ Abatimento Concedido
+ 12
+
+
+
+
+
+ Abatimento Cancelado
+ 13
+
+
+
+
+
+ Vencimento Alterado
+ 14
+
+
+
+
+
+ Liquidação em Cartório
+ 15
+
+
+
+
+
+ Título Pago em Cheque – Vinculado
+ 16
+
+
+
+
- Liquidação *Atualizar Tabela
+ Liquidação após baixa ou Título não registrado
17
-
+
+ Acerto de Depositária
+ 18
+
+
+
+
+
+ Confirmação Receb. Inst. de Protesto
+ 19
+
+
+
+
+
+ Confirmação Recebimento Instrução Sustação de Protesto
+ 20
+
+
+
+
+
+ Acerto do Controle do Participante (sem motivo)
+ 21
+
+
+
+
+
+ Título Com Pagamento Cancelado
+ 22
+
+
+
+
+
+ Entrada do Título em Cartório (sem motivo)
+ 23
+
+
+
+
+
+ Entrada rejeitada por CEP Irregular
+ 24
+
+
+
+
+
+ Confirmação Receb.Inst.de Protesto Falimentar
+ 25
+
+
+
+
+
+ Baixa Rejeitada
+ 27
+
+
+
+
+
+ Débito de tarifas/custas
+ 28
+
+
+
+
+
+ Ocorrências do Pagador (NOVO)
+ 29
+
+
+
+
+
+ Alteração de Outros Dados Rejeitados
+ 30
+
+
+
+
+
+ Instrução Rejeitada
+ 32
+
+
+
+
+
+ Confirmação Pedido Alteração Outros Dados (sem motivo)
+ 33
+
+
+
+
+
+ Retirado de Cartório e Manutenção Carteira
+ 34
+
+
+
+
+
+ Desagendamento do débito automático
+ 35
+
+
+
+
+
+ Estorno de pagamento
+ 40
+
+
+
+
+
+ Sustado judicial
+ 55
+
+
+
+
+
+ Acerto dos dados do rateio de Crédito
+ 68
+
+
+
+
+
+ Cancelamento dos dados do rateio
+ 69
+
+
+
+
+
+ Confirmação Receb. Pedido de Negativação
+ 73
+
+
+
+
+
+ Confir Pedido de Excl de Negat (com ou sem baixa)
+ 74
+
+
+
+
+
+ Nota: Para as ocorrências sem motivos, as posições serão informadas com Zeros.
+ 00
+
+
+
+
+
+
+ ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM
+ 02
+
+
+
+
+
+ ENTRADA REJEITADA
+ 03
+
+
+
+
+
+ ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA
+ 04
+
+
+
+
+
+ ALTERAÇÃO DE DADOS – BAIXA
+ 05
+
+
+
+
- Liquidação Normal *
+ Liquidação Normal
06
+
+ LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)
+ 07
+
+
+
+
+
+ LIQUIDAÇÃO EM CARTÓRIO
+ 08
+
+
+
+
+
+ BAIXA SIMPLES
+ 09
+
+
+
+
- Liquidação *Atualizar Tabela
+ BAIXA POR TER SIDO LIQUIDADO
10
+
+ EM SER (SÓ NO RETORNO MENSAL)
+ 11
+
+
+
+
+
+ ABATIMENTO CONCEDIDO
+ 12
+
+
+
+
+
+ ABATIMENTO CANCELADO
+ 13
+
+
+
+
+
+ VENCIMENTO ALTERADO
+ 14
+
+
+
+
+
+ BAIXAS REJEITADAS (NOTA 20 – TABELA 4)
+ 15
+
+
+
+
+
+ INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)
+ 16
+
+
+
+
+
+ ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)
+ 17
+
+
+
+
+
+ COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)
+ 18
+
+
+
+
+
+ CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO
+ 19
+
+
+
+
+
+ CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA
+ 20
+
+
+
+
+
+ CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR
+ 21
+
+
+
+
+
+ TÍTULO ENVIADO A CARTÓRIO/TARIFA
+ 23
+
+
+
+
+
+ INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)
+ 24
+
+
+
+
+
+ ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)
+ 25
+
+
+
+
+
+ TARIFA DE AVISO DE COBRANÇA
+ 26
+
+
+
+
+
+ TARIFA DE EXTRATO POSIÇÃO (B40X)
+ 27
+
+
+
+
+
+ TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES
+ 28
+
+
+
+
+
+ TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS
+ 29
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)
+ 30
+
+
+
+
+
+ BAIXA POR TER SIDO PROTESTADO
+ 32
+
+
+
+
+
+ CUSTAS DE PROTESTO
+ 33
+
+
+
+
+
+ CUSTAS DE SUSTAÇÃO
+ 34
+
+
+
+
+
+ CUSTAS DE CARTÓRIO DISTRIBUIDOR
+ 35
+
+
+
+
+
+ CUSTAS DE EDITAL
+ 36
+
+
+
+
+
+ TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA
+ 37
+
+
+
+
+
+ TARIFA DE INSTRUÇÃO
+ 38
+
+
+
+
+
+ TARIFA DE OCORRÊNCIAS
+ 39
+
+
+
+
+
+ TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA
+ 40
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)
+ 41
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES
+ 42
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS
+ 43
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS
+ 44
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – PROTESTO
+ 45
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO
+ 46
+
+
+
+
+
+ BAIXA COM TRANSFERÊNCIA PARA DESCONTO
+ 47
+
+
+
+
+
+ CUSTAS DE SUSTAÇÃO JUDICIAL
+ 48
+
+
+
+
+
+ TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA
+ 51
+
+
+
+
+
+ TARIFA MENSAL BAIXAS NA CARTEIRA
+ 52
+
+
+
+
+
+ TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA
+ 53
+
+
+
+
+
+ TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA
+ 54
+
+
+
+
+
+ TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA
+ 55
+
+
+
+
+
+ CUSTAS DE IRREGULARIDADE
+ 56
+
+
+
+
+
+ INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)
+ 57
+
+
+
+
+
+ BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG
+ 59
+
+
+
+
+
+ ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)
+ 60
+
+
+
+
+
+ TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)
+ 61
+
+
+
+
+
+ DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)
+ 62
+
+
+
+
+
+ TÍTULO SUSTADO JUDICIALMENTE
+ 63
+
+
+
+
+
+ ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO
+ 64
+
+
+
+
+
+ PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO
+ 65
+
+
+
+
+
+ CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)
+ 69
+
+
+
+
+
+ ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO
+ 71
+
+
+
+
+
+ BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE
+ 72
+
+
+
+
+
+ CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL
+ 73
+
+
+
+
+
+ INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)
+ 74
+
+
+
+
+
+ CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA
+ 75
+
+
+
+
+
+ CHEQUE COMPENSADO
+ 76
+
+
+
+
+
+ CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA
+ 77
+
+
+
+
+
+ CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA
+ 78
+
+
+
+
+
+ NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)
+ 79
+
+
+
+
+
+ CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA
+ 80
+
+
+
+
+
+ CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA
+ 82
+
+
+
+
+
+ CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA
+ 83
+
+
+
+
+
+ TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA
+ 85
+
+
+
+
+
+ TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA
+ 86
+
+
+
+
+
+ TARIFA SMS COBRANÇA ATIVA ELETRÔNICA
+ 87
+
+
+
+
+
+ TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA
+ 88
+
+
+
+
+
+ TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA
+ 89
+
+
+
+
+
+ TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA
+ 90
+
+
+
+
+
+ TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA
+ 91
+
+
+
+
+
+ TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA
+ 92
+
+
+
+
+
+ TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO
+ 93
+
+
+
+
From 98bee542631fdab2dd487efa7ae7c3fc6fb7a172 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 10:44:25 -0300
Subject: [PATCH 293/612] [MIG][IMP] Demo data.
---
.../demo/account_account.xml | 48 ++++++++++++++--
.../demo/account_invoice.xml | 14 ++---
.../demo/account_payment_mode.xml | 56 ++++++++++++++++++-
3 files changed, 105 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_order/demo/account_account.xml b/l10n_br_account_payment_order/demo/account_account.xml
index d136b49389bb..2d95b20d71bf 100644
--- a/l10n_br_account_payment_order/demo/account_account.xml
+++ b/l10n_br_account_payment_order/demo/account_account.xml
@@ -1,9 +1,9 @@
-
-
- 3.01.01.01.01.02.00-AVOID_TRAVIS_ERROR*
+
+
+ 3.01.01.01.01.02.00
Receita da Venda no Mercado Interno
de Produtos de Fabricação Própria - AVOID_TRAVIS_ERROR
@@ -11,12 +11,50 @@
-
- 3.01.01.01.01.03.00-AVOID_TRAVIS_ERROR*
+
+
+ 3.01.01.01.01.03.00-*
Taxa do Boleto - AVOID_TRAVIS_ERROR
+
+
+ 3.2.3.02-*
+ Outras Despesas Financeiras - AVOID_TRAVIS_ERROR
+
+
+
+
+
+
+
+ 3.1.2.02-*
+ Juros Ativos - AVOID_TRAVIS_ERROR
+
+
+
+
+
+
+
+ 3.2.2.02-*
+ Despesas com Vendas - AVOID_TRAVIS_ERROR
+
+
+
+
+
+
+
+ 3.2.2.03-*
+ Outras Despesas Gerais - AVOID_TRAVIS_ERROR
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index b06aaed03f56..6813d8c7ec66 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -20,7 +20,7 @@
100
10
-
+
@@ -40,7 +40,7 @@
100
10
-
+
@@ -60,7 +60,7 @@
100
10
-
+
@@ -80,7 +80,7 @@
100
10
-
+
@@ -100,7 +100,7 @@
100
10
-
+
@@ -120,7 +120,7 @@
100
10
-
+
@@ -140,7 +140,7 @@
100
10
-
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index 068e148dcb5b..fee51342382b 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -8,6 +8,10 @@
variable
+ False
+ False
+ False
+ 0001222130126
@@ -17,6 +21,10 @@
variable
+ False
+ False
+ False
+ 0001222130126
@@ -26,6 +34,10 @@
variable
+ False
+ False
+ False
+ 0001222130126
@@ -45,6 +57,8 @@
False
False
+ False
+ 0001222130126
@@ -67,6 +81,15 @@
72234050
False
False
+ False
+
+
+
+
+
+ 0001222130126
@@ -89,6 +112,12 @@
72234050
False
False
+ False
+
+
+
+
+ 0001222130126
@@ -108,6 +137,12 @@
False
False
+ False
+
+
+
+
+ 0001222130126
@@ -127,6 +162,13 @@
False
False
+ False
+
+
+
+
+
+ 000122
@@ -146,6 +188,12 @@
False
False
+ False
+
+
+
+
+ 0001222130126
@@ -176,9 +224,15 @@
S
-
+
False
False
+ False
+
+
+
+
+ 0001222130126
From be5210c92d0e3c8792c224c66e165c1c59a6304a Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 11:35:49 -0300
Subject: [PATCH 294/612] [MIG][FIX] PEP8.
---
l10n_br_account_payment_order/models/cnab_return_move_code.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/cnab_return_move_code.py b/l10n_br_account_payment_order/models/cnab_return_move_code.py
index 1c31bc0dbb66..4b94a296bdf5 100644
--- a/l10n_br_account_payment_order/models/cnab_return_move_code.py
+++ b/l10n_br_account_payment_order/models/cnab_return_move_code.py
@@ -2,7 +2,7 @@
# @author Magno Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import models, api, fields, _
+from odoo import models, api, fields
class CNABReturnMoveCode(models.Model):
From 6f6f6ed897b67a7f7a762f9d8f5a9a508d50eb44 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 29 Sep 2020 15:52:15 -0300
Subject: [PATCH 295/612] [MIG][FIX] Tests, field group_lines can be used for
BOLETO/CNAB Payment Mode.
---
l10n_br_account_payment_order/tests/test_payment_order.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order.py
index 98506f32421a..4393969c288f 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order.py
@@ -113,7 +113,7 @@ def test_cancel_payment_order(self):
# Open payment order
payment_order.draft2open()
- self.assertEquals(len(payment_order.bank_line_ids), 1)
+ self.assertEquals(len(payment_order.bank_line_ids), 2)
# TODO
# Generate and upload
From 860a8aca296a8e1fe30d01e5d90a48afe5ca0cc3 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 30 Sep 2020 07:07:48 -0300
Subject: [PATCH 296/612] [REM] ir.cron Boleto API
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_order/data/ir_cron.xml | 15 ---------------
1 file changed, 15 deletions(-)
delete mode 100644 l10n_br_account_payment_order/data/ir_cron.xml
diff --git a/l10n_br_account_payment_order/data/ir_cron.xml b/l10n_br_account_payment_order/data/ir_cron.xml
deleted file mode 100644
index e183757e1cea..000000000000
--- a/l10n_br_account_payment_order/data/ir_cron.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 071903dc1de6999c0e39df8f4247525db2235372 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 30 Sep 2020 07:09:06 -0300
Subject: [PATCH 297/612] [REF] Index and code improve cnab.return.move.code
Signed-off-by: Luis Felipe Mileo
---
.../models/cnab_return_move_code.py | 24 +++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_order/models/cnab_return_move_code.py b/l10n_br_account_payment_order/models/cnab_return_move_code.py
index 4b94a296bdf5..b18a2f73c3f6 100644
--- a/l10n_br_account_payment_order/models/cnab_return_move_code.py
+++ b/l10n_br_account_payment_order/models/cnab_return_move_code.py
@@ -12,19 +12,33 @@ class CNABReturnMoveCode(models.Model):
_name = 'cnab.return.move.code'
_description = 'CNAB Return Move Code'
- name = fields.Char(string='Name')
- code = fields.Char(string='Code')
+ name = fields.Char(
+ string='Name',
+ index=True,
+ )
+ code = fields.Char(
+ string='Code',
+ index=True,
+ )
bank_id = fields.Many2one(
- string='Bank', comodel_name='res.bank'
+ string='Bank',
+ comodel_name='res.bank',
+ index=True,
)
payment_method_id = fields.Many2one(
- 'account.payment.method', string='Payment Method'
+ comodel_name='account.payment.method',
+ string='Payment Method',
+ index=True,
)
# Fields used to create domain
bank_code_bc = fields.Char(
related='bank_id.code_bc',
+ store=True,
+ )
+ payment_method_code = fields.Char(
+ related='payment_method_id.code',
+ store=True,
)
- payment_method_code = fields.Char(related='payment_method_id.code')
@api.multi
def name_get(self):
From a33ed0712d4f6a52054845d80b92f4600a1c7f74 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Wed, 30 Sep 2020 07:11:18 -0300
Subject: [PATCH 298/612] [REF] Code otimization and comments
Signed-off-by: Luis Felipe Mileo
---
.../models/account_invoice.py | 36 ++++++++++++-------
.../models/account_move.py | 2 +-
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 82684bf5aceb..63aa7e8ca4d4 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -79,24 +79,37 @@ def _onchange_payment_mode_id(self):
}
)
+ # TODO: Criar um movimento de baixa
def _remove_payment_order_line(self, _raise=True):
+ """ Try to search payment orders related to the account move of this
+ invoice, we can't remove a payment.order.line / bank.line of a invoice
+ that already sent to the bank.
+
+ The only way to do that is to say that you want to cancel it.
+
+ Creating a new move of "BAIXA/ESTORNO"
+
+ :param _raise:
+ :return:
+ """
move_line_receivable_ids = self.move_line_receivable_ids
payment_order_ids = self.env['account.payment.order']
- for line in move_line_receivable_ids:
- payment_order_ids |= self.env['account.payment.order'].search(
- [('payment_line_ids.move_line_id', 'in', [line.id])]
- )
+ payment_order_ids |= self.env['account.payment.order'].search([
+ ('payment_line_ids.move_line_id', 'in', move_line_receivable_ids.ids),
+ ])
if payment_order_ids:
draft_cancel_payment_order_ids = payment_order_ids.filtered(
- lambda p: p.state in ['draft', 'cancel']
+ lambda p: p.state in ('draft', 'cancel')
)
if payment_order_ids - draft_cancel_payment_order_ids:
if _raise:
raise UserError(_(
'A fatura não pode ser cancelada pois a mesma já se '
- 'encontra exportada por uma ordem de pagamento.'))
+ 'encontra exportada por uma ordem de pagamento. \n',
+ 'Envie um novo lançamento solicitando a Baixa/Cancelamento'
+ ))
for po_id in draft_cancel_payment_order_ids:
p_line_id = self.env['account.payment.line']
@@ -104,15 +117,17 @@ def _remove_payment_order_line(self, _raise=True):
p_line_id |= self.env['account.payment.line'].search([
('order_id', '=', po_id.id),
('move_line_id', '=', line.id)])
-
po_id.payment_line_ids -= p_line_id
@api.multi
def action_invoice_cancel(self):
+ """ Before cancel the invoice, check if this invoice have any payment order
+ related to it.
+ :return:
+ """
for record in self:
record._remove_payment_order_line()
-
- super().action_invoice_cancel()
+ return super().action_invoice_cancel()
@api.multi
def get_invoice_fiscal_number(self):
@@ -125,7 +140,6 @@ def get_invoice_fiscal_number(self):
@api.multi
def _pos_action_move_create(self):
for inv in self:
-
# TODO - apesar do campo move_line_receivable_ids ser do tipo
# compute esta sendo preciso chamar o metodo porque as vezes
# ocorre da linha vir vazia o que impede de entrar no FOR
@@ -161,14 +175,12 @@ def _pos_action_move_create(self):
@api.multi
def action_move_create(self):
result = super().action_move_create()
-
self._pos_action_move_create()
return result
@api.multi
def create_account_payment_line_baixa(self):
for inv in self:
-
applicable_lines = inv.move_id.line_ids.filtered(
lambda x: (
x.payment_mode_id.payment_order_ok
diff --git a/l10n_br_account_payment_order/models/account_move.py b/l10n_br_account_payment_order/models/account_move.py
index 94c6c0ed0cf8..32f203f69a70 100644
--- a/l10n_br_account_payment_order/models/account_move.py
+++ b/l10n_br_account_payment_order/models/account_move.py
@@ -13,7 +13,7 @@ def unlink(self):
for record in self:
payment_line_ids = record.line_ids.mapped("payment_line_ids")
if any(
- state not in ["draft", "cancel"]
+ state not in ("draft", "cancel")
for state in payment_line_ids.mapped("state")
):
raise ValidationError(
From dcc23c49c2a8cc99528b9b39d173d65a08e58cec Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 1 Oct 2020 10:34:01 -0300
Subject: [PATCH 299/612] [NEW] Boleto test cases
Signed-off-by: Luis Felipe Mileo
---
.../tests/test_payment_order_inbound.py | 80 +++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index 173db1288f9c..9b77ffbb2bc7 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -1,5 +1,7 @@
# @ 2020 Akretion - www.akretion.com.br -
# Magno Costa
+# @ 2020 KMEE - www.kmee.com.br
+# Luis Felipe Mileo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
@@ -68,3 +70,81 @@ def test_payment_mode_without_payment_order(self):
# I check that the invoice state is "Open"
self.assertEquals(self.invoice_cheque.state, 'open')
+
+ def test_payment_inbound_change_due_date(self):
+ """ Change account.move.line due date. Automatic add this aml to a new
+ payment.order, export the movement to the bank and process it's accept return.
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_cancel_invoice_not_registred(self):
+ """ Cancel the invoice with a payment that isn't registred at the bank
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_cancel_invoice_alread_registred_raise(self):
+ """ Cancel the invoice with a payment that is already registred at the bank.
+ For that you have to create bank movement of "BAIXA" before you can cancel
+ the invoice.
+
+ In this test we must get a raise when trying to cancel the invoice.
+
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_payment_in_cash(self):
+ """ Pay a invoice in cash, with a payment already registred to in the bank.
+ Then we must cancel the boleto at the bank, creating a movement of "BAIXA".
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_cancel_invoice_alread_registred_with_baixa(self):
+ """ Cancel the invoice with a payment that is already registred at the bank.
+ For that you have to create bank movement of "BAIXA" before you can cancel
+ the invoice.
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_return_accept(self):
+ """ The payment was exported and the bank return that it's accepted
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_return_denied(self):
+ """ The payment was exported and the bank return that it's denied
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_return_paid(self):
+ """ The payment was exported, accepted, and after some days the bank
+ return that it's paid (LIQUIDADO) by the customer
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_return_paid_with_interest(self):
+ """ The payment was exported, accepted, and after some days the bank
+ return that it's paid (LIQUIDADO) by the customer but with interest
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_return_paid_with_discount(self):
+ """ The payment was exported, accepted, and after some days the bank
+ return that it's paid (LIQUIDADO) by the customer but with discount
+ :return:
+ """
+ pass
+
+ def test_payment_inbound_protesto(self):
+ """ Protesto movement sent and accepted
+ :return:
+ """
+ pass
From c5fee449b7f1c3d1a429ef2b24cc856776e17611 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 1 Oct 2020 13:05:57 -0300
Subject: [PATCH 300/612] fixup! [NEW] Boleto test cases
---
.../tests/test_payment_order_inbound.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index 9b77ffbb2bc7..ff9479d125bb 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -129,6 +129,23 @@ def test_payment_inbound_return_paid(self):
"""
pass
+ def test_payment_inbound_return_baixado(self):
+ """ The payment was exported, accepted, and after some days the user at
+ internet banking cancel it (STATE: BAIXADO). The invoice must stay
+ open, waiting to the user to do a new manual action.
+
+ - The user must be warned that the state of the invoice/aml
+ was changed at the bank;
+ - The user can record manual/statement payment with another payment method;
+ - The user can cancel the invoice/aml;
+
+ This test is similar with "test_payment_inbound_payment_in_cash" buy
+ it is not exported again to the bank because i'ts already set manualy at the
+ internet banking
+ :return:
+ """
+ pass
+
def test_payment_inbound_return_paid_with_interest(self):
""" The payment was exported, accepted, and after some days the bank
return that it's paid (LIQUIDADO) by the customer but with interest
From be8abf260e28f8b9b01c15cc0c1805ce68fe26e2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 5 Oct 2020 13:22:21 -0300
Subject: [PATCH 301/612] [MIG][FIX] File was removed.
---
l10n_br_account_payment_order/__manifest__.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 501fe420eed3..4d376edbcfa6 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -26,7 +26,6 @@
'data/cnab_data.xml',
'data/l10n_br_payment_export_type.xml',
'data/boleto_data.xml',
- 'data/ir_cron.xml',
'data/account_analytic_tag_data.xml',
'data/cnab_return_move_code_data.xml',
From c3f1976d50d014d84624874631bd1172d939fec6 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 5 Oct 2020 16:49:42 -0300
Subject: [PATCH 302/612] [MIG][WIP] Prepare extraction of objects
l10n_br.cnab/lote/evento to KMEE module implementation.
---
l10n_br_account_payment_order/__manifest__.py | 8 ++++++--
.../migrations/12.0.2.0.0/pre-migration.py | 4 ++++
l10n_br_account_payment_order/models/__init__.py | 10 +++++++---
.../models/bank_payment_line.py | 16 ++++++++++------
.../security/ir.model.access.csv | 3 ---
.../views/bank_payment_line.xml | 10 ++++++++--
6 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 4d376edbcfa6..11ac518e3112 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -38,8 +38,12 @@
'views/account_payment_mode.xml',
'views/res_company.xml',
'views/bank_payment_line.xml',
- 'views/l10n_br_cnab_retorno_view.xml',
- 'views/l10n_br_cnab_evento_views.xml',
+ # TODO - mover os cnab/lote/evento para o modulo de implentacao da
+ # KMEE, já que para importacao do arquivo CNAB de retorno a Akretion
+ # passou a usar o account_move_base_import, estou mantendo a visão
+ # para permirtir a extração e assim preservar o histórico de commits
+ # 'views/l10n_br_cnab_retorno_view.xml',
+ # 'views/l10n_br_cnab_evento_views.xml',
'views/account_invoice.xml',
'views/account_move_line.xml',
# 'views/l10n_br_payment_cnab.xml',
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index 5aa639306d0a..c2fa5534eb75 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -71,6 +71,10 @@
('mensagem_erro_exportacao', 'export_error_message'),
('ultimo_estado_cnab', 'last_cnab_state')
],
+ # TODO - mover os cnab/lote/evento para o modulo de implentacao da KMEE,
+ # já que para importacao do arquivo CNAB de retorno a Akretion passou a
+ # usar o account_move_base_import, estou mantendo o código para permirtir
+ # a extração e assim preservar o histórico de commits
'l10n_br.cnab.evento': [
('data_real_pagamento', 'real_payment_date'),
('data_ocorrencia', 'occurrence_date'),
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index b0912c2a2fcd..89277c80a6b6 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -11,7 +11,11 @@
from . import account_payment_line
from . import account_payment
from . import bank_payment_line
-from . import l10n_br_cnab
-from . import l10n_br_cnab_evento
-from . import l10n_br_cnab_lote
+# TODO - mover os cnab/lote/evento para o modulo de implentacao da KMEE,
+# já que para importacao do arquivo CNAB de retorno a Akretion passou a
+# usar o account_move_base_import, estou mantendo o código para permirtir
+# a extração e assim preservar o histórico de commits
+# from . import l10n_br_cnab
+# from . import l10n_br_cnab_evento
+# from . import l10n_br_cnab_lote
from . import cnab_return_move_code
diff --git a/l10n_br_account_payment_order/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
index 8519a996fce6..095453a59bfd 100644
--- a/l10n_br_account_payment_order/models/bank_payment_line.py
+++ b/l10n_br_account_payment_order/models/bank_payment_line.py
@@ -86,12 +86,16 @@ def default_get(self, fields_list):
help='Campo G048 do CNAB',
)
- event_id = fields.One2many(
- string='Eventos CNAB',
- comodel_name='l10n_br.cnab.evento',
- inverse_name='bank_payment_line_id',
- readonly=True,
- )
+ # TODO - mover os cnab/lote/evento para o modulo de implentacao da KMEE,
+ # já que para importacao do arquivo CNAB de retorno a Akretion passou a
+ # usar o account_move_base_import, estou mantendo o código para permirtir
+ # a extração e assim preservar o histórico de commits
+ # event_id = fields.One2many(
+ # string='Eventos CNAB',
+ # comodel_name='l10n_br.cnab.evento',
+ # inverse_name='bank_payment_line_id',
+ # readonly=True,
+ # )
own_number = fields.Char(
string='Nosso Numero',
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index a42c8b36703f..60f4f4205cb3 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -1,5 +1,2 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,group_cnab_cobranca,1,1,1,1
-access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,group_cnab_cobranca,1,1,1,1
-access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,group_cnab_cobranca,1,1,1,1
access_cnab_return_move_code,access_cnab_return_move_code,model_cnab_return_move_code,group_cnab_cobranca,1,1,1,1
diff --git a/l10n_br_account_payment_order/views/bank_payment_line.xml b/l10n_br_account_payment_order/views/bank_payment_line.xml
index 4b0d81cd2f3b..a4f25bf2a83d 100644
--- a/l10n_br_account_payment_order/views/bank_payment_line.xml
+++ b/l10n_br_account_payment_order/views/bank_payment_line.xml
@@ -21,13 +21,19 @@
-
+
From 98c74218d259d9d0d6bd3ba8bcee52811a5eb86a Mon Sep 17 00:00:00 2001
From: Renato Lima
Date: Wed, 7 Oct 2020 12:04:31 -0300
Subject: [PATCH 303/612] [FIX] invoice without payment_mode_id
---
l10n_br_account_payment_order/models/account_invoice.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 63aa7e8ca4d4..4430543b5b42 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -145,11 +145,13 @@ def _pos_action_move_create(self):
# ocorre da linha vir vazia o que impede de entrar no FOR
# abaixo causando o não preenchimento de dados usados no Boleto,
# isso deve ser melhor investigado
+ if not inv.payment_mode_id:
+ continue
inv._compute_receivables()
# Verifica se gera Ordem de Pagamento
if not inv.payment_mode_id.payment_order_ok:
- return
+ continue
for index, interval in enumerate(inv.move_line_receivable_ids):
inv_number = inv.get_invoice_fiscal_number().split('/')[-1].zfill(8)
From 3965725044a890d8902cb209183de33cabf9a9e8 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 14 Oct 2020 16:09:21 -0300
Subject: [PATCH 304/612] [MIG][REF] Security groups.
---
.../demo/res_users.xml | 2 +-
.../security/cnab_cobranca_security.xml | 23 +++++++++++++++----
.../security/ir.model.access.csv | 3 ++-
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/l10n_br_account_payment_order/demo/res_users.xml b/l10n_br_account_payment_order/demo/res_users.xml
index 183b54fe2761..3b8e149f9240 100644
--- a/l10n_br_account_payment_order/demo/res_users.xml
+++ b/l10n_br_account_payment_order/demo/res_users.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/l10n_br_account_payment_order/security/cnab_cobranca_security.xml b/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
index 0cf09df8ca0c..963afdc3ff1f 100644
--- a/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
+++ b/l10n_br_account_payment_order/security/cnab_cobranca_security.xml
@@ -1,17 +1,30 @@
-
- CNAB Cobranca
-
+
+ CNAB
+ Helps you handle your CNAB needs.
+ 99
+
+
+
+ CNAB User
+
+
+
+
+
+ CNAB Manager
+
+
-
+
-
+
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index 60f4f4205cb3..8e539c1b1b50 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -1,2 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-access_cnab_return_move_code,access_cnab_return_move_code,model_cnab_return_move_code,group_cnab_cobranca,1,1,1,1
+access_cnab_return_move_code_user,access_cnab_return_move_code_user,model_cnab_return_move_code,group_cnab_user,1,0,0,0
+access_cnab_return_move_code_manager,access_cnab_return_move_code_manager,model_cnab_return_move_code,group_cnab_manager,1,1,1,1
\ No newline at end of file
From 797753e790d4b7acb99a6c8b5edd4e3086a9d287 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 21 Oct 2020 11:23:51 -0300
Subject: [PATCH 305/612] [FIX] Name views.
---
.../views/cnab_return_move_code_view.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
index 2ebef9fe354a..b870035969ba 100644
--- a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
+++ b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
@@ -2,7 +2,7 @@
- cnab.return.log.tree
+ cnab.return.move.code.tree
cnab.return.move.code
@@ -15,7 +15,7 @@
- cnab.return.log.form.view
+ cnab.return.move.code.form.view
cnab.return.move.code
@@ -38,7 +38,7 @@
tree,form
-
From ccbdb31857b84d4c2e042206cc2f36be12f902b5 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 21 Oct 2020 11:30:18 -0300
Subject: [PATCH 306/612] [REF] Splitted objects used to import CNAB return
file to have the Log separated from the importer.
---
l10n_br_account_payment_order/__manifest__.py | 17 +-
.../models/__init__.py | 18 +-
.../models/cnab_return_log.py | 41 +++++
.../models/ir_attachment.py | 19 +++
.../models/l10n_br_cnab_evento.py | 30 ++--
.../models/l10n_br_cnab_lote.py | 33 ++--
.../security/ir.model.access.csv | 8 +-
.../views/cnab_return_log_view.xml | 155 ++++++++++++++++++
8 files changed, 275 insertions(+), 46 deletions(-)
create mode 100644 l10n_br_account_payment_order/models/cnab_return_log.py
create mode 100644 l10n_br_account_payment_order/models/ir_attachment.py
create mode 100644 l10n_br_account_payment_order/views/cnab_return_log_view.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 11ac518e3112..a701fdb02dfa 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -38,17 +38,22 @@
'views/account_payment_mode.xml',
'views/res_company.xml',
'views/bank_payment_line.xml',
- # TODO - mover os cnab/lote/evento para o modulo de implentacao da
- # KMEE, já que para importacao do arquivo CNAB de retorno a Akretion
- # passou a usar o account_move_base_import, estou mantendo a visão
- # para permirtir a extração e assim preservar o histórico de commits
+ # TODO - Separação dos dados de importação para um objeto especifico
+ # cnab.return.log armazenando o LOG do Arquivo de Retorno CNAB
+ # de forma separada e permitindo a integração com a alteração feita no
+ # modulo do BRCobranca onde se esta utilizando o modulo
+ # account_base_move_import para fazer essa tarefa de wizard de importação,
+ # o objeto l10n_br_cnab esta comentado para permitir, caso seja necessário,
+ # a implementação de outra forma de importação pois tem os metodos que eram
+ # usados pela KMEE e o historico git do arquivo
# 'views/l10n_br_cnab_retorno_view.xml',
# 'views/l10n_br_cnab_evento_views.xml',
- 'views/account_invoice.xml',
- 'views/account_move_line.xml',
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
+ 'views/cnab_return_log_view.xml',
+ 'views/account_invoice.xml',
+ 'views/account_move_line.xml',
'views/cnab_return_move_code_view.xml',
# Wizards
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 89277c80a6b6..60b98c88062d 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -11,11 +11,17 @@
from . import account_payment_line
from . import account_payment
from . import bank_payment_line
-# TODO - mover os cnab/lote/evento para o modulo de implentacao da KMEE,
-# já que para importacao do arquivo CNAB de retorno a Akretion passou a
-# usar o account_move_base_import, estou mantendo o código para permirtir
-# a extração e assim preservar o histórico de commits
+# TODO - Separação dos dados de importação para um objeto especifico
+# cnab.return.log armazenando o LOG do Arquivo de Retorno CNAB
+# de forma separada e permitindo a integração com a alteração feita no
+# modulo do BRCobranca onde se esta utilizando o modulo
+# account_base_move_import para fazer essa tarefa de wizard de importação,
+# o objeto l10n_br_cnab esta comentado para permitir, caso seja necessário,
+# a implementação de outra forma de importação pois tem os metodos que eram
+# usados pela KMEE e o historico git do arquivo
# from . import l10n_br_cnab
-# from . import l10n_br_cnab_evento
-# from . import l10n_br_cnab_lote
+from . import l10n_br_cnab_evento
+from . import l10n_br_cnab_lote
from . import cnab_return_move_code
+from . import cnab_return_log
+from . import ir_attachment
diff --git a/l10n_br_account_payment_order/models/cnab_return_log.py b/l10n_br_account_payment_order/models/cnab_return_log.py
new file mode 100644
index 000000000000..fea307ab1fc3
--- /dev/null
+++ b/l10n_br_account_payment_order/models/cnab_return_log.py
@@ -0,0 +1,41 @@
+# Copyright 2020 Akretion
+# @author Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import models, fields
+
+
+class CNABReturnLog(models.Model):
+ """
+ The class is used to register the LOG of CNAB return file.
+ """
+ _name = 'cnab.return.log'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
+ _description = 'CNAB Return Log'
+
+ name = fields.Char(string='Name')
+ filename = fields.Char(string='Nome do Arquivo')
+ number_events = fields.Integer(string='Número de Eventos')
+ number_lots = fields.Integer(string='Número de Lotes')
+ cnab_date_import = fields.Datetime(string='CNAB Date Import')
+ bank_account_id = fields.Many2one(
+ string='Conta cedente', comodel_name='res.partner.bank'
+ )
+ # TODO - validar o campo a partir do primeiro arquivo incluido
+ # para evitar de 'pular' a sequencia ?
+ # O BRCobranca ignora a linha do header
+ sequential_file = fields.Char(string='Sequencial do Arquivo')
+ cnab_date_file = fields.Date(string='CNAB Date File')
+
+ event_ids = fields.One2many(
+ string='Eventos', comodel_name='cnab.return.event',
+ inverse_name='cnab_return_log_id'
+ )
+ amount_total_title = fields.Float(string='Valor Total Títulos')
+ amount_total_received = fields.Float(string='Valor Total Recebido')
+ # Field used to make invisible/visible fields refer to Lot
+ is_cnab_lot = fields.Boolean(string='Is CNAB Lot?')
+ # The LOG can have or not Journal Entry
+ move_id = fields.Many2one(
+ string='Journal Entry', comodel_name='account.move'
+ )
diff --git a/l10n_br_account_payment_order/models/ir_attachment.py b/l10n_br_account_payment_order/models/ir_attachment.py
new file mode 100644
index 000000000000..fa8fe9777bc5
--- /dev/null
+++ b/l10n_br_account_payment_order/models/ir_attachment.py
@@ -0,0 +1,19 @@
+# Copyright 2020 Akretion
+# @author Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, models, SUPERUSER_ID
+from odoo.exceptions import ValidationError
+
+
+class IrAttachment(models.Model):
+ _inherit = 'ir.attachment'
+
+ @api.multi
+ def unlink(self):
+ for rec in self:
+ if rec.res_model in ['cnab.return.log']\
+ and rec.res_id and self._uid != SUPERUSER_ID:
+ raise ValidationError(
+ 'Sorry, you are not allowed to delete the attachment.')
+ return super().unlink()
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
index 0d51320c41a3..d0d6ba9954e8 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
@@ -2,19 +2,25 @@
# @author Luiz Felipe do Divino Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import logging
-
from odoo import fields, models
-from ..constants import STATE_CNAB
-
-_logger = logging.getLogger(__name__)
-
-class L10nBrCnabEvento(models.Model):
- _name = 'l10n_br.cnab.evento'
- _description = 'l10n_br CNAB Event'
+class CNABReturnEvent(models.Model):
+ """
+ The class is used to register the Events of CNAB return file.
+ """
+ _name = 'cnab.return.event'
+ _description = 'CNAB Return Event'
+ cnab_return_log_id = fields.Many2one(
+ string='CNAB Return Log', comodel_name='cnab.return.log',
+ )
+ # Field used to make invisible/visible fields refer to Lot
+ is_cnab_lot = fields.Boolean(string='Is CNAB Lot?')
+ # O arquivo de Retorno pode ter ou não Lotes
+ lot_id = fields.Many2one(
+ string='Lote', comodel_name='cnab.return.lot', ondelete='cascade'
+ )
bank_payment_line_id = fields.Many2one(
string='Bank Payment Line', comodel_name='bank.payment.line'
)
@@ -30,18 +36,12 @@ class L10nBrCnabEvento(models.Model):
)
invoice_id = fields.Many2one(comodel_name='account.invoice', string='Fatura')
interest_fee_value = fields.Float(string='Juros de Mora/Multa')
- lot_id = fields.Many2one(
- string='Lote', comodel_name='l10n_br.cnab.lote', ondelete='cascade'
- )
own_number = fields.Char(string='Nosso Número')
occurrences = fields.Char(string='Ocorrências')
other_credits = fields.Float(string='Outros Créditos')
partner_id = fields.Many2one(comodel_name='res.partner', string='Associado')
segment = fields.Char(string='Segmento')
your_number = fields.Char(string='Seu Número')
- state = fields.Selection(
- string='State', related='lot_id.state', selection=STATE_CNAB, default='draft'
- )
str_motiv_a = fields.Char('Motivo da ocorrência 01')
str_motiv_b = fields.Char('Motivo de ocorrência 02')
str_motiv_c = fields.Char('Motivo de ocorrência 03')
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
index ce09e9929f62..863a1a6a02c9 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
@@ -2,35 +2,32 @@
# @author Luiz Felipe do Divino Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import logging
-
from odoo import fields, models
-from ..constants import STATE_CNAB
-
-_logger = logging.getLogger(__name__)
+class CNABReturnLot(models.Model):
+ """
+ The class is used to register the Lots of Events in CNAB return file.
+ """
+ _name = 'cnab.return.lot'
+ _description = 'CNAB Return Lot'
-class L10nBrCnabLote(models.Model):
- _name = 'l10n_br.cnab.lote'
- _description = 'l10n_br CNAB Lot'
-
+ lot_event_ids = fields.One2many(
+ string='Eventos', comodel_name='cnab.return.event',
+ inverse_name='lot_id'
+ )
+ # TODO - deveria ter alguma relação com o objeto cnab.return.log
+ # diretamente ? Já que já existe com no Evento
+ # cnab_return_log_id = fields.Many2one(
+ # string='CNAB Return Log', comodel_name='cnab.return.log', ondelete='cascade'
+ # )
account_bank_id = fields.Many2one(
string='Conta Bancária', comodel_name='res.partner.bank'
)
- cnab_id = fields.Many2one(
- string='CNAB', comodel_name='l10n_br.cnab', ondelete='cascade'
- )
company_registration_number = fields.Char(string='Número de Inscrição')
company_registration_type = fields.Char(string='Tipo de Inscrição')
- event_id = fields.One2many(
- string='Eventos', comodel_name='l10n_br.cnab.evento', inverse_name='lot_id'
- )
message = fields.Char(string='Mensagem')
register_qty = fields.Integer(string='Quantidade de Registros')
operation_service = fields.Char(string='Tipo de Operação')
- state = fields.Selection(
- string='State', related='cnab_id.state', selection=STATE_CNAB, default='draft'
- )
service_type = fields.Char(string='Tipo do Serviço')
total_value = fields.Float(string='Valor Total')
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index 8e539c1b1b50..f49d3758e11d 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -1,3 +1,9 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_cnab_return_move_code_user,access_cnab_return_move_code_user,model_cnab_return_move_code,group_cnab_user,1,0,0,0
-access_cnab_return_move_code_manager,access_cnab_return_move_code_manager,model_cnab_return_move_code,group_cnab_manager,1,1,1,1
\ No newline at end of file
+access_cnab_return_move_code_manager,access_cnab_return_move_code_manager,model_cnab_return_move_code,group_cnab_manager,1,1,1,1
+access_cnab_return_log_user,access_cnab_return_log_user,model_cnab_return_log,group_cnab_user,1,1,1,0
+access_cnab_return_log_manager,access_cnab_return_log_manager,model_cnab_return_log,group_cnab_manager,1,1,1,1
+access_cnab_return_event_user,access_cnab_return_event_user,model_cnab_return_event,group_cnab_user,1,1,1,0
+access_cnab_return_event_manager,access_cnab_return_event_manager,model_cnab_return_event,group_cnab_manager,1,1,1,1
+access_cnab_return_lot_user,access_cnab_return_lot_user,model_cnab_return_lot,group_cnab_user,1,1,1,0
+access_cnab_return_lot_manager,access_cnab_return_lot_manager,model_cnab_return_lot,group_cnab_manager,1,1,1,1
\ No newline at end of file
diff --git a/l10n_br_account_payment_order/views/cnab_return_log_view.xml b/l10n_br_account_payment_order/views/cnab_return_log_view.xml
new file mode 100644
index 000000000000..9241e941e67e
--- /dev/null
+++ b/l10n_br_account_payment_order/views/cnab_return_log_view.xml
@@ -0,0 +1,155 @@
+
+
+
+
+ cnab.return.log.tree
+ cnab.return.log
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.return.log.form.view
+ cnab.return.log
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.return.event.tree
+ cnab.return.event
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.return.lot.form.view
+ cnab.return.lot
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cnab.return.log.search
+ cnab.return.log
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CNAB Return Log
+ cnab.return.log
+ form
+ tree,form
+
+
+
+
+
From ff384ba8738d0e86b52dbd8f73b149f1cd5c7f4f Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 22 Oct 2020 12:47:49 -0300
Subject: [PATCH 307/612] [IMP] Boleto demo data
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_order/__manifest__.py | 1 +
.../demo/account_invoice.xml | 24 +++++++++++++++++++
.../demo/account_payment_mode.xml | 2 ++
.../demo/account_payment_order.xml | 14 +++++++++++
.../models/account_payment_order.py | 14 ++++++-----
5 files changed, 49 insertions(+), 6 deletions(-)
create mode 100644 l10n_br_account_payment_order/demo/account_payment_order.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index a701fdb02dfa..0d591e70895e 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -66,6 +66,7 @@
'demo/account_payment_mode.xml',
'demo/account_invoice.xml',
'demo/res_users.xml',
+ 'demo/account_payment_order.xml',
],
'installable': True,
}
diff --git a/l10n_br_account_payment_order/demo/account_invoice.xml b/l10n_br_account_payment_order/demo/account_invoice.xml
index 6813d8c7ec66..0cfa23aaf51d 100644
--- a/l10n_br_account_payment_order/demo/account_invoice.xml
+++ b/l10n_br_account_payment_order/demo/account_invoice.xml
@@ -143,4 +143,28 @@
+
+ Manual Main Company
+
+
+ out_invoice
+
+
+
+
+
+
+
+ [E-COM06] Computador Personalizado (kit)
+
+
+ 100
+ 10
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index fee51342382b..b4bfaf218448 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -12,6 +12,8 @@
False
False
0001222130126
+ fixed
+
diff --git a/l10n_br_account_payment_order/demo/account_payment_order.xml b/l10n_br_account_payment_order/demo/account_payment_order.xml
new file mode 100644
index 000000000000..c8a5416f7882
--- /dev/null
+++ b/l10n_br_account_payment_order/demo/account_payment_order.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index c89d40fb543c..9413334838d7 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -102,10 +102,12 @@ def _prepare_bank_payment_line(self, paylines):
def open2generated(self):
result = super().open2generated()
- if self.bank_line_error_ids:
- self.message_post(
- 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
- )
- return False
- self.message_post('Arquivo gerado com sucesso')
+ for record in self:
+ if record.bank_line_error_ids:
+ record.message_post(
+ 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
+ )
+ continue
+ else:
+ record.message_post('Arquivo gerado com sucesso')
return result
From 221ba1cd88957340a4ae57671d73b78119be1cec Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 22 Oct 2020 12:48:14 -0300
Subject: [PATCH 308/612] [NEW] AML Changes
Signed-off-by: Luis Felipe Mileo
---
l10n_br_account_payment_order/__manifest__.py | 7 +-
.../models/account_move_line.py | 1 +
.../views/account_move_line.xml | 26 +++++++
.../wizards/__init__.py | 1 +
.../wizards/account_move_line_change.py | 77 +++++++++++++++++++
.../wizards/account_move_line_change.xml | 42 ++++++++++
6 files changed, 151 insertions(+), 3 deletions(-)
create mode 100644 l10n_br_account_payment_order/wizards/account_move_line_change.py
create mode 100644 l10n_br_account_payment_order/wizards/account_move_line_change.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 0d591e70895e..36ce4225c767 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -32,6 +32,10 @@
# Reports
'reports/report_print_button_view.xml',
+ # Wizards
+ 'wizards/account_payment_line_create_view.xml',
+ 'wizards/account_move_line_change.xml',
+
# Views
'views/account_payment_order.xml',
'views/account_payment_line.xml',
@@ -55,9 +59,6 @@
'views/account_invoice.xml',
'views/account_move_line.xml',
'views/cnab_return_move_code_view.xml',
-
- # Wizards
- 'wizards/account_payment_line_create_view.xml',
],
'demo': [
'demo/res_partner_bank.xml',
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 8c906cee565a..35b1a1e56eff 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -44,6 +44,7 @@ class AccountMoveLine(models.Model):
compute="_compute_journal_entry_ref",
store=True,
)
+ date_maturity = fields.Date(readonly=True)
@api.depends("move_id")
def _compute_journal_entry_ref(self):
diff --git a/l10n_br_account_payment_order/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
index 08d06e1ccc59..8f9c54b24af2 100644
--- a/l10n_br_account_payment_order/views/account_move_line.xml
+++ b/l10n_br_account_payment_order/views/account_move_line.xml
@@ -7,6 +7,16 @@
+
+
+
+
@@ -18,4 +28,20 @@
+
+ cnab.account.move.line.tree.inherit
+ account.move.line
+
+
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/wizards/__init__.py b/l10n_br_account_payment_order/wizards/__init__.py
index 649d0fc86a5e..5ce2c034e080 100644
--- a/l10n_br_account_payment_order/wizards/__init__.py
+++ b/l10n_br_account_payment_order/wizards/__init__.py
@@ -5,3 +5,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_payment_line_create
+from . import account_move_line_change
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.py b/l10n_br_account_payment_order/wizards/account_move_line_change.py
new file mode 100644
index 000000000000..ad7ba4ecc7a3
--- /dev/null
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.py
@@ -0,0 +1,77 @@
+# Copyright 2020 KMEE
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, fields, models, _
+
+
+class AccountMoveLineChange(models.TransientModel):
+
+ _name = 'account.move.line.change'
+
+ @api.model
+ def default_get(self, fields_list):
+ res = super(AccountMoveLineChange, self).default_get(fields_list)
+ if self.env.context.get('active_model') == 'account.move.line':
+ active_ids = self.env.context.get('active_ids')
+ res['account_move_line_ids'] = active_ids
+ if active_ids and len(active_ids) == 1:
+ move_line_id = self.account_move_line_ids.browse(
+ active_ids
+ )
+ if move_line_id.date_maturity:
+ res['date_maturity'] = move_line_id.date_maturity
+ if move_line_id.payment_mode_id:
+ res['payment_mode_id'] = move_line_id.payment_mode_id.id
+ return res
+
+ account_move_line_ids = fields.Many2many(
+ comodel_name='account.move.line',
+ string='Move Line',
+ readonly=True,
+ )
+ change_type = fields.Selection(
+ selection=[
+ ('change_date_maturity', 'Vencimento'),
+ ('change_payment_mode', 'Modo de Pagamento'),
+ ('baixa', 'Baixa'),
+ ],
+ string='Tipo Alteração',
+ )
+ date_maturity = fields.Date(
+ string="Date Maturity"
+ )
+ payment_mode_id = fields.Many2one(
+ comodel_name='account.payment.mode',
+ )
+ # Muitas opções são permitidas, verificar manual do cnab 240.
+ # Entretanto inicialmente só vamos implementar as mais simples.
+
+ def _pre_process_change(self):
+ pass
+
+ def _change_date_maturity(self):
+ for aml in self.account_move_line_ids:
+ if aml.date_maturity != self.date_maturity:
+ aml.date_maturity = self.date_maturity
+
+ def _change_payment_mode(self):
+ for aml in self.account_move_line_ids:
+ if aml.payment_mode_id != self.payment_mode_id:
+ aml.payment_mode_id = self.payment_mode_id
+
+ def _change_baixa(self):
+ NotImplementedError
+
+ def _post_process_change(self):
+ pass
+
+ @api.multi
+ def doit(self):
+ self._pre_process_change()
+ if self.change_type == 'change_date_maturity':
+ self._change_date_maturity()
+ elif self.change_type == 'change_payment_mode':
+ self._change_payment_mode()
+ elif self.change_type == 'baixa':
+ self._change_baixa()
+ self._post_process_change()
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.xml b/l10n_br_account_payment_order/wizards/account_move_line_change.xml
new file mode 100644
index 000000000000..fea294ef23dd
--- /dev/null
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ account.move.line.change.form (in l10n_br_account_payment_order)
+ account.move.line.change
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Change Account Move Line
+ ir.actions.act_window
+ account.move.line.change
+ form
+
+ new
+ True
+
+
+
+
From 5082dd7e76f6930f444d141420ba9322fb8cb526 Mon Sep 17 00:00:00 2001
From: Luis Felipe Mileo
Date: Thu, 22 Oct 2020 15:13:19 -0300
Subject: [PATCH 309/612] [IMP] AML Changes
Signed-off-by: Luis Felipe Mileo
---
.../models/account_move_line.py | 58 ++++++++++++++++++-
.../views/account_move_line.xml | 13 ++++-
.../wizards/account_move_line_change.py | 36 +++---------
.../wizards/account_move_line_change.xml | 1 +
4 files changed, 75 insertions(+), 33 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 35b1a1e56eff..08edd7f91775 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -2,13 +2,14 @@
# Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models
+from odoo import api, fields, models, _
from ..constants import ESTADOS_CNAB, SITUACAO_PAGAMENTO
class AccountMoveLine(models.Model):
- _inherit = 'account.move.line'
+ _name = 'account.move.line'
+ _inherit = ["account.move.line", "mail.thread", "mail.activity.mixin"]
cnab_state = fields.Selection(
selection=ESTADOS_CNAB,
@@ -32,6 +33,7 @@ class AccountMoveLine(models.Model):
selection=SITUACAO_PAGAMENTO,
string='Situação do Pagamento',
default='inicial',
+ track_visibility='onchange',
)
instructions = fields.Text(
@@ -44,7 +46,18 @@ class AccountMoveLine(models.Model):
compute="_compute_journal_entry_ref",
store=True,
)
- date_maturity = fields.Date(readonly=True)
+ payment_mode_id = fields.Many2one(
+ track_visibility='onchange'
+ )
+ date_maturity = fields.Date(
+ readonly=True,
+ track_visibility='onchange'
+ )
+ last_change_reason = fields.Text(
+ readonly=True,
+ track_visibility='onchange',
+ string="Justificativa",
+ )
@api.depends("move_id")
def _compute_journal_entry_ref(self):
@@ -136,3 +149,42 @@ def get_balance(self):
for line in self:
total += (line.debit or 0.0) - (line.credit or 0.0)
return total
+
+ def _create_payment_order_change(self, **kwargs):
+ self.ensure_one()
+ # TODO:
+
+ def _change_date_maturity(self, new_date, reason, **kwargs):
+ moves_to_sync = self.filtered(lambda m: m.date_maturity != new_date)
+ moves_to_sync._create_payment_order_change(new_date=new_date, **kwargs)
+ moves_to_sync.write({
+ 'date_maturity': new_date,
+ 'last_change_reason': reason,
+ })
+
+ def _change_payment_mode(self, reason, new_payment_mode_id, **kwargs):
+ moves_to_sync = self.filtered(
+ lambda m: m.payment_mode_id != new_payment_mode_id)
+ moves_to_sync._create_payment_order_change(
+ new_payment_mode_id=new_payment_mode_id, **kwargs)
+ moves_to_sync.write({
+ 'payment_mode_id': new_payment_mode_id.id,
+ 'last_change_reason': reason,
+ })
+
+ def _create_baixa(self, reason, **kwargs):
+ moves_to_sync = self.filtered(lambda m: True)
+ # TODO: Verificar restrições possíveis
+ moves_to_sync._create_payment_order_change(baixa=True, **kwargs)
+ moves_to_sync.write({
+ 'last_change_reason': reason,
+ 'payment_situation': 'baixa', # FIXME: Podem ser múltiplos motivos
+ })
+
+ def _create_change(self, change_type, reason='', **kwargs):
+ if change_type == 'change_date_maturity':
+ self._change_date_maturity(reason, **kwargs)
+ elif change_type == 'change_payment_mode':
+ self._change_payment_mode(reason, **kwargs)
+ elif change_type == 'baixa':
+ self._create_baixa(reason, **kwargs)
diff --git a/l10n_br_account_payment_order/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
index 8f9c54b24af2..9cf3a31bc559 100644
--- a/l10n_br_account_payment_order/views/account_move_line.xml
+++ b/l10n_br_account_payment_order/views/account_move_line.xml
@@ -7,16 +7,16 @@
-
+
-
-
+
@@ -25,6 +25,13 @@
+
+
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.py b/l10n_br_account_payment_order/wizards/account_move_line_change.py
index ad7ba4ecc7a3..a6c9bf852c75 100644
--- a/l10n_br_account_payment_order/wizards/account_move_line_change.py
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.py
@@ -43,35 +43,17 @@ def default_get(self, fields_list):
payment_mode_id = fields.Many2one(
comodel_name='account.payment.mode',
)
+ reason = fields.Text(
+ string="Justificativa",
+ )
# Muitas opções são permitidas, verificar manual do cnab 240.
# Entretanto inicialmente só vamos implementar as mais simples.
- def _pre_process_change(self):
- pass
-
- def _change_date_maturity(self):
- for aml in self.account_move_line_ids:
- if aml.date_maturity != self.date_maturity:
- aml.date_maturity = self.date_maturity
-
- def _change_payment_mode(self):
- for aml in self.account_move_line_ids:
- if aml.payment_mode_id != self.payment_mode_id:
- aml.payment_mode_id = self.payment_mode_id
-
- def _change_baixa(self):
- NotImplementedError
-
- def _post_process_change(self):
- pass
-
@api.multi
def doit(self):
- self._pre_process_change()
- if self.change_type == 'change_date_maturity':
- self._change_date_maturity()
- elif self.change_type == 'change_payment_mode':
- self._change_payment_mode()
- elif self.change_type == 'baixa':
- self._change_baixa()
- self._post_process_change()
+ self.account_move_line_ids._create_change(
+ change_type=self.change_type,
+ reason=self.reason,
+ new_date=self.date_maturity,
+ new_payment_mode_id=self.payment_mode_id,
+ )
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.xml b/l10n_br_account_payment_order/wizards/account_move_line_change.xml
index fea294ef23dd..18135bf088ee 100644
--- a/l10n_br_account_payment_order/wizards/account_move_line_change.xml
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.xml
@@ -14,6 +14,7 @@
+
Date: Wed, 28 Oct 2020 14:32:30 -0300
Subject: [PATCH 310/612] =?UTF-8?q?[REF]=20Move=20field=20movement=5Fintru?=
=?UTF-8?q?ction=5Fcode=20(=20Codigo=20de=20Instru=C3=A7=C3=A3o=20da=20Mov?=
=?UTF-8?q?imenta=C3=A7=C3=A3o=20)=20CNAB=20from=20object=20account=5Fpaym?=
=?UTF-8?q?ent=5Forder=20to=20account=5Fpayment=5Fline=20because=20in=20th?=
=?UTF-8?q?e=20same=20file=20the=20lines=20can=20have=20different=20code.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/account_invoice.py | 6 +++-
.../models/account_move_line.py | 28 +++++++++++++++++++
.../models/account_payment_line.py | 26 +++++++++++++++++
.../models/account_payment_mode.py | 6 ++++
.../models/account_payment_order.py | 7 -----
.../views/account_move_line.xml | 1 +
.../views/account_payment_line.xml | 7 +++--
.../views/account_payment_order.xml | 1 -
8 files changed, 70 insertions(+), 12 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 4430543b5b42..b02ce2592883 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -173,6 +173,8 @@ def _pos_action_move_create(self):
if inv.instructions:
instructions += inv.instructions + '\n'
interval.instructions = instructions
+ # Codigo de Instrução da Remessa - '01 - Remessa*'
+ interval.movement_instruction_code = '01'
@api.multi
def action_move_create(self):
@@ -250,7 +252,9 @@ def invoice_validate(self):
filtered_invoice_ids = self.filtered(lambda s: s.payment_mode_id)
if filtered_invoice_ids:
for filtered_invoice_id in filtered_invoice_ids:
- # Verifica se gera Ordem de Pagamento
+ # TODO - essa validação já é feita no super, confirmar
+ # com o teste do modo de pagto q não deve gerar Ordem
+ # de Pagto, modo Cheque
if filtered_invoice_id.payment_mode_id.payment_order_ok:
filtered_invoice_id.create_account_payment_line()
return result
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 08edd7f91775..996f208e45eb 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -59,6 +59,31 @@ class AccountMoveLine(models.Model):
string="Justificativa",
)
+ # TODO - Mover seleção para o arquivo de Constantes,
+ # aguardando retorno para saber se existe diferença
+ # entre os Bancos, o CNAB 400 da Unicred e o 240 da
+ # Febraban v10.06 estão iguais, a seleção no arquivo
+ # de constantes está diferente.
+ # Caso exista diferença vai ser preciso fazer o mesmo
+ # que foi feito nos Codigos de Retorno
+ movement_instruction_code = fields.Selection(
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ selection=[
+ ('01', '01 - Remessa*'),
+ ('02', '02 - Pedido de Baixa'),
+ ('04', '04 - Concessão de Abatimento*'),
+ ('05', '05 - Cancelamento de Abatimento'),
+ ('06', '06 - Alteração de vencimento'),
+ ('08', '08 - Alteração de Seu Número'),
+ ('09', '09 - Protestar*'),
+ ('11', '11 - Sustar Protesto e Manter em Carteira'),
+ ('25', '25 - Sustar Protesto e Baixar Título'),
+ ('26', '26 – Protesto automático'),
+ ('31', '31 - Alteração de outros dados (Alteração de dados do pagador'),
+ ('40', '40 - Alteração de Carteira')]
+ )
+
@api.depends("move_id")
def _compute_journal_entry_ref(self):
for record in self:
@@ -78,6 +103,9 @@ def _prepare_payment_line_vals(self, payment_order):
vals['document_number'] = self.document_number
vals['company_title_identification'] = self.company_title_identification
+ # Codigo de Instrução do Movimento para Remessa
+ vals['movement_instruction_code'] = self.movement_instruction_code
+
if self.invoice_id.state == 'paid':
vals['amount_currency'] = self.credit or self.debit
diff --git a/l10n_br_account_payment_order/models/account_payment_line.py b/l10n_br_account_payment_order/models/account_payment_line.py
index 4ef9f7575ea1..6b1697df3db8 100644
--- a/l10n_br_account_payment_order/models/account_payment_line.py
+++ b/l10n_br_account_payment_order/models/account_payment_line.py
@@ -96,6 +96,31 @@ class AccountPaymentLine(models.Model):
help='Campo G048 do CNAB',
)
+ # TODO - Mover seleção para o arquivo de Constantes,
+ # aguardando retorno para saber se existe diferença
+ # entre os Bancos, o CNAB 400 da Unicred e o 240 da
+ # Febraban v10.06 estão iguais, a seleção no arquivo
+ # de constantes está diferente.
+ # Caso exista diferença vai ser preciso fazer o mesmo
+ # que foi feito nos Codigos de Retorno
+ movement_instruction_code = fields.Selection(
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ selection=[
+ ('01', '01 - Remessa*'),
+ ('02', '02 - Pedido de Baixa'),
+ ('04', '04 - Concessão de Abatimento*'),
+ ('05', '05 - Cancelamento de Abatimento'),
+ ('06', '06 - Alteração de vencimento'),
+ ('08', '08 - Alteração de Seu Número'),
+ ('09', '09 - Protestar*'),
+ ('11', '11 - Sustar Protesto e Manter em Carteira'),
+ ('25', '25 - Sustar Protesto e Baixar Título'),
+ ('26', '26 – Protesto automático'),
+ ('31', '31 - Alteração de outros dados (Alteração de dados do pagador'),
+ ('40', '40 - Alteração de Carteira')]
+ )
+
@api.multi
@api.depends('percent_interest', 'amount_currency')
def _compute_interest(self):
@@ -124,4 +149,5 @@ def default_get(self, fields_list):
)
if mode.favored_warning:
res.update({'favored_warning': mode.favored_warning})
+
return res
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index cc8ba6782fc0..322abc7defa7 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -279,6 +279,12 @@ class AccountPaymentMode(models.Model):
help='Conta padrão para a Tarifa Bancaria',
)
+ # Foi preciso criar esse campo pois o CNAB 400 não
+ # parece padronizado (olhar dados na pasta Data),
+ # dessa forma novas implementações
+ # do 400 podem ser feitas atraves de cadastro,
+ # o CNAB 240 parece ser mais padronizado.
+ # TODO - tornar o campo invisivel no caso do 240 ?
cnab_liq_return_move_code_ids = fields.Many2many(
comodel_name='cnab.return.move.code',
relation='cnab_return_liquidity_move_code_rel',
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 9413334838d7..e4b29a7e847d 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -73,13 +73,6 @@ class AccountPaymentOrder(models.Model):
default='0',
)
- movement_instruction_code = fields.Selection(
- selection=CODIGO_INSTRUCAO_MOVIMENTO,
- string='Código da Instrução para Movimento',
- help='Campo G061 do CNAB',
- default='00',
- )
-
bank_line_error_ids = fields.One2many(
comodel_name='bank.payment.line',
inverse_name='order_id',
diff --git a/l10n_br_account_payment_order/views/account_move_line.xml b/l10n_br_account_payment_order/views/account_move_line.xml
index 9cf3a31bc559..a7301de7c403 100644
--- a/l10n_br_account_payment_order/views/account_move_line.xml
+++ b/l10n_br_account_payment_order/views/account_move_line.xml
@@ -22,6 +22,7 @@
+
diff --git a/l10n_br_account_payment_order/views/account_payment_line.xml b/l10n_br_account_payment_order/views/account_payment_line.xml
index ce90a3edf396..881d94bb922d 100644
--- a/l10n_br_account_payment_order/views/account_payment_line.xml
+++ b/l10n_br_account_payment_order/views/account_payment_line.xml
@@ -6,10 +6,10 @@
-->
-
- l10n_br_account.payment.line.form
+
+ l10n_br_account_payment_order.payment.line.form
account.payment.line
- primary
+
@@ -21,6 +21,7 @@
+
diff --git a/l10n_br_account_payment_order/views/account_payment_order.xml b/l10n_br_account_payment_order/views/account_payment_order.xml
index 4fcb10321bdf..b0aa79405fbf 100644
--- a/l10n_br_account_payment_order/views/account_payment_order.xml
+++ b/l10n_br_account_payment_order/views/account_payment_order.xml
@@ -33,7 +33,6 @@
-
From a675b1ebcc45d2e622711b37fa718972ebc6301b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 30 Oct 2020 13:30:41 -0300
Subject: [PATCH 311/612] [IMP] Included return movement code for CNAB 240.
---
.../data/cnab_return_move_code_data.xml | 114 +++++++++++++++++-
.../views/cnab_return_move_code_view.xml | 22 ++++
2 files changed, 135 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
index eba90664630d..90cd0fa464b4 100644
--- a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
+++ b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
@@ -1,7 +1,119 @@
-
+
+
+
+
+ Entrada Confirmada
+ 02
+
+
+
+
+ Entrada Rejeitada
+ 03
+
+
+
+
+ Liquidação
+ 06
+
+
+
+
+ Confirmação do Recebimento da Instrução de Desconto
+ 07
+
+
+
+
+ Confirmação do Recebimento do Cancelamento da Instrução de Desconto
+ 08
+
+
+
+
+ Baixa
+ 09
+
+
+
+
+ Confirmação do Recebimento da Instrução de Repactuação
+ 10
+
+
+
+
+ Confirmação do Recebimento da Instrução de Abatimento
+ 12
+
+
+
+
+ Confirmação do Recebimento do Cancelamento da Instrução de Abatimento
+ 13
+
+
+
+
+ Confirmação do Recebimento da Instrução de Alteração de Vencimento
+ 14
+
+
+
+
+ Liquidação após Baixa ou Liquidação Título não Registrado
+ 17
+
+
+
+
+ Instrução Rejeitada
+ 26
+
+
+
+
+ Confirmação do Pedido de Alteração de Outros Dados
+ 27
+
+
+
+
+ Alteração de Dados Rejeitada
+ 30
+
+
+
+
+ Concentração (Será informado apenas no arquivo retorno dos dados do Comprador)
+ 36
+
+
+
+
+ Títulos debitados a Empresa após o término da carência
+ 37
+
+
+
+
+ Títulos pagosem atraso creditados a Empresa
+ 38
+
+
diff --git a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
index b870035969ba..cc0f1abcdc02 100644
--- a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
+++ b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
@@ -38,6 +38,28 @@
tree,form
+
+ cnab.return.move.code.search
+ cnab.return.move.code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 76f018b4018879c1f1466aa7e81c6ee9a4cd3a0e Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 12:04:14 -0300
Subject: [PATCH 314/612] [REF] Default and domain value for CNAB Return Move
Codes.
---
.../models/account_payment_mode.py | 42 ++++++++++++++++++-
.../views/account_payment_mode.xml | 3 +-
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 322abc7defa7..2ecd3dee19bb 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -284,13 +284,24 @@ class AccountPaymentMode(models.Model):
# dessa forma novas implementações
# do 400 podem ser feitas atraves de cadastro,
# o CNAB 240 parece ser mais padronizado.
- # TODO - tornar o campo invisivel no caso do 240 ?
cnab_liq_return_move_code_ids = fields.Many2many(
comodel_name='cnab.return.move.code',
relation='cnab_return_liquidity_move_code_rel',
column1='cnab_liq_return_move_code_id',
column2='payment_mode_id',
- string='CNAB Liquidity Return Move Code')
+ string='CNAB Liquidity Return Move Code'
+ )
+ # TODO - pode ser melhorado ?
+ # Só foi possível ter um Domain de forma dinamica,
+ # devido a diferença no caso do 240
+ domain_cnab_liq_return_move_code_ids = fields.Many2many(
+ comodel_name='cnab.return.move.code',
+ relation='domain_cnab_return_liquidity_move_code_rel',
+ column1='domain_cnab_liq_return_move_code_id',
+ column2='payment_mode_id',
+ compute='_get_domain_cnab_liq_return_move_code',
+ store=False,
+ )
_sql_constraints = [(
"internal_sequence_id_unique",
@@ -353,3 +364,30 @@ def _check_discount_perc(self):
record.boleto_discount_perc < 0:
raise ValidationError(
_('O percentual deve ser um valor entre 0 a 100.'))
+
+ @api.onchange('payment_method_id')
+ def _onchange_payment_method_id(self):
+ # Valores Padrões de Liquidação/Baixa do
+ # CNAB 240, parece ser mais padronizado
+ for record in self:
+ if record.payment_method_id.code == '240':
+ liq_codes = self.env['cnab.return.move.code'].search([
+ ('payment_method_code', '=', '240'),
+ ('code', 'in', ['06', '09', '17'])
+ ])
+ record.cnab_liq_return_move_code_ids = liq_codes.ids
+
+ @api.multi
+ @api.depends('payment_method_id', 'bank_code_bc')
+ def _get_domain_cnab_liq_return_move_code(self):
+ for record in self:
+ search_domain = [
+ ('payment_method_code', '=', record.payment_method_id.code)]
+ if record.payment_method_id.code != '240':
+ search_domain.append(
+ ('bank_code_bc', '=', record.bank_code_bc))
+
+ return_codes = self.env[
+ 'cnab.return.move.code'].search(search_domain)
+
+ record.domain_cnab_liq_return_move_code_ids = return_codes.ids
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 19d7a72d3962..9e3e0e3c5219 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -55,8 +55,9 @@
+
+ domain="[('id','in', domain_cnab_liq_return_move_code_ids)]"/>
From b3918b8eb089924d7875d191d4200e9c783b315b Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 13:09:23 -0300
Subject: [PATCH 315/612] [FIX] Using standard name for the objects related to
CNAB Return Log.
---
.../models/bank_payment_line.py | 2 +-
.../models/cnab_return_log.py | 6 +--
.../models/l10n_br_cnab_evento.py | 10 +++--
.../models/l10n_br_cnab_lote.py | 6 +--
.../security/ir.model.access.csv | 12 +++---
.../views/cnab_return_log_view.xml | 38 +++++++++----------
6 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/l10n_br_account_payment_order/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
index 7b0420bea48c..401240809e14 100644
--- a/l10n_br_account_payment_order/models/bank_payment_line.py
+++ b/l10n_br_account_payment_order/models/bank_payment_line.py
@@ -88,7 +88,7 @@ def default_get(self, fields_list):
event_id = fields.One2many(
string='Eventos CNAB',
- comodel_name='cnab.return.event',
+ comodel_name='l10n_br_cnab.return.event',
inverse_name='bank_payment_line_id',
readonly=True,
)
diff --git a/l10n_br_account_payment_order/models/cnab_return_log.py b/l10n_br_account_payment_order/models/cnab_return_log.py
index fea307ab1fc3..9933e607656c 100644
--- a/l10n_br_account_payment_order/models/cnab_return_log.py
+++ b/l10n_br_account_payment_order/models/cnab_return_log.py
@@ -5,11 +5,11 @@
from odoo import models, fields
-class CNABReturnLog(models.Model):
+class L10nBrCNABReturnLog(models.Model):
"""
The class is used to register the LOG of CNAB return file.
"""
- _name = 'cnab.return.log'
+ _name = 'l10n_br_cnab.return.log'
_inherit = ['mail.thread', 'mail.activity.mixin']
_description = 'CNAB Return Log'
@@ -28,7 +28,7 @@ class CNABReturnLog(models.Model):
cnab_date_file = fields.Date(string='CNAB Date File')
event_ids = fields.One2many(
- string='Eventos', comodel_name='cnab.return.event',
+ string='Eventos', comodel_name='l10n_br_cnab.return.event',
inverse_name='cnab_return_log_id'
)
amount_total_title = fields.Float(string='Valor Total Títulos')
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
index d0d6ba9954e8..2af0744c153d 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
@@ -5,21 +5,23 @@
from odoo import fields, models
-class CNABReturnEvent(models.Model):
+class L10nBrCNABReturnEvent(models.Model):
"""
The class is used to register the Events of CNAB return file.
"""
- _name = 'cnab.return.event'
+ _name = 'l10n_br_cnab.return.event'
_description = 'CNAB Return Event'
cnab_return_log_id = fields.Many2one(
- string='CNAB Return Log', comodel_name='cnab.return.log',
+ string='CNAB Return Log', comodel_name='l10n_br_cnab.return.log',
)
# Field used to make invisible/visible fields refer to Lot
is_cnab_lot = fields.Boolean(string='Is CNAB Lot?')
# O arquivo de Retorno pode ter ou não Lotes
lot_id = fields.Many2one(
- string='Lote', comodel_name='cnab.return.lot', ondelete='cascade'
+ string='Lote',
+ comodel_name='l10n_br_cnab.return.lot',
+ ondelete='cascade'
)
bank_payment_line_id = fields.Many2one(
string='Bank Payment Line', comodel_name='bank.payment.line'
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
index 863a1a6a02c9..01768f1d4f10 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
@@ -5,15 +5,15 @@
from odoo import fields, models
-class CNABReturnLot(models.Model):
+class L10nBrCNABReturnLot(models.Model):
"""
The class is used to register the Lots of Events in CNAB return file.
"""
- _name = 'cnab.return.lot'
+ _name = 'l10n_br_cnab.return.lot'
_description = 'CNAB Return Lot'
lot_event_ids = fields.One2many(
- string='Eventos', comodel_name='cnab.return.event',
+ string='Eventos', comodel_name='l10n_br_cnab.return.event',
inverse_name='lot_id'
)
# TODO - deveria ter alguma relação com o objeto cnab.return.log
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index f49d3758e11d..0949720ac1ec 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -1,9 +1,9 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_cnab_return_move_code_user,access_cnab_return_move_code_user,model_cnab_return_move_code,group_cnab_user,1,0,0,0
access_cnab_return_move_code_manager,access_cnab_return_move_code_manager,model_cnab_return_move_code,group_cnab_manager,1,1,1,1
-access_cnab_return_log_user,access_cnab_return_log_user,model_cnab_return_log,group_cnab_user,1,1,1,0
-access_cnab_return_log_manager,access_cnab_return_log_manager,model_cnab_return_log,group_cnab_manager,1,1,1,1
-access_cnab_return_event_user,access_cnab_return_event_user,model_cnab_return_event,group_cnab_user,1,1,1,0
-access_cnab_return_event_manager,access_cnab_return_event_manager,model_cnab_return_event,group_cnab_manager,1,1,1,1
-access_cnab_return_lot_user,access_cnab_return_lot_user,model_cnab_return_lot,group_cnab_user,1,1,1,0
-access_cnab_return_lot_manager,access_cnab_return_lot_manager,model_cnab_return_lot,group_cnab_manager,1,1,1,1
\ No newline at end of file
+access_l10n_br_cnab_return_log_user,access_l10n_br_cnab_return_log_user,model_l10n_br_cnab_return_log,group_cnab_user,1,1,1,0
+access_l10n_br_cnab_return_log_manager,access_l10n_br_cnab_return_log_manager,model_l10n_br_cnab_return_log,group_cnab_manager,1,1,1,1
+access_l10n_br_cnab_return_event_user,access_l10n_br_cnab_return_event_user,model_l10n_br_cnab_return_event,group_cnab_user,1,1,1,0
+access_l10n_br_cnab_return_event_manager,access_l10n_br_cnab_return_event_manager,model_l10n_br_cnab_return_event,group_cnab_manager,1,1,1,1
+access_l10n_br_cnab_return_lot_user,access_l10n_br_cnab_return_lot_user,model_l10n_br_cnab_return_lot,group_cnab_user,1,1,1,0
+access_l10n_br_cnab_return_lot_manager,access_l10n_br_cnab_return_lot_manager,model_l10n_br_cnab_return_lot,group_cnab_manager,1,1,1,1
\ No newline at end of file
diff --git a/l10n_br_account_payment_order/views/cnab_return_log_view.xml b/l10n_br_account_payment_order/views/cnab_return_log_view.xml
index 9241e941e67e..b54560ce3918 100644
--- a/l10n_br_account_payment_order/views/cnab_return_log_view.xml
+++ b/l10n_br_account_payment_order/views/cnab_return_log_view.xml
@@ -1,9 +1,9 @@
-
- cnab.return.log.tree
- cnab.return.log
+
+ l10n_br_cnab.return.log.tree
+ l10n_br_cnab.return.log
@@ -19,9 +19,9 @@
-
- cnab.return.log.form.view
- cnab.return.log
+
+ l10n_br_cnab.return.log.form.view
+ l10n_br_cnab.return.log
@@ -65,9 +65,9 @@
-
- cnab.return.event.tree
- cnab.return.event
+
+ l10n_br_cnab.return.event.tree
+ l10n_br_cnab.return.event
@@ -92,9 +92,9 @@
-
- cnab.return.lot.form.view
- cnab.return.lot
+
+ l10n_br_cnab.return.lot.form.view
+ l10n_br_cnab.return.lot
@@ -107,7 +107,7 @@
-
+
- cnab.return.log.search
- cnab.return.log
+ l10n_br_cnab.return.log.search
+ l10n_br_cnab.return.log
@@ -140,16 +140,16 @@
-
+
CNAB Return Log
- cnab.return.log
+ l10n_br_cnab.return.log
form
tree,form
-
+ action="l10n_br_account_payment_order.l10n_br_cnab_return_log_action"/>
From a948e470253cb86a4dae505376087ed8d8136b24 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 13:18:24 -0300
Subject: [PATCH 316/612] [FIX] Update name of files and views related to CNAB
Return Log.
---
l10n_br_account_payment_order/__manifest__.py | 2 +-
l10n_br_account_payment_order/models/__init__.py | 6 +++---
.../{l10n_br_cnab_evento.py => l10n_br_cnab_event.py} | 0
.../models/{l10n_br_cnab_lote.py => l10n_br_cnab_lot.py} | 0
.../{cnab_return_log.py => l10n_br_cnab_return_log.py} | 0
...return_log_view.xml => l10n_br_cnab_return_log_view.xml} | 0
6 files changed, 4 insertions(+), 4 deletions(-)
rename l10n_br_account_payment_order/models/{l10n_br_cnab_evento.py => l10n_br_cnab_event.py} (100%)
rename l10n_br_account_payment_order/models/{l10n_br_cnab_lote.py => l10n_br_cnab_lot.py} (100%)
rename l10n_br_account_payment_order/models/{cnab_return_log.py => l10n_br_cnab_return_log.py} (100%)
rename l10n_br_account_payment_order/views/{cnab_return_log_view.xml => l10n_br_cnab_return_log_view.xml} (100%)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 36ce4225c767..985fae29f1e0 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -55,7 +55,7 @@
# 'views/l10n_br_payment_cnab.xml',
# 'views/l10n_br_cobranca_cnab.xml',
# 'views/l10n_br_cobranca_cnab_lines.xml',
- 'views/cnab_return_log_view.xml',
+ 'views/l10n_br_cnab_return_log_view.xml',
'views/account_invoice.xml',
'views/account_move_line.xml',
'views/cnab_return_move_code_view.xml',
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 60b98c88062d..81214f47b719 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -20,8 +20,8 @@
# a implementação de outra forma de importação pois tem os metodos que eram
# usados pela KMEE e o historico git do arquivo
# from . import l10n_br_cnab
-from . import l10n_br_cnab_evento
-from . import l10n_br_cnab_lote
+from . import l10n_br_cnab_event
+from . import l10n_br_cnab_lot
from . import cnab_return_move_code
-from . import cnab_return_log
+from . import l10n_br_cnab_return_log
from . import ir_attachment
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_evento.py b/l10n_br_account_payment_order/models/l10n_br_cnab_event.py
similarity index 100%
rename from l10n_br_account_payment_order/models/l10n_br_cnab_evento.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_event.py
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_lote.py b/l10n_br_account_payment_order/models/l10n_br_cnab_lot.py
similarity index 100%
rename from l10n_br_account_payment_order/models/l10n_br_cnab_lote.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_lot.py
diff --git a/l10n_br_account_payment_order/models/cnab_return_log.py b/l10n_br_account_payment_order/models/l10n_br_cnab_return_log.py
similarity index 100%
rename from l10n_br_account_payment_order/models/cnab_return_log.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_return_log.py
diff --git a/l10n_br_account_payment_order/views/cnab_return_log_view.xml b/l10n_br_account_payment_order/views/l10n_br_cnab_return_log_view.xml
similarity index 100%
rename from l10n_br_account_payment_order/views/cnab_return_log_view.xml
rename to l10n_br_account_payment_order/views/l10n_br_cnab_return_log_view.xml
From 3b18d4362f92f1ff6d8ffb10394323d41b1604e2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 15:23:41 -0300
Subject: [PATCH 317/612] [REF] Rename objects related to CNAB Return Move Code
to has standard name.
---
.../data/cnab_return_move_code_data.xml | 288 +++++++++---------
.../models/account_payment_mode.py | 12 +-
.../models/cnab_return_move_code.py | 4 +-
.../security/ir.model.access.csv | 4 +-
.../views/cnab_return_move_code_view.xml | 26 +-
5 files changed, 167 insertions(+), 167 deletions(-)
diff --git a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
index 90cd0fa464b4..002e2b1189e3 100644
--- a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
+++ b/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
@@ -13,180 +13,180 @@
-
+
Entrada Confirmada
02
-
+
Entrada Rejeitada
03
-
+
Liquidação
06
-
+
Confirmação do Recebimento da Instrução de Desconto
07
-
+
Confirmação do Recebimento do Cancelamento da Instrução de Desconto
08
-
+
Baixa
09
-
+
Confirmação do Recebimento da Instrução de Repactuação
10
-
+
Confirmação do Recebimento da Instrução de Abatimento
12
-
+
Confirmação do Recebimento do Cancelamento da Instrução de Abatimento
13
-
+
Confirmação do Recebimento da Instrução de Alteração de Vencimento
14
-
+
Liquidação após Baixa ou Liquidação Título não Registrado
17
-
+
Instrução Rejeitada
26
-
+
Confirmação do Pedido de Alteração de Outros Dados
27
-
+
Alteração de Dados Rejeitada
30
-
+
Concentração (Será informado apenas no arquivo retorno dos dados do Comprador)
36
-
+
Títulos debitados a Empresa após o término da carência
37
-
+
Títulos pagosem atraso creditados a Empresa
38
-
+
Pago (Título protestado pago em cartório)
01
-
+
Instrução Confirmada*
02
-
+
Instrução Rejeitada*
03
-
+
Sustado Judicial (Título protestado sustado judicialmente)
04
-
+
Liquidação Normal *
06
-
+
Liquidação em Condicional (Título liquidado em cartório com cheque do próprio devedor)
07
-
+
Sustado Definitivo (Título protestado sustado judicialmente)
08
-
+
Liquidação de Título Descontado
09
-
+
Protesto solicitado
10
-
+
Protesto Em cartório
11
-
+
Sustação solicitada
12
@@ -194,245 +194,245 @@
-
+
Entrada Confirmada
02
-
+
Entrada Rejeitada
03
-
+
Liquidação Normal *
06
-
+
Baixado Automat. via Arquivo
09
-
+
Baixado conforme instruções da Agência
10
-
+
Em Ser - Arquivo de Títulos pendentes
11
-
+
Abatimento Concedido
12
-
+
Abatimento Cancelado
13
-
+
Vencimento Alterado
14
-
+
Liquidação em Cartório
15
-
+
Título Pago em Cheque – Vinculado
16
-
+
Liquidação após baixa ou Título não registrado
17
-
+
Acerto de Depositária
18
-
+
Confirmação Receb. Inst. de Protesto
19
-
+
Confirmação Recebimento Instrução Sustação de Protesto
20
-
+
Acerto do Controle do Participante (sem motivo)
21
-
+
Título Com Pagamento Cancelado
22
-
+
Entrada do Título em Cartório (sem motivo)
23
-
+
Entrada rejeitada por CEP Irregular
24
-
+
Confirmação Receb.Inst.de Protesto Falimentar
25
-
+
Baixa Rejeitada
27
-
+
Débito de tarifas/custas
28
-
+
Ocorrências do Pagador (NOVO)
29
-
+
Alteração de Outros Dados Rejeitados
30
-
+
Instrução Rejeitada
32
-
+
Confirmação Pedido Alteração Outros Dados (sem motivo)
33
-
+
Retirado de Cartório e Manutenção Carteira
34
-
+
Desagendamento do débito automático
35
-
+
Estorno de pagamento
40
-
+
Sustado judicial
55
-
+
Acerto dos dados do rateio de Crédito
68
-
+
Cancelamento dos dados do rateio
69
-
+
Confirmação Receb. Pedido de Negativação
73
-
+
Confir Pedido de Excl de Negat (com ou sem baixa)
74
-
+
Nota: Para as ocorrências sem motivos, as posições serão informadas com Zeros.
00
@@ -440,567 +440,567 @@
-
+
ENTRADA CONFIRMADA COM POSSIBILIDADE DE MENSAGEM
02
-
+
ENTRADA REJEITADA
03
-
+
ALTERAÇÃO DE DADOS – NOVA ENTRADA OU ALTERAÇÃO/EXCLUSÃO DE DADOS ACATADA
04
-
+
ALTERAÇÃO DE DADOS – BAIXA
05
-
+
Liquidação Normal
06
-
+
LIQUIDAÇÃO PARCIAL – COBRANÇA INTELIGENTE (B2B)
07
-
+
LIQUIDAÇÃO EM CARTÓRIO
08
-
+
BAIXA SIMPLES
09
-
+
BAIXA POR TER SIDO LIQUIDADO
10
-
+
EM SER (SÓ NO RETORNO MENSAL)
11
-
+
ABATIMENTO CONCEDIDO
12
-
+
ABATIMENTO CANCELADO
13
-
+
VENCIMENTO ALTERADO
14
-
+
BAIXAS REJEITADAS (NOTA 20 – TABELA 4)
15
-
+
INSTRUÇÕES REJEITADAS (NOTA 20 – TABELA 3)
16
-
+
ALTERAÇÃO/EXCLUSÃO DE DADOS REJEITADOS (NOTA 20 – TABELA 2)
17
-
+
COBRANÇA CONTRATUAL – INSTRUÇÕES/ALTERAÇÕES REJEITADAS/PENDENTES (NOTA 20 – TABELA 5)
18
-
+
CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE PROTESTO
19
-
+
CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE SUSTAÇÃO DE PROTESTO /TARIFA
20
-
+
CONFIRMA RECEBIMENTO DE INSTRUÇÃO DE NÃO PROTESTAR
21
-
+
TÍTULO ENVIADO A CARTÓRIO/TARIFA
23
-
+
INSTRUÇÃO DE PROTESTO REJEITADA / SUSTADA / PENDENTE (NOTA 20 – TABELA 7)
24
-
+
ALEGAÇÕES DO PAGADOR (NOTA 20 – TABELA 6)
25
-
+
TARIFA DE AVISO DE COBRANÇA
26
-
+
TARIFA DE EXTRATO POSIÇÃO (B40X)
27
-
+
TARIFA DE RELAÇÃO DAS LIQUIDAÇÕES
28
-
+
TARIFA DE MANUTENÇÃO DE TÍTULOS VENCIDOS
29
-
+
DÉBITO MENSAL DE TARIFAS (PARA ENTRADAS E BAIXAS)
30
-
+
BAIXA POR TER SIDO PROTESTADO
32
-
+
CUSTAS DE PROTESTO
33
-
+
CUSTAS DE SUSTAÇÃO
34
-
+
CUSTAS DE CARTÓRIO DISTRIBUIDOR
35
-
+
CUSTAS DE EDITAL
36
-
+
TARIFA DE EMISSÃO DE BOLETO/TARIFA DE ENVIO DE DUPLICATA
37
-
+
TARIFA DE INSTRUÇÃO
38
-
+
TARIFA DE OCORRÊNCIAS
39
-
+
TARIFA MENSAL DE EMISSÃO DE BOLETO/TARIFA MENSAL DE ENVIO DE DUPLICATA
40
-
+
DÉBITO MENSAL DE TARIFAS – EXTRATO DE POSIÇÃO (B4EP/B4OX)
41
-
+
DÉBITO MENSAL DE TARIFAS – OUTRAS INSTRUÇÕES
42
-
+
DÉBITO MENSAL DE TARIFAS – MANUTENÇÃO DE TÍTULOS VENCIDOS
43
-
+
DÉBITO MENSAL DE TARIFAS – OUTRAS OCORRÊNCIAS
44
-
+
DÉBITO MENSAL DE TARIFAS – PROTESTO
45
-
+
DÉBITO MENSAL DE TARIFAS – SUSTAÇÃO DE PROTESTO
46
-
+
BAIXA COM TRANSFERÊNCIA PARA DESCONTO
47
-
+
CUSTAS DE SUSTAÇÃO JUDICIAL
48
-
+
TARIFA MENSAL REF A ENTRADAS BANCOS CORRESPONDENTES NA CARTEIRA
51
-
+
TARIFA MENSAL BAIXAS NA CARTEIRA
52
-
+
TARIFA MENSAL BAIXAS EM BANCOS CORRESPONDENTES NA CARTEIRA
53
-
+
TARIFA MENSAL DE LIQUIDAÇÕES NA CARTEIRA
54
-
+
TARIFA MENSAL DE LIQUIDAÇÕES EM BANCOS CORRESPONDENTES NA CARTEIRA
55
-
+
CUSTAS DE IRREGULARIDADE
56
-
+
INSTRUÇÃO CANCELADA (NOTA 20 – TABELA 8)
57
-
+
BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG
59
-
+
ENTRADA REJEITADA CARNÊ (NOTA 20 – TABELA 1)
60
-
+
TARIFA EMISSÃO AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)
61
-
+
DÉBITO MENSAL DE TARIFA – AVISO DE MOVIMENTAÇÃO DE TÍTULOS (2154)
62
-
+
TÍTULO SUSTADO JUDICIALMENTE
63
-
+
ENTRADA CONFIRMADA COM RATEIO DE CRÉDITO
64
-
+
PAGAMENTO COM CHEQUE – AGUARDANDO COMPENSAÇÃO
65
-
+
CHEQUE DEVOLVIDO (NOTA 20 – TABELA 9)
69
-
+
ENTRADA REGISTRADA, AGUARDANDO AVALIAÇÃO
71
-
+
BAIXA POR CRÉDITO EM C/C ATRAVÉS DO SISPAG SEM TÍTULO CORRESPONDENTE
72
-
+
CONFIRMAÇÃO DE ENTRADA NA COBRANÇA SIMPLES – ENTRADA NÃO ACEITA NA COBRANÇA CONTRATUAL
73
-
+
INSTRUÇÃO DE NEGATIVAÇÃO EXPRESSA REJEITADA (NOTA 20 – TABELA 11)
74
-
+
CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA
75
-
+
CHEQUE COMPENSADO
76
-
+
CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA
77
-
+
CONFIRMAÇÃO DE RECEBIMENTO DE INSTRUÇÃO DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA
78
-
+
NEGATIVAÇÃO EXPRESSA INFORMACIONAL (NOTA 20 – TABELA 12)
79
-
+
CONFIRMAÇÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA – TARIFA
80
-
+
CONFIRMAÇÃO DO CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA – TARIFA
82
-
+
CONFIRMAÇÃO DE EXCLUSÃO DE ENTRADA EM NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO – TARIFA
83
-
+
TARIFA POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA
85
-
+
TARIFA EMAIL COBRANÇA ATIVA ELETRÔNICA
86
-
+
TARIFA SMS COBRANÇA ATIVA ELETRÔNICA
87
-
+
TARIFA MENSAL POR BOLETO (ATÉ 03 ENVIOS) COBRANÇA ATIVA ELETRÔNICA
88
-
+
TARIFA MENSAL EMAIL COBRANÇA ATIVA ELETRÔNICA
89
-
+
TARIFA MENSAL SMS COBRANÇA ATIVA ELETRÔNICA
90
-
+
TARIFA MENSAL DE EXCLUSÃO DE ENTRADA DE NEGATIVAÇÃO EXPRESSA
91
-
+
TARIFA MENSAL DE CANCELAMENTO DE NEGATIVAÇÃO EXPRESSA
92
-
+
TARIFA MENSAL DE EXCLUSÃO DE NEGATIVAÇÃO EXPRESSA POR LIQUIDAÇÃO
93
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 2ecd3dee19bb..2e35de2d5b05 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -285,8 +285,8 @@ class AccountPaymentMode(models.Model):
# do 400 podem ser feitas atraves de cadastro,
# o CNAB 240 parece ser mais padronizado.
cnab_liq_return_move_code_ids = fields.Many2many(
- comodel_name='cnab.return.move.code',
- relation='cnab_return_liquidity_move_code_rel',
+ comodel_name='l10n_br_cnab.return.move.code',
+ relation='l10n_br_cnab_return_liquidity_move_code_rel',
column1='cnab_liq_return_move_code_id',
column2='payment_mode_id',
string='CNAB Liquidity Return Move Code'
@@ -295,8 +295,8 @@ class AccountPaymentMode(models.Model):
# Só foi possível ter um Domain de forma dinamica,
# devido a diferença no caso do 240
domain_cnab_liq_return_move_code_ids = fields.Many2many(
- comodel_name='cnab.return.move.code',
- relation='domain_cnab_return_liquidity_move_code_rel',
+ comodel_name='l10n_br_cnab.return.move.code',
+ relation='domain_l10n_br_cnab_return_liquidity_move_code_rel',
column1='domain_cnab_liq_return_move_code_id',
column2='payment_mode_id',
compute='_get_domain_cnab_liq_return_move_code',
@@ -371,7 +371,7 @@ def _onchange_payment_method_id(self):
# CNAB 240, parece ser mais padronizado
for record in self:
if record.payment_method_id.code == '240':
- liq_codes = self.env['cnab.return.move.code'].search([
+ liq_codes = self.env['l10n_br_cnab.return.move.code'].search([
('payment_method_code', '=', '240'),
('code', 'in', ['06', '09', '17'])
])
@@ -388,6 +388,6 @@ def _get_domain_cnab_liq_return_move_code(self):
('bank_code_bc', '=', record.bank_code_bc))
return_codes = self.env[
- 'cnab.return.move.code'].search(search_domain)
+ 'l10n_br_cnab.return.move.code'].search(search_domain)
record.domain_cnab_liq_return_move_code_ids = return_codes.ids
diff --git a/l10n_br_account_payment_order/models/cnab_return_move_code.py b/l10n_br_account_payment_order/models/cnab_return_move_code.py
index b18a2f73c3f6..fedc4e11bd19 100644
--- a/l10n_br_account_payment_order/models/cnab_return_move_code.py
+++ b/l10n_br_account_payment_order/models/cnab_return_move_code.py
@@ -5,11 +5,11 @@
from odoo import models, api, fields
-class CNABReturnMoveCode(models.Model):
+class L10nBrCNABReturnMoveCode(models.Model):
"""
CNAB return code, each Bank can has a list of Codes
"""
- _name = 'cnab.return.move.code'
+ _name = 'l10n_br_cnab.return.move.code'
_description = 'CNAB Return Move Code'
name = fields.Char(
diff --git a/l10n_br_account_payment_order/security/ir.model.access.csv b/l10n_br_account_payment_order/security/ir.model.access.csv
index 0949720ac1ec..f5d54e5cbb1c 100644
--- a/l10n_br_account_payment_order/security/ir.model.access.csv
+++ b/l10n_br_account_payment_order/security/ir.model.access.csv
@@ -1,6 +1,6 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-access_cnab_return_move_code_user,access_cnab_return_move_code_user,model_cnab_return_move_code,group_cnab_user,1,0,0,0
-access_cnab_return_move_code_manager,access_cnab_return_move_code_manager,model_cnab_return_move_code,group_cnab_manager,1,1,1,1
+access_l10n_br_cnab_return_move_code_user,access_l10n_br_cnab_return_move_code_user,model_l10n_br_cnab_return_move_code,group_cnab_user,1,0,0,0
+access_l10n_br_cnab_return_move_code_manager,access_l10n_br_cnab_return_move_code_manager,model_l10n_br_cnab_return_move_code,group_cnab_manager,1,1,1,1
access_l10n_br_cnab_return_log_user,access_l10n_br_cnab_return_log_user,model_l10n_br_cnab_return_log,group_cnab_user,1,1,1,0
access_l10n_br_cnab_return_log_manager,access_l10n_br_cnab_return_log_manager,model_l10n_br_cnab_return_log,group_cnab_manager,1,1,1,1
access_l10n_br_cnab_return_event_user,access_l10n_br_cnab_return_event_user,model_l10n_br_cnab_return_event,group_cnab_user,1,1,1,0
diff --git a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
index cc0f1abcdc02..53332e7bfe56 100644
--- a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
+++ b/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
@@ -1,9 +1,9 @@
-
- cnab.return.move.code.tree
- cnab.return.move.code
+
+ l10n_br_cnab.return.move.code.tree
+ l10n_br_cnab.return.move.code
@@ -14,9 +14,9 @@
-
- cnab.return.move.code.form.view
- cnab.return.move.code
+
+ l10n_br_cnab.return.move.code.form.view
+ l10n_br_cnab.return.move.code
@@ -31,16 +31,16 @@
-
+
CNAB Return Move Code
- cnab.return.move.code
+ l10n_br_cnab.return.move.code
form
tree,form
-
- cnab.return.move.code.search
- cnab.return.move.code
+
+ l10n_br_cnab.return.move.code.search
+ l10n_br_cnab.return.move.code
@@ -60,9 +60,9 @@
-
+ action="l10n_br_cnab_return_move_code_action"/>
From 08ef927c82b4bd55f309cc394e8f4cf92258120d Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 15:45:31 -0300
Subject: [PATCH 318/612] [REF] Rename models and views related to CNAB Return
Move Code to has standard name.
---
l10n_br_account_payment_order/__manifest__.py | 4 ++--
...e_code_data.xml => l10n_br_cnab_return_move_code_data.xml} | 0
l10n_br_account_payment_order/models/__init__.py | 2 +-
...b_return_move_code.py => l10n_br_cnab_return_move_code.py} | 0
...e_code_view.xml => l10n_br_cnab_return_move_code_view.xml} | 0
5 files changed, 3 insertions(+), 3 deletions(-)
rename l10n_br_account_payment_order/data/{cnab_return_move_code_data.xml => l10n_br_cnab_return_move_code_data.xml} (100%)
rename l10n_br_account_payment_order/models/{cnab_return_move_code.py => l10n_br_cnab_return_move_code.py} (100%)
rename l10n_br_account_payment_order/views/{cnab_return_move_code_view.xml => l10n_br_cnab_return_move_code_view.xml} (100%)
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 985fae29f1e0..8566b0a9a3bc 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -27,7 +27,7 @@
'data/l10n_br_payment_export_type.xml',
'data/boleto_data.xml',
'data/account_analytic_tag_data.xml',
- 'data/cnab_return_move_code_data.xml',
+ 'data/l10n_br_cnab_return_move_code_data.xml',
# Reports
'reports/report_print_button_view.xml',
@@ -58,7 +58,7 @@
'views/l10n_br_cnab_return_log_view.xml',
'views/account_invoice.xml',
'views/account_move_line.xml',
- 'views/cnab_return_move_code_view.xml',
+ 'views/l10n_br_cnab_return_move_code_view.xml',
],
'demo': [
'demo/res_partner_bank.xml',
diff --git a/l10n_br_account_payment_order/data/cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml
similarity index 100%
rename from l10n_br_account_payment_order/data/cnab_return_move_code_data.xml
rename to l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml
diff --git a/l10n_br_account_payment_order/models/__init__.py b/l10n_br_account_payment_order/models/__init__.py
index 81214f47b719..15ab37509a00 100644
--- a/l10n_br_account_payment_order/models/__init__.py
+++ b/l10n_br_account_payment_order/models/__init__.py
@@ -22,6 +22,6 @@
# from . import l10n_br_cnab
from . import l10n_br_cnab_event
from . import l10n_br_cnab_lot
-from . import cnab_return_move_code
+from . import l10n_br_cnab_return_move_code
from . import l10n_br_cnab_return_log
from . import ir_attachment
diff --git a/l10n_br_account_payment_order/models/cnab_return_move_code.py b/l10n_br_account_payment_order/models/l10n_br_cnab_return_move_code.py
similarity index 100%
rename from l10n_br_account_payment_order/models/cnab_return_move_code.py
rename to l10n_br_account_payment_order/models/l10n_br_cnab_return_move_code.py
diff --git a/l10n_br_account_payment_order/views/cnab_return_move_code_view.xml b/l10n_br_account_payment_order/views/l10n_br_cnab_return_move_code_view.xml
similarity index 100%
rename from l10n_br_account_payment_order/views/cnab_return_move_code_view.xml
rename to l10n_br_account_payment_order/views/l10n_br_cnab_return_move_code_view.xml
From 40f80fcf75b613b741592fb063fb536089b7891e Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 18:07:30 -0300
Subject: [PATCH 319/612] [REF] Payment Mode views to be more clear for users.
---
.../models/account_payment_mode.py | 2 +
.../views/account_payment_mode.xml | 43 ++++++++++++-------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_mode.py b/l10n_br_account_payment_order/models/account_payment_mode.py
index 2e35de2d5b05..4ec3f439bd55 100644
--- a/l10n_br_account_payment_order/models/account_payment_mode.py
+++ b/l10n_br_account_payment_order/models/account_payment_mode.py
@@ -302,6 +302,8 @@ class AccountPaymentMode(models.Model):
compute='_get_domain_cnab_liq_return_move_code',
store=False,
)
+ # Field used to make invisible Inbound or Outbound specifics fields
+ payment_type = fields.Selection(related='payment_method_id.payment_type')
_sql_constraints = [(
"internal_sequence_id_unique",
diff --git a/l10n_br_account_payment_order/views/account_payment_mode.xml b/l10n_br_account_payment_order/views/account_payment_mode.xml
index 9e3e0e3c5219..aa9d5fdbe9f0 100644
--- a/l10n_br_account_payment_order/views/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/views/account_payment_mode.xml
@@ -13,9 +13,14 @@
+
+
+
+
+
@@ -25,17 +30,12 @@
+
-
-
-
-
-
-
-
-
+
+
@@ -49,22 +49,35 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
From fe4dcf8a7828416ccfba0805099daab3ecd57ea6 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 3 Nov 2020 18:07:56 -0300
Subject: [PATCH 320/612] [IMP] Demo data.
---
l10n_br_account_payment_order/demo/account_payment_mode.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/l10n_br_account_payment_order/demo/account_payment_mode.xml b/l10n_br_account_payment_order/demo/account_payment_mode.xml
index fe8a0302e18d..32bdaea2fbd1 100644
--- a/l10n_br_account_payment_order/demo/account_payment_mode.xml
+++ b/l10n_br_account_payment_order/demo/account_payment_mode.xml
@@ -80,6 +80,10 @@
2
5
+ 2
+ 2
+ 2
+ 2
72234050
False
False
From 991f317fefcf781ecbf38af93e9c57f88dce1101 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Wed, 4 Nov 2020 03:36:53 +0000
Subject: [PATCH 321/612] fixed flake8
---
l10n_br_account_payment_order/models/account_move_line.py | 2 +-
l10n_br_account_payment_order/models/account_payment_order.py | 1 -
.../wizards/account_move_line_change.py | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 996f208e45eb..9d0a4c434d47 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -2,7 +2,7 @@
# Luis Felipe Miléo - mileo@kmee.com.br
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models, _
+from odoo import api, fields, models
from ..constants import ESTADOS_CNAB, SITUACAO_PAGAMENTO
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index e4b29a7e847d..afbb867bd719 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -13,7 +13,6 @@
from odoo import api, fields, models
from ..constants import (
- CODIGO_INSTRUCAO_MOVIMENTO,
FORMA_LANCAMENTO,
INDICATIVO_FORMA_PAGAMENTO,
TIPO_MOVIMENTO,
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.py b/l10n_br_account_payment_order/wizards/account_move_line_change.py
index a6c9bf852c75..8e3d3f7771cc 100644
--- a/l10n_br_account_payment_order/wizards/account_move_line_change.py
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.py
@@ -1,7 +1,7 @@
# Copyright 2020 KMEE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models, _
+from odoo import api, fields, models
class AccountMoveLineChange(models.TransientModel):
From 5aa290f846f55679ec0afba96f5bf336d302f394 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Wed, 4 Nov 2020 16:54:54 -0300
Subject: [PATCH 322/612] [FIX] Data of rename objects need migrations scripts
to avoid error.
---
l10n_br_account_payment_order/__manifest__.py | 2 +-
.../migrations/12.0.2.0.0/pre-migration.py | 15 +++++++++----
.../migrations/12.0.3.0.0/pre-migration.py | 22 +++++++++++++++++++
3 files changed, 34 insertions(+), 5 deletions(-)
create mode 100644 l10n_br_account_payment_order/migrations/12.0.3.0.0/pre-migration.py
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 8566b0a9a3bc..b89491c30347 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -4,7 +4,7 @@
{
'name': 'Brazilian Payment Order',
- 'version': '12.0.1.0.0',
+ 'version': '12.0.3.0.0',
'license': 'AGPL-3',
'author': "KMEE, "
"Akretion, "
diff --git a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
index c2fa5534eb75..37c3ea618f5d 100644
--- a/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/12.0.2.0.0/pre-migration.py
@@ -71,10 +71,6 @@
('mensagem_erro_exportacao', 'export_error_message'),
('ultimo_estado_cnab', 'last_cnab_state')
],
- # TODO - mover os cnab/lote/evento para o modulo de implentacao da KMEE,
- # já que para importacao do arquivo CNAB de retorno a Akretion passou a
- # usar o account_move_base_import, estou mantendo o código para permirtir
- # a extração e assim preservar o histórico de commits
'l10n_br.cnab.evento': [
('data_real_pagamento', 'real_payment_date'),
('data_ocorrencia', 'occurrence_date'),
@@ -107,6 +103,14 @@
('tipo_servico', 'service_type'),
('total_valores', 'total_value'),
],
+ # TODO - Separação dos dados de importação para um objeto especifico
+ # l10n_br_cnab.return.log armazenando o LOG do Arquivo de Retorno CNAB
+ # de forma separada e permitindo a integração com a alteração feita no
+ # modulo do BRCobranca onde se esta utilizando o modulo
+ # account_base_move_import para fazer essa tarefa de wizard de importação,
+ # o objeto l10n_br_cnab esta comentado para permitir, caso seja necessário,
+ # a implementação de outra forma de importação pois tem os metodos que eram
+ # usados pela KMEE e o historico git do arquivo
'l10n_br.cnab': [
('arquivo_retorno', 'return_file'),
('data', 'cnab_date'),
@@ -130,6 +134,9 @@
('eval_payment_mode_instrucoes', 'eval_payment_mode_instructions')
],
}
+# TODO - verificar na migração da 8/10 para 12, em uma base de dados nova não
+# existe os campos e objetos o que causa erro
+_column_renames = {}
@openupgrade.migrate(use_env=True)
diff --git a/l10n_br_account_payment_order/migrations/12.0.3.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/12.0.3.0.0/pre-migration.py
new file mode 100644
index 000000000000..a83c05208916
--- /dev/null
+++ b/l10n_br_account_payment_order/migrations/12.0.3.0.0/pre-migration.py
@@ -0,0 +1,22 @@
+# @ 2020 Akretion - www.akretion.com.br -
+# Magno Costa
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
+
+from openupgradelib import openupgrade
+
+_table_renames = [
+ ('cnab_return_move_code', 'l10n_br_cnab_return_move_code'),
+]
+
+_model_renames = [
+ ('cnab.return.move.code', 'l10n_br_cnab.return.move.code'),
+ ('cnab.return.log', 'l10n_br_cnab.return.log'),
+ ('cnab.return.event', 'l10n_br_cnab.return.event'),
+ ('cnab.return.lot', 'l10n_br_cnab.return.lot'),
+]
+
+
+@openupgrade.migrate(use_env=True)
+def migrate(env, version):
+ openupgrade.rename_tables(env.cr, _table_renames)
+ openupgrade.rename_models(env.cr, _model_renames)
From 16499560937ee533e5fb540925c13874e256488b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Wed, 4 Nov 2020 23:06:57 +0000
Subject: [PATCH 323/612] added account.move.line.change descr
---
.../wizards/account_move_line_change.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/wizards/account_move_line_change.py b/l10n_br_account_payment_order/wizards/account_move_line_change.py
index 8e3d3f7771cc..12342f554347 100644
--- a/l10n_br_account_payment_order/wizards/account_move_line_change.py
+++ b/l10n_br_account_payment_order/wizards/account_move_line_change.py
@@ -5,8 +5,8 @@
class AccountMoveLineChange(models.TransientModel):
-
_name = 'account.move.line.change'
+ _description = 'Wizard de edição de pagamento'
@api.model
def default_get(self, fields_list):
From f46059178a492e88d53dbf1f2cf7fd438bd0ba36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Thu, 5 Nov 2020 04:21:00 +0000
Subject: [PATCH 324/612] fix open2generated (tested in demo)
---
.../models/account_payment_order.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index afbb867bd719..fd45e94ec60e 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -97,9 +97,10 @@ def open2generated(self):
for record in self:
if record.bank_line_error_ids:
record.message_post(
- 'Erro ao gerar o arquivo, verifique a aba Linhas com problemas'
+ body=('Erro ao gerar o arquivo, '
+ 'verifique a aba Linhas com problemas.')
)
continue
else:
- record.message_post('Arquivo gerado com sucesso')
+ record.message_post(body='Arquivo gerado com sucesso.')
return result
From 23cddfbc7b62b9f94647f069050b5c7099d6a3a1 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 5 Nov 2020 13:55:48 -0300
Subject: [PATCH 325/612] [FIX] Inform Movemnt Intruction Code in
bank.payment.line .
---
.../models/account_payment_order.py | 2 ++
.../models/bank_payment_line.py | 25 +++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index fd45e94ec60e..4664334784e3 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -88,6 +88,8 @@ def _prepare_bank_payment_line(self, paylines):
result['company_title_identification'] =\
paylines[0].company_title_identification
result['last_cnab_state'] = paylines[0].move_line_id.cnab_state
+ result['movement_instruction_code'] = \
+ paylines[0].move_line_id.movement_instruction_code
return result
@api.multi
diff --git a/l10n_br_account_payment_order/models/bank_payment_line.py b/l10n_br_account_payment_order/models/bank_payment_line.py
index 401240809e14..802cb9b8cb3e 100644
--- a/l10n_br_account_payment_order/models/bank_payment_line.py
+++ b/l10n_br_account_payment_order/models/bank_payment_line.py
@@ -120,6 +120,31 @@ def default_get(self, fields_list):
'pagamento nas Ordens de Pagamento',
)
+ # TODO - Mover seleção para o arquivo de Constantes,
+ # aguardando retorno para saber se existe diferença
+ # entre os Bancos, o CNAB 400 da Unicred e o 240 da
+ # Febraban v10.06 estão iguais, a seleção no arquivo
+ # de constantes está diferente.
+ # Caso exista diferença vai ser preciso fazer o mesmo
+ # que foi feito nos Codigos de Retorno
+ movement_instruction_code = fields.Selection(
+ string='Código da Instrução para Movimento',
+ help='Campo G061 do CNAB',
+ selection=[
+ ('01', '01 - Remessa*'),
+ ('02', '02 - Pedido de Baixa'),
+ ('04', '04 - Concessão de Abatimento*'),
+ ('05', '05 - Cancelamento de Abatimento'),
+ ('06', '06 - Alteração de vencimento'),
+ ('08', '08 - Alteração de Seu Número'),
+ ('09', '09 - Protestar*'),
+ ('11', '11 - Sustar Protesto e Manter em Carteira'),
+ ('25', '25 - Sustar Protesto e Baixar Título'),
+ ('26', '26 – Protesto automático'),
+ ('31', '31 - Alteração de outros dados (Alteração de dados do pagador'),
+ ('40', '40 - Alteração de Carteira')]
+ )
+
@api.multi
def unlink(self):
for record in self:
From f462c4b3129d94b4cd6770e9ee852e00cd3faebc Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Fri, 6 Nov 2020 18:35:13 -0300
Subject: [PATCH 326/612] [WIP] CNAB Movement Instruction Code 02 - Pedido de
Baixa.
---
.../models/account_invoice.py | 114 +++++++++++++-----
.../models/account_move_line.py | 6 +-
2 files changed, 88 insertions(+), 32 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index b02ce2592883..b6c04c5ba2a4 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -183,38 +183,43 @@ def action_move_create(self):
return result
@api.multi
- def create_account_payment_line_baixa(self):
+ def create_account_payment_line_baixa(self, amount_payment):
+ """
+ Em caso de CNAB é preciso verificar e criar linha(s)
+ com Codigo de Instrução do Movimento para Remessa
+ - 02 - Pedido de Baixa
+ :param amount_payment:
+ :return:
+ """
+
for inv in self:
+ if not inv.payment_mode_id.payment_order_ok:
+ # TODO - deveria fazer algo, testar
+ return False
+
applicable_lines = inv.move_id.line_ids.filtered(
lambda x: (
x.payment_mode_id.payment_order_ok
and x.account_id.internal_type in ('receivable', 'payable')
- )
- )
+ ))
if not applicable_lines:
- raise UserError(
- _(
- 'No Payment Line created for invoice %s because '
- "it's internal type isn't receivable or payable."
- )
- % inv.number
- )
+ raise UserError(_(
+ 'No Payment Line created for invoice %s because '
+ "it's internal type isn't receivable or payable."
+ ) % inv.number)
payment_modes = applicable_lines.mapped('payment_mode_id')
+
if not payment_modes:
raise UserError(_('No Payment Mode on invoice %s') % inv.number)
result_payorder_ids = []
apoo = self.env['account.payment.order']
for payment_mode in payment_modes:
- payorder = apoo.search(
- [
- ('payment_mode_id', '=', payment_mode.id),
- ('state', '=', 'draft'),
- ],
- limit=1,
- )
+ payorder = apoo.search([
+ ('payment_mode_id', '=', payment_mode.id),
+ ('state', '=', 'draft')], limit=1)
new_payorder = False
if not payorder:
@@ -224,27 +229,74 @@ def create_account_payment_line_baixa(self):
new_payorder = True
result_payorder_ids.append(payorder.id)
count = 0
+ line_to_update_cnab = self.env['account.move.line']
for line in applicable_lines.filtered(
lambda x: x.payment_mode_id == payment_mode
):
- line.create_payment_line_from_move_line(payorder)
- count += 1
- if new_payorder:
- inv.message_post(
- body=_(
+ # Identificar a Linha CNAB que vai ser dado Baixa,
+ # é preciso que o valor que está sendo pago seja igual
+ # ao valor de uma das Parcelas em aberto ou ao Valor
+ # Total pois até onde vi não há possibilidade de
+ # uma baixa parcial para ser enviada na Remessa CNAB
+ if line.debit == amount_payment:
+ line_to_update_cnab |= line
+
+ if not line_to_update_cnab:
+ # Baixar todas as Parcelas em aberto
+ if inv.amount_total == amount_payment:
+ line_to_update_cnab |= applicable_lines
+ else:
+ # TODO - existe possibilidade de baixas parciais ?
+ raise UserError(_(
+ 'O valor de Pagamento R$ %d da fatura %s não pode'
+ ' ser realizado porque é preciso que o valor seja '
+ 'igual a uma das Parcelas ou ao Valor Total da'
+ ' Fatura para ser possível ser feito o Pedido de Baixa'
+ ' do Título junto ao Banco via CNAB, não é possível.'
+ ) % (amount_payment, inv.number))
+
+ line_update = False
+ for line in line_to_update_cnab:
+ # TODO - O Banco aceita receber uma instrução parcial ou
+ # isso precisa ser resolvido de outra forma ?
+ # Existe o caso do cliente pagar antecipadamente um valor
+ # como um "Sinal" ( em vendas de produtos de alto valor
+ # para garantir a intenção é pedido um pagto como uma
+ # garantia de intenção e assim evitar prejuízos por
+ # desistencia ) caso a Ordem de Pagto ainda não tenha sido
+ # enviada ao Banco apagamos a Linha
+ if line.cnab_state in ('draft', 'added'):
+ line.payment_line_ids.unlink()
+ line.message_post(body=_(
+ 'Removida Linha de Pagamento que seria enviada'
+ ' ao Banco %s via CNAB porque foi feito o pagamento'
+ ' de %d antes do envio.') % (
+ inv.payment_mode_id.fixed_journal_id.bank_id.name,
+ amount_payment))
+ # Atualização do Codigo de Instrução do Movimento
+ # para Remessa - 02 - Pedido de Baixa
+ if line.cnab_state in ('exported', 'accepted'):
+ line_update = True
+ line.movement_instruction_code = '02'
+ line.payment_situation = 'paga'
+ line.message_post(body=_(
+ 'Atualizado o Codigo de Instrução do Movimento'
+ ' para Pedido de Baixa do Título, motivo pagamento'
+ 'realizado por outra forma.'))
+ line.create_payment_line_from_move_line(payorder)
+ count += 1
+
+ if line_update:
+ if new_payorder:
+ inv.message_post(body=_(
'%d payment lines added to the new draft payment '
'order %s which has been automatically created.'
- )
- % (count, payorder.name)
- )
- else:
- inv.message_post(
- body=_(
+ ) % (count, payorder.name))
+ else:
+ inv.message_post(body=_(
'%d payment lines added to the existing draft '
'payment order %s.'
- )
- % (count, payorder.name)
- )
+ ) % (count, payorder.name))
@api.multi
def invoice_validate(self):
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index 9d0a4c434d47..f1884e863665 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -106,9 +106,13 @@ def _prepare_payment_line_vals(self, payment_order):
# Codigo de Instrução do Movimento para Remessa
vals['movement_instruction_code'] = self.movement_instruction_code
- if self.invoice_id.state == 'paid':
+ if self.movement_instruction_code == '02':
vals['amount_currency'] = self.credit or self.debit
+ # TODO - ainda necessário ?
+ # if self.invoice_id.state == 'paid':
+ # vals['amount_currency'] = self.credit or self.debit
+
return vals
@api.multi
From 239dc48e9f81f46c552ce1eec66180ac105e364a Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 9 Nov 2020 17:29:40 -0300
Subject: [PATCH 327/612] [WIP] CNAB Movement Instruction Code 02 - Pedido de
Baixa.
---
.../models/account_invoice.py | 30 +++++++++----------
.../models/account_payment.py | 4 +--
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index b6c04c5ba2a4..2d174ab74d8b 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -215,15 +215,15 @@ def create_account_payment_line_baixa(self, amount_payment):
raise UserError(_('No Payment Mode on invoice %s') % inv.number)
result_payorder_ids = []
- apoo = self.env['account.payment.order']
+ apo = self.env['account.payment.order']
for payment_mode in payment_modes:
- payorder = apoo.search([
+ payorder = apo.search([
('payment_mode_id', '=', payment_mode.id),
('state', '=', 'draft')], limit=1)
new_payorder = False
if not payorder:
- payorder = apoo.create(
+ payorder = apo.create(
inv._prepare_new_payment_order(payment_mode)
)
new_payorder = True
@@ -238,21 +238,22 @@ def create_account_payment_line_baixa(self, amount_payment):
# ao valor de uma das Parcelas em aberto ou ao Valor
# Total pois até onde vi não há possibilidade de
# uma baixa parcial para ser enviada na Remessa CNAB
+
if line.debit == amount_payment:
line_to_update_cnab |= line
if not line_to_update_cnab:
- # Baixar todas as Parcelas em aberto
+ # Valor Total ? Baixar todas as Parcelas em aberto
if inv.amount_total == amount_payment:
line_to_update_cnab |= applicable_lines
else:
# TODO - existe possibilidade de baixas parciais ?
raise UserError(_(
- 'O valor de Pagamento R$ %d da fatura %s não pode'
- ' ser realizado porque é preciso que o valor seja '
- 'igual a uma das Parcelas ou ao Valor Total da'
- ' Fatura para ser possível ser feito o Pedido de Baixa'
- ' do Título junto ao Banco via CNAB, não é possível.'
+ 'Payment amount R$ %d of invoice %s can not'
+ ' be made because the amount must be equal to one'
+ ' of Installments or the Total amount of Invoice'
+ ' to be able to make the Request to Write Off the'
+ ' title with the Bank by CNAB.'
) % (amount_payment, inv.number))
line_update = False
@@ -268,9 +269,9 @@ def create_account_payment_line_baixa(self, amount_payment):
if line.cnab_state in ('draft', 'added'):
line.payment_line_ids.unlink()
line.message_post(body=_(
- 'Removida Linha de Pagamento que seria enviada'
- ' ao Banco %s via CNAB porque foi feito o pagamento'
- ' de %d antes do envio.') % (
+ 'Removed Payline that would be sent to Bank %s'
+ ' by CNAB because amount payment of %d was made '
+ ' before sending.') % (
inv.payment_mode_id.fixed_journal_id.bank_id.name,
amount_payment))
# Atualização do Codigo de Instrução do Movimento
@@ -280,9 +281,8 @@ def create_account_payment_line_baixa(self, amount_payment):
line.movement_instruction_code = '02'
line.payment_situation = 'paga'
line.message_post(body=_(
- 'Atualizado o Codigo de Instrução do Movimento'
- ' para Pedido de Baixa do Título, motivo pagamento'
- 'realizado por outra forma.'))
+ 'Movement Instruction Code Updated for Request to'
+ ' Write Off, because payment done in another way'))
line.create_payment_line_from_move_line(payorder)
count += 1
diff --git a/l10n_br_account_payment_order/models/account_payment.py b/l10n_br_account_payment_order/models/account_payment.py
index 71b5d7f4c89f..817d5a48423a 100644
--- a/l10n_br_account_payment_order/models/account_payment.py
+++ b/l10n_br_account_payment_order/models/account_payment.py
@@ -3,7 +3,7 @@
# @author Hugo Uchôas Borges
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, models
+from odoo import api, models, fields
class AccountPayment(models.Model):
@@ -13,4 +13,4 @@ class AccountPayment(models.Model):
def post(self):
super().post()
for record in self:
- record.invoice_ids.create_account_payment_line_baixa()
+ record.invoice_ids.create_account_payment_line_baixa(record.amount)
From 95f9a6f2b1bc9b9eec4e7ad2cce71539772d54ff Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Mon, 9 Nov 2020 20:16:32 -0300
Subject: [PATCH 328/612] [REF] Remove .po and .pot files to be create
automatic by weblate.
---
.../i18n/l10n_br_account_payment_order.pot | 117 -------------
l10n_br_account_payment_order/i18n/pt_BR.po | 165 ------------------
2 files changed, 282 deletions(-)
delete mode 100644 l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
delete mode 100644 l10n_br_account_payment_order/i18n/pt_BR.po
diff --git a/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot b/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
deleted file mode 100644
index c934434eac26..000000000000
--- a/l10n_br_account_payment_order/i18n/l10n_br_account_payment_order.pot
+++ /dev/null
@@ -1,117 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * l10n_br_account_payment_order
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
-"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: \n"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_res_partner_bank
-msgid "Bank Accounts"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:account.payment.mode,name:l10n_br_account_payment_order.lucro_presumido_payment_mode_boleto
-#: model:account.payment.mode,name:l10n_br_account_payment_order.main_company_payment_mode_boleto
-#: model:account.payment.mode,name:l10n_br_account_payment_order.simples_nacional_payment_mode_boleto
-msgid "Boleto Bancario"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
-msgid "Configurações Brasileiras"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_move_line__date_scheduled
-msgid "Data Prevista"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
-msgid "Geral"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__invoice_print
-msgid "Gerar relatorio na conclusão da fatura?"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__instrucoes
-msgid "Instruções de cobrança"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_move_line__journal_entry_ref
-msgid "Journal Entry Ref"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_move_line
-msgid "Journal Item"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__linha_digitavel
-msgid "Linha Digitável"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: code:addons/l10n_br_account_payment_order/models/res_partner_bank.py:18
-#, python-format
-msgid "O cógido da Agencia Bancaria do Santander deve ter no máximo quatro caracteres."
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_line
-msgid "Payment Lines"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_mode
-msgid "Payment Modes"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_order
-msgid "Payment Order"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__percent_interest
-msgid "Percentual de Juros"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.ui.menu,name:l10n_br_account_payment_order.menu_remessa_categ
-msgid "Remessa"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.ui.menu,name:l10n_br_account_payment_order.menu_retorno_categ
-msgid "Retorno"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__internal_sequence_id
-msgid "Sequência"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: sql_constraint:account.payment.mode:0
-msgid "Sequência já usada! Crie uma sequência unica para cada modo"
-msgstr ""
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__amount_interest
-msgid "Valor Juros"
-msgstr ""
diff --git a/l10n_br_account_payment_order/i18n/pt_BR.po b/l10n_br_account_payment_order/i18n/pt_BR.po
deleted file mode 100644
index 96282b79239c..000000000000
--- a/l10n_br_account_payment_order/i18n/pt_BR.po
+++ /dev/null
@@ -1,165 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * l10n_br_account_banking_payment
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: Odoo Server 8.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-11-22 14:13+0000\n"
-"PO-Revision-Date: 2020-11-09 03:08+0000\n"
-"Last-Translator: Eder Brito \n"
-"Language-Team: \n"
-"Language: pt_BR\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: nplurals=2; plural=n > 1;\n"
-"X-Generator: Weblate 3.10\n"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_res_partner_bank
-msgid "Bank Accounts"
-msgstr "Contas Bancárias"
-
-#. module: l10n_br_account_payment_order
-#: model:account.payment.mode,name:l10n_br_account_payment_order.lucro_presumido_payment_mode_boleto
-#: model:account.payment.mode,name:l10n_br_account_payment_order.main_company_payment_mode_boleto
-#: model:account.payment.mode,name:l10n_br_account_payment_order.simples_nacional_payment_mode_boleto
-msgid "Boleto Bancario"
-msgstr "Boleto Bancário"
-
-#. module: l10n_br_account_payment_order
-#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
-msgid "Configurações Brasileiras"
-msgstr "Configurações Brasileiras"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_move_line__date_scheduled
-msgid "Data Prevista"
-msgstr "Data Prevista"
-
-#. module: l10n_br_account_payment_order
-<<<<<<< HEAD
-#: selection:account.payment.mode,operation_type:0
-#: selection:account.payment.order,operation_type:0
-msgid "Debito em conta corrente"
-msgstr "Debito em conta corrente"
-
-#. module: l10n_br_account_payment_order
-=======
->>>>>>> [REF] remove field operation_type in l10n_br_account_payment_order
-#: model_terms:ir.ui.view,arch_db:l10n_br_account_payment_order.l10n_br-account_payment_mode_form
-msgid "Geral"
-msgstr "Geral"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__invoice_print
-msgid "Gerar relatorio na conclusão da fatura?"
-msgstr "Gerar relatório na conclusão da fatura?"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__instrucoes
-msgid "Instruções de cobrança"
-msgstr "Instruções de cobrança"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_move_line__journal_entry_ref
-msgid "Journal Entry Ref"
-msgstr "Ref da Entrada do Diário"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_move_line
-msgid "Journal Item"
-msgstr "Item do Diário"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__linha_digitavel
-msgid "Linha Digitável"
-msgstr "Linha Digitável"
-
-#. module: l10n_br_account_payment_order
-#: code:addons/l10n_br_account_payment_order/models/res_partner_bank.py:18
-#, python-format
-msgid ""
-"O cógido da Agencia Bancaria do Santander deve ter no máximo quatro "
-"caracteres."
-msgstr ""
-"O código da Agencia Bancaria do Santander deve ter no máximo quatro "
-"caracteres."
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_line
-msgid "Payment Lines"
-msgstr "Linhas de Pagamento"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_mode
-msgid "Payment Modes"
-msgstr "Modos de Pagamentos"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model,name:l10n_br_account_payment_order.model_account_payment_order
-msgid "Payment Order"
-msgstr "Ordem de Pagamento"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__percent_interest
-msgid "Percentual de Juros"
-msgstr "Percentual de Juros"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.ui.menu,name:l10n_br_account_payment_order.menu_remessa_categ
-msgid "Remessa"
-msgstr "Remessa"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.ui.menu,name:l10n_br_account_payment_order.menu_retorno_categ
-msgid "Retorno"
-msgstr "Retorno"
-
-#. module: l10n_br_account_payment_order
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_mode__internal_sequence_id
-msgid "Sequência"
-msgstr "Sequência"
-
-#. module: l10n_br_account_payment_order
-#: sql_constraint:account.payment.mode:0
-msgid "Sequência já usada! Crie uma sequência unica para cada modo"
-msgstr "Sequência já usada! Crie uma sequência unica para cada modo"
-
-#: model:ir.model.fields,field_description:l10n_br_account_payment_order.field_account_payment_line__amount_interest
-msgid "Valor Juros"
-msgstr "Valor Juros"
-
-#~ msgid "Bank"
-#~ msgstr "Banco"
-
-#~ msgid "Data Programada"
-#~ msgstr "Data Programada"
-
-#~ msgid "Entry Lines"
-#~ msgstr "Linhas de Entrada"
-
-#~ msgid "Impossible confirm empty line!"
-#~ msgstr "Impossível confirmar linha vazia!"
-
-#~ msgid "Total Credit"
-#~ msgstr "Total de Crédito"
-
-#~ msgid "Total Debit"
-#~ msgstr "Total de Débito"
-
-#~ msgid "Títulos em aberto"
-#~ msgstr "Títulos em aberto"
-
-#~ msgid ""
-#~ "{'display_credit': context.get('display_credit', False),'display_debit': "
-#~ "context.get('display_debit', False),'journal_type': 'sale', "
-#~ "'tree_view_ref' : 'account_banking_payment_export."
-#~ "payment_order_populate_view_move_line_tree'}"
-#~ msgstr ""
-#~ "{'display_credit': context.get('display_credit', False),'display_debit': "
-#~ "context.get('display_debit', False),'journal_type': 'sale', "
-#~ "'tree_view_ref' : 'account_banking_payment_export."
-#~ "payment_order_populate_view_move_line_tree'}"
From 61e47a4cceef40dead75e71fae7949ba64b7f00a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Tue, 10 Nov 2020 01:17:19 +0000
Subject: [PATCH 329/612] flake8 fix
---
l10n_br_account_payment_order/models/account_payment.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_payment.py b/l10n_br_account_payment_order/models/account_payment.py
index 817d5a48423a..f4e1c09f2c1a 100644
--- a/l10n_br_account_payment_order/models/account_payment.py
+++ b/l10n_br_account_payment_order/models/account_payment.py
@@ -3,7 +3,7 @@
# @author Hugo Uchôas Borges
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, models, fields
+from odoo import api, models
class AccountPayment(models.Model):
From e92022e20b9608e1ceedca66551a4ac4406315bb Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Tue, 10 Nov 2020 15:26:22 -0300
Subject: [PATCH 330/612] [IMP+FIX] CNAB Movement Instruction Code 02,
forbidden register account.payment with CNAB payment methods.
---
l10n_br_account_payment_order/__manifest__.py | 1 +
.../models/account_payment.py | 22 ++++++++++++++-
.../views/account_payment_views.xml | 28 +++++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 l10n_br_account_payment_order/views/account_payment_views.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index b89491c30347..50bb16417f4d 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -59,6 +59,7 @@
'views/account_invoice.xml',
'views/account_move_line.xml',
'views/l10n_br_cnab_return_move_code_view.xml',
+ 'views/account_payment_views.xml',
],
'demo': [
'demo/res_partner_bank.xml',
diff --git a/l10n_br_account_payment_order/models/account_payment.py b/l10n_br_account_payment_order/models/account_payment.py
index f4e1c09f2c1a..81f0ada48ca7 100644
--- a/l10n_br_account_payment_order/models/account_payment.py
+++ b/l10n_br_account_payment_order/models/account_payment.py
@@ -3,7 +3,8 @@
# @author Hugo Uchôas Borges
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import api, models
+from odoo import api, models, _
+from odoo.exceptions import UserError
class AccountPayment(models.Model):
@@ -11,6 +12,25 @@ class AccountPayment(models.Model):
@api.multi
def post(self):
+
+ # TODO - Rodando 2 For para não chamar o super em caso do
+ # metodo de pagto ser CNAB, necessário devido o problema abaixo
+ for rec in self:
+ if rec.payment_method_code in ('240', '400', '500'):
+ # TODO - Idealmente isso deveria ser resolvido com um
+ # domain=[('code', 'not in', ('400','240','500'))]
+ # no campo payment_method_id, mas mesmo adicionando isso na
+ # visão ou sobre escrevendo o campo não funciona e não gera
+ # erros, não consegui identificar o motivo do problema (
+ # seria algum problema no orm ? Não encontrei um issue aberto
+ # com referencia a isso ), para reproduzir o erro basta tentar
+ # incluir o domain no campo como comentado acima e testar
+ # na tela.
+ # Testar na migração.
+ raise UserError(_(
+ 'CNAB Payment Method can be used to make'
+ ' Payments here, just used in Payment Orders,'
+ ' choose another one.'))
super().post()
for record in self:
record.invoice_ids.create_account_payment_line_baixa(record.amount)
diff --git a/l10n_br_account_payment_order/views/account_payment_views.xml b/l10n_br_account_payment_order/views/account_payment_views.xml
new file mode 100644
index 000000000000..2c1d921633e6
--- /dev/null
+++ b/l10n_br_account_payment_order/views/account_payment_views.xml
@@ -0,0 +1,28 @@
+
+
+
+
+ l10n_br_account_payment_order.view.account.payment.invoice.form
+ account.payment
+
+
+
+
+
+ [('code', 'not in', ('400','240','500'))]
+
+
+
+
+
+
From 6fcfe18f5a83e3f6ddb5817b71081b4f67703a73 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 12 Nov 2020 15:02:56 -0300
Subject: [PATCH 331/612] [FIX] Payment out CNAB can be made when there is CNAB
file created.
---
.../models/account_invoice.py | 16 +++++++++++++++-
.../models/account_payment_order.py | 5 +++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/l10n_br_account_payment_order/models/account_invoice.py b/l10n_br_account_payment_order/models/account_invoice.py
index 2d174ab74d8b..f39b24599de8 100644
--- a/l10n_br_account_payment_order/models/account_invoice.py
+++ b/l10n_br_account_payment_order/models/account_invoice.py
@@ -266,7 +266,21 @@ def create_account_payment_line_baixa(self, amount_payment):
# garantia de intenção e assim evitar prejuízos por
# desistencia ) caso a Ordem de Pagto ainda não tenha sido
# enviada ao Banco apagamos a Linha
+
if line.cnab_state in ('draft', 'added'):
+ # Caso o arquivo já esteja criado a linha
+ # não pode ser atualizada
+ for payment_line in line.payment_line_ids:
+ if payment_line.order_id.state == 'generated':
+ raise UserError(_(
+ 'There is a CNAB file related to invoice'
+ ' %s created, this file should be sent to'
+ ' bank, because after that only Payment'
+ ' Order in status Exported allows make an'
+ ' payment and inform it in another Payment'
+ ' Order.'
+ ) % inv.number)
+
line.payment_line_ids.unlink()
line.message_post(body=_(
'Removed Payline that would be sent to Bank %s'
@@ -282,7 +296,7 @@ def create_account_payment_line_baixa(self, amount_payment):
line.payment_situation = 'paga'
line.message_post(body=_(
'Movement Instruction Code Updated for Request to'
- ' Write Off, because payment done in another way'))
+ ' Write Off, because payment done in another way.'))
line.create_payment_line_from_move_line(payorder)
count += 1
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index 4664334784e3..bff716129655 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -97,12 +97,17 @@ def open2generated(self):
result = super().open2generated()
for record in self:
+ # TODO - exemplos de caso de uso ? Qdo isso ocorre ?
+ # Já não gera erro ao tentar criar o arquivo ?
if record.bank_line_error_ids:
record.message_post(
body=('Erro ao gerar o arquivo, '
'verifique a aba Linhas com problemas.')
)
+ for payment_line in record.payment_line_ids:
+ payment_line.move_line_id.cnab_state = 'exporting_error'
continue
else:
record.message_post(body='Arquivo gerado com sucesso.')
+
return result
From 17037de3fbac77e77601aac52318475953d5d335 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 12 Nov 2020 15:04:59 -0300
Subject: [PATCH 332/612] [IMP] Created fields to be able search
account_move_line related to event in return CNAB file.
---
.../models/account_move_line.py | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/l10n_br_account_payment_order/models/account_move_line.py b/l10n_br_account_payment_order/models/account_move_line.py
index f1884e863665..6c2409f52f41 100644
--- a/l10n_br_account_payment_order/models/account_move_line.py
+++ b/l10n_br_account_payment_order/models/account_move_line.py
@@ -11,6 +11,7 @@ class AccountMoveLine(models.Model):
_name = 'account.move.line'
_inherit = ["account.move.line", "mail.thread", "mail.activity.mixin"]
+ # TODO - possível tornar um compute ?
cnab_state = fields.Selection(
selection=ESTADOS_CNAB,
string='Estados CNAB',
@@ -21,6 +22,28 @@ class AccountMoveLine(models.Model):
string='Nosso Numero',
)
+ # No arquivo de retorno do CNAB o campo pode ter um tamanho diferente,
+ # o tamanho do campo é preenchido na totalidade com zeros a esquerda,
+ # e no odoo o tamanho do sequencial pode estar diferente
+ # ex.: retorno cnab 0000000000000201 own_number 0000000201
+ # o campo abaixo foi a forma que encontrei para poder usar o
+ # nosso_numero_cnab_retorno.strip("0") e ter algo:
+ # ex.: retorno cnab 201 own_number_without_zfill 201
+ # Assim o metodo que faz o retorno do CNAB consegue encontrar
+ # a move line relacionada ao Evento.
+ own_number_without_zfill = fields.Char(
+ compute='_compute_own_number_without_zfill',
+ store=True, copy=False,
+ )
+
+ # Podem existir sequencias do nosso numero/own_number iguais entre bancos
+ # diferentes, porém o Diario/account.journal não pode ser o mesmo.
+ journal_payment_mode_id = fields.Many2one(
+ comodel_name='account.journal',
+ compute='_compute_journal_payment_mode',
+ store=True, copy=False
+ )
+
document_number = fields.Char(
string='Número documento',
)
@@ -220,3 +243,20 @@ def _create_change(self, change_type, reason='', **kwargs):
self._change_payment_mode(reason, **kwargs)
elif change_type == 'baixa':
self._create_baixa(reason, **kwargs)
+
+ @api.multi
+ @api.depends('own_number')
+ def _compute_own_number_without_zfill(self):
+ for record in self:
+ if record.own_number:
+ record.own_number_without_zfill = record.own_number.strip('0')
+
+ @api.multi
+ @api.depends('payment_mode_id')
+ def _compute_journal_payment_mode(self):
+ for record in self:
+ if record.payment_mode_id:
+ # CNAB usa sempre a opção fixed_journal_id
+ if record.payment_mode_id.fixed_journal_id:
+ record.journal_payment_mode_id =\
+ record.payment_mode_id.fixed_journal_id.id
From 7c8d7bed141bc3e3867cba584d4f91a207b38ab2 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Thu, 12 Nov 2020 17:30:11 -0300
Subject: [PATCH 333/612] [FIX+WIP] Tests.
---
.../tests/test_payment_order.py | 14 ++++++++++----
.../tests/test_payment_order_inbound.py | 4 +++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/l10n_br_account_payment_order/tests/test_payment_order.py b/l10n_br_account_payment_order/tests/test_payment_order.py
index 4393969c288f..a0409d7ab5b3 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order.py
@@ -63,7 +63,9 @@ def test_implemented_fields_payment_order(self):
self.assertEqual(
line.journal_entry_ref, line.invoice_id.name,
"Error with compute field journal_entry_ref")
- test_balance_value = line.get_balance()
+ # testar com a parcela 700
+ if line.debit == 700.0:
+ test_balance_value = line.get_balance()
# Return the status of Move to Posted
self.invoice_customer_original.move_id.action_post()
@@ -77,7 +79,9 @@ def test_implemented_fields_payment_order(self):
self.assertEquals(
line.journal_entry_ref, line.invoice_id.name,
"Error with compute field journal_entry_ref")
- test_balance_value = line.get_balance()
+ # testar com a parcela 700
+ if line.debit == 700.0:
+ test_balance_value = line.get_balance()
self.assertEquals(
test_balance_value, 700.0,
@@ -103,9 +107,11 @@ def test_cancel_payment_order(self):
self.assertEqual(len(payment_order.bank_line_ids), 0)
for line in payment_order.payment_line_ids:
- line.percent_interest = 1.5
+ # testar com a parcela 700
+ if line.amount_currency == 700.0:
+ line.percent_interest = 1.5
+ test_amount_interest = line.amount_interest
- test_amount_interest = line.amount_interest
self.assertEquals(
test_amount_interest, 10.5,
"Error with compute field amount_interest.")
diff --git a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index ff9479d125bb..4a39cda13556 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -46,7 +46,9 @@ def test_payment_order(self):
assert self.invoice_customer_original.move_id,\
"Move not created for open invoice"
- payment_order = self.env['account.payment.order'].search([])
+ payment_order = self.env['account.payment.order'].search([
+ ('state', '=', 'draft')
+ ])
# I check creation of Payment Order
assert payment_order, "Payment Order not created."
payment_order.draft2open()
From 488dcecbd0c5fc07817a0e00944e4fdd78272048 Mon Sep 17 00:00:00 2001
From: Magno Costa
Date: Sat, 14 Nov 2020 17:41:44 -0300
Subject: [PATCH 334/612] [FIX] CNAB : Movement Instruction Code can be
different.
---
l10n_br_account_payment_order/__manifest__.py | 2 +
...l10n_br_cnab_mov_instruction_code_data.xml | 182 +++++++++++
.../l10n_br_cnab_return_move_code_data.xml | 293 +++++++++---------
.../demo/account_payment_mode.xml | 18 +-
.../models/__init__.py | 1 +
.../models/account_invoice.py | 17 +-
.../models/account_move_line.py | 32 +-
.../models/account_payment_line.py | 21 +-
.../models/account_payment_mode.py | 63 +++-
.../models/account_payment_order.py | 4 +-
.../models/bank_payment_line.py | 23 +-
.../l10n_br_cnab_mov_intruction_code.py | 51 +++
.../security/ir.model.access.csv | 4 +-
.../views/account_move_line.xml | 2 +-
.../views/account_payment_line.xml | 2 +-
.../views/account_payment_mode.xml | 145 ++++-----
.../views/bank_payment_line.xml | 1 +
...l10n_br_cnab_mov_instruction_code_view.xml | 69 +++++
18 files changed, 640 insertions(+), 290 deletions(-)
create mode 100644 l10n_br_account_payment_order/data/l10n_br_cnab_mov_instruction_code_data.xml
create mode 100644 l10n_br_account_payment_order/models/l10n_br_cnab_mov_intruction_code.py
create mode 100644 l10n_br_account_payment_order/views/l10n_br_cnab_mov_instruction_code_view.xml
diff --git a/l10n_br_account_payment_order/__manifest__.py b/l10n_br_account_payment_order/__manifest__.py
index 50bb16417f4d..e61fd7e5a246 100644
--- a/l10n_br_account_payment_order/__manifest__.py
+++ b/l10n_br_account_payment_order/__manifest__.py
@@ -28,6 +28,7 @@
'data/boleto_data.xml',
'data/account_analytic_tag_data.xml',
'data/l10n_br_cnab_return_move_code_data.xml',
+ 'data/l10n_br_cnab_mov_instruction_code_data.xml',
# Reports
'reports/report_print_button_view.xml',
@@ -60,6 +61,7 @@
'views/account_move_line.xml',
'views/l10n_br_cnab_return_move_code_view.xml',
'views/account_payment_views.xml',
+ 'views/l10n_br_cnab_mov_instruction_code_view.xml',
],
'demo': [
'demo/res_partner_bank.xml',
diff --git a/l10n_br_account_payment_order/data/l10n_br_cnab_mov_instruction_code_data.xml b/l10n_br_account_payment_order/data/l10n_br_cnab_mov_instruction_code_data.xml
new file mode 100644
index 000000000000..06be514eca31
--- /dev/null
+++ b/l10n_br_account_payment_order/data/l10n_br_cnab_mov_instruction_code_data.xml
@@ -0,0 +1,182 @@
+
+
+
+
+
+
+
+ Inclusão de Registro Detalhe Liberado
+ 00
+
+
+
+
+ Inclusão do Registro Detalhe Bloqueado
+ 09
+
+
+
+
+ Alteração do Pagamento Liberado para Bloqueado (Bloqueio)
+ 10
+
+
+
+
+ Alteração do Pagamento Bloqueado para Liberado (Liberação)
+ 11
+
+
+
+
+ Alteração do Valor do Título
+ 17
+
+
+
+
+ Alteração da Data de Pagamento
+ 19
+
+
+
+
+ Pagamento Direto ao Fornecedor - Baixar
+ 23
+
+
+
+
+ Manutenção em Carteira - Não Pagar
+ 25
+
+
+
+
+ Retirada de Carteira - Não Pagar
+ 27
+
+
+
+
+ Estorno por Devolução da Câmara Centralizadora (somente para Tipo de Movimento = '3')
+ 33
+
+
+
+
+ Alegação do Pagador
+ 40
+
+
+
+
+ Exclusão do Registro Detalhe Incluído Anteriormente
+ 99
+
+
+
+
+
+ Remessa*
+ 01
+
+
+ Na inclusão de título em carteira, poderá ser definido “Protesto Automático” se forem obrigatoriamente respeitados: 1.Beneficiário estiver habilitado para uso de Protesto e 2.forem informados: 158 a 158 - Código para Protesto e 159 a 160 - Número de Dias para Protesto.Para configurar “Protesto Automático” para Títulos em Carteira deve ser utilizado a intrução 26 – Protesto automático.
+
+
+
+ Pedido de Baixa
+ 02
+
+
+
+
+
+ Concessão de Abatimento*
+ 04
+
+
+ Necessário ao enviar esta instrução 4 e também inserir 206 a 218 Valor do Abatimento.
+
+
+
+ Concessão de Abatimento*
+ 05
+
+
+
+
+
+ Alteração de vencimento
+ 06
+
+
+
+
+
+ Alteração de Seu Número
+ 08
+
+
+
+
+
+ Protestar*
+ 09
+
+
+ Instrução utilizada para títulos vencidos e que não possuam protesto automático registrado. Neste caso, sem protesto automático cadastrado (automático é prioritário ao manual), o sistema encaminha o título à protesto, pois o fato gerador já aconteceu, ou seja, título já vencido. Deverá ser usada como “Protesto Manual”.Se for usado em título “À Vencer”, o sistema vai rejeitar instrução.IMPORTANTE: Carência 1 dia para Protesto Tanto Protesto Automático quando Protesto Manual, terá sempre 1 dia a mais para iniciar o envio do pedido de Protesto ao cartório. Esta carência é devido a ser possível receber pagamento via Compensação em D+1 (Correspondentes ou outro Bancos) Exemplos Título com data para vencimento hoje (D+0), será possível enviar “protesto manual” apenas em D+2 (dia útil) e mesmo se estiver “protesto automático” cadastrado, só será enviado em D+2 (dia útil ), respeitando a carência 1 dia útil.Caso seja enviado pedido de protesto sem respeitar o prazo de “1 dia”, a instrução será rejeitada.
+
+
+ Protesto solicitado
+ 10
+
+
+
+
+
+ Sustar Protesto e Manter em Carteira
+ 11
+
+
+
+
+
+ Sustar Protesto e Baixar Título
+ 25
+
+
+
+
+
+ Protesto automático
+ 26
+
+
+ (Instrução para Criar, Alterar, Remover): Instrução indicada para títulos a vencer, utilizada para protesto futuro, quando o fato gerador do protesto acontecer.Criar: Esta instrução deverá ser informada, somente, para títulos a vencer, registrados na carteira e que não possuam ‘Código para Protesto’ e ‘Número de Dias para Protesto’ cadastrados, ou seja, não foram registrados com as informações básicas de protesto (Código e Número de Dias). Neste caso o sistema irá encaminhar o título para protesto quando o fato gerador acontecer.Deverá ser informado um dos itens do ‘158 a 158 - Código para Protesto’ o Código ‘1’ ou o Código ‘2’ e ‘159 a 160 - Número de Dias para Protesto’, maior que zeros.Alterar: Esta instrução deverá ser informada para títulos a vencer, registrados na carteira e que possuam ‘Código para Protesto’ e ‘Número de Dias para Protesto’ cadastrados, com o objetivo de alterar essas informações básicas de protesto (Código e Número de Dias). Neste caso o sistema irá sobrescrever as informações enviadas sobre as informações cadastradas.Deverá ser informado um dos itens do ‘158 a 158 - Código para Protesto’ o Código ‘1’ ou o Código ‘2’ e ‘159 a 160 - Número de Dias para Protesto’, maior que zeros. Remover: Esta instrução deverá ser informada para títulos, que o fato gerador do protesto não ocorreu, registrados na carteira e que possuam ‘Código para Protesto’ e ‘Número de Dias para Protesto’ cadastrados, com o objetivo de excluir essas informações básicas de protesto automático. Neste caso o sistema excluí a possibilidade de protesto futuro automático.Deverá ser informado um dos itens do ‘158 a 158 - Código para Protesto’ o Código ‘3’ e ‘159 a 160 - Número de Dias para Protesto’, igual a zero.
+
+
+ Alteração de outros dados (Alteração de dados do pagador)
+ 31
+
+
+
+
+
+ Alteração de Carteira
+ 40
+
+
+
+
+
diff --git a/l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml b/l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml
index 002e2b1189e3..fb0137bb4324 100644
--- a/l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml
+++ b/l10n_br_account_payment_order/data/l10n_br_cnab_return_move_code_data.xml
@@ -11,182 +11,181 @@
Baixa/Liquidação para um determindo caso.
-->
-
-
+
+
Entrada Confirmada
02
-
+
Entrada Rejeitada
03
-
+
Liquidação
06
-
+
Confirmação do Recebimento da Instrução de Desconto
07
-
+
Confirmação do Recebimento do Cancelamento da Instrução de Desconto
08
-
+
Baixa
09
-
+
Confirmação do Recebimento da Instrução de Repactuação
10
-
+
Confirmação do Recebimento da Instrução de Abatimento
12
-
+
Confirmação do Recebimento do Cancelamento da Instrução de Abatimento
13
-
+
Confirmação do Recebimento da Instrução de Alteração de Vencimento
14
-
+
Liquidação após Baixa ou Liquidação Título não Registrado
17
-
+
Instrução Rejeitada
26
-
+
Confirmação do Pedido de Alteração de Outros Dados
27
-
+
Alteração de Dados Rejeitada
30
-
+
Concentração (Será informado apenas no arquivo retorno dos dados do Comprador)
36
-
+