Skip to content

Commit

Permalink
[FIX] Limpeza após rebase
Browse files Browse the repository at this point in the history
[FIX] Cópia de views agora mantém sincronia no caso de herança
[FEA] Empresa movido para l10n_br_base
[FEA] CNAE movido para sped
  • Loading branch information
aricaldeira committed Apr 21, 2017
1 parent ae5f89c commit 6aef1aa
Show file tree
Hide file tree
Showing 107 changed files with 2,097 additions and 2,320 deletions.
76 changes: 70 additions & 6 deletions copy_views/models/inherited_ir_ui_view.py
Expand Up @@ -20,10 +20,15 @@ class IrUiView(models.Model):

copy_id = fields.Many2one(
comodel_name='ir.ui.view',
string=u'Copied View',
string='Copied View',
ondelete='restrict',
index=True,
)
copy_children_ids = fields.One2many(
comodel_name='ir.ui.view',
inverse_name='copy_id',
string='Views which copy from this one',
)

@api.model
def create(self, values):
Expand All @@ -32,35 +37,94 @@ def create(self, values):
# original view
#
if values.get('copy_id'):
values['arch'] = self.browse(values['copy_id']).arch
copied_view = self.browse(values['copy_id'])
values['arch'] = copied_view.read_combined(['arch'])['arch']

return super(IrUiView, self).create(values)
copied_views = []

res = super(IrUiView, self).create(values)

#
# Ensures inheritance gets replicated to copied views
#
if values.get('inherit_id'):
cv = self.search([('copy_id', '=', res.inherit_id.id)])
if cv:
arch = res.read_combined(['arch'])['arch']
cv.write({'arch': arch})

return res

@api.model
def write(self, values):
copied_views = []

for view in self:
#
# Saves copied views for latter proccess
# Saves copied views for later proccess
#
cv = self.search([('copy_id', '=', view.id)])
if cv:
copied_views += [[view.id, cv]]

#
# Saves copied views for later proccess
#
if values.get('inherit_id'):
cv = self.search([('copy_id', '=', values['inherit_id'])])
if cv:
copied_views += [[view.id, cv]]

#
# Ensures that the arch of the copied view remains copied from the
# original view
#
if values.get('copy_id'):
values['arch'] = self.browse(values['copy_id']).arch
copied_view = self.browse(values['copy_id'])
values['arch'] = copied_view.read_combined(['arch'])['arch']

res = super(IrUiView, self).write(values)

if copied_views:
for view_id, cv in copied_views:
view = self.browse(view_id)
cv.write({'arch': view.arch})
arch = view.read_combined(['arch'])['arch']
cv.write({'arch': arch})

return res

@api.model
def unlink(self):
copied_views = []

for view in self:
if not view.inherit_id:
continue

#
# Saves copied views for later proccess
#
cv = self.search([('copy_id', '=', view.inherit_id.id)])
if cv:
copied_views += [[view.inherit_id.id, cv]]

res = super(IrUiView, self).unlink()

#
# Ajusts now the copies of the inherited views
#
if copied_views:
for view_id, cv in copied_views:
inherited_view_ids = \
self.search([('inherit_id', '=', view_id)])

if len(inherited_view_ids) > 0:
view = self.browse(inherited_view_ids[0])
else:
view = self.browse(view_id)

arch = view.read_combined(['arch'])['arch']
cv.write({'arch': arch})

return res

Expand Down
17 changes: 14 additions & 3 deletions copy_views/views/inherited_ir_ui_view_view.xml
Expand Up @@ -11,9 +11,20 @@
<field name="priority">100</field>
<field name="inherit_id" ref="base.view_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='xml_id']" position="after">
<xpath expr="//field[@name='inherit_id']" position="after">
<field name="copy_id" />
</xpath>
<xpath expr="//page[@name='inherit_children']" position="after">
<page name="copy_children" string="Copied Views">
<field name="copy_children_ids" context="{'default_model':model,'default_type':type,'default_copy_id':active_id,'default_mode':'extension'}">
<tree>
<field name="priority"/>
<field name="name"/>
<field name="xml_id"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

Expand All @@ -23,8 +34,8 @@
<field name="priority">100</field>
<field name="inherit_id" ref="base.view_view_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='xml_id']" position="after">
<field name="xml_id" groups="base.group_no_one" />
<xpath expr="//field[@name='inherit_id']" position="after">
<field name="copy_id" />
</xpath>
</field>
</record>
Expand Down
2 changes: 0 additions & 2 deletions l10n_br_base/__init__.py
Expand Up @@ -3,5 +3,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
from . import tools
from . import tests
27 changes: 11 additions & 16 deletions l10n_br_base/__manifest__.py
@@ -1,18 +1,22 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 - TODAY Renato Lima - Akretion
# Copyright 2017 Taŭga Tecnologia
# Aristides Caldeira <aristides.caldeira@tauga.com.br>
# Copyright 2017 KMEE
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
#

{
'name': 'Brazilian Localization Base',
'name': 'Brazilian Localisation Base',
'category': 'Localisation',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Akretion',
'author': 'Odoo Community Association (OCA), Akretion, Taŭga, KMEE',
'website': 'http://odoo-brasil.org',
'version': '10.0.1.0.0',
'depends': [
'base',
'mail',
'base_setup',
'decimal_precision',
'copy_views',
],
Expand All @@ -24,18 +28,14 @@
'data/inherited_res_currency_data.xml',
'data/inherited_decimal_precision_data.xml',

'data/res_country_data.xml',
'data/res_country_state_data.xml',
'data/inherited_res_country_data.xml',
'data/inherited_res_country_state_data.xml',

'data/sped_pais_data.xml',
'data/sped_estado_data.xml',
'data/sped_municipio_data.xml',
'data/sped_municipio_exterior_data.xml',

'data/sped_cnae_data.xml',

# 'views/res_bank_view.xml',

#
# Menus principais
#
Expand All @@ -48,16 +48,14 @@
'views/sped_estado_view.xml',
'views/sped_municipio_view.xml',

'views/sped_cnae_view.xml',

#
# Módulo Cadastro: participantes, produtos etc.
#
'views/sped_participante_base_view.xml',
'views/sped_participante_cliente_view.xml',
'views/sped_participante_fornecedor_view.xml',
'views/sped_participante_vincula_partner_view.xml',
'views/sped_empresa.xml',
'views/sped_empresa_view.xml',

#
# Parcelamentos e pagamentos; bancos e contas bancárias
Expand All @@ -68,9 +66,7 @@
# 'security/ir.model.access.csv',
],
'demo': [
'demo/sped_empresa.xml',
# 'demo/l10n_br_base_demo.xml',
# 'demo/res_partner_demo.xml',
'demo/sped_empresa_demo.xml',
],
'test': [
# 'test/base_inscr_est_valid.yml',
Expand All @@ -84,7 +80,6 @@
'python': [
'pybrasil',
'email_validator',
'num2words',
],
}
}
1 change: 1 addition & 0 deletions l10n_br_base/constante_tributaria.py
Expand Up @@ -4833,6 +4833,7 @@
('12', u'Vale presente'),
('13', u'Vale combustível'),
('14', u'Duplicata mercantil'),
#('90', u''),
('99', u'Outros'),
)
FORMA_PAGAMENTO_DICT = dict(FORMA_PAGAMENTO)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions l10n_br_base/models/__init__.py
Expand Up @@ -6,6 +6,8 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
#

from __future__ import division, print_function, unicode_literals

#
# Sincronização de casas decimais
#
Expand All @@ -24,11 +26,6 @@
from . import sped_estado
from . import sped_municipio

#
# Tabelas Fiscais
#
from . import sped_cnae

#
# Cadastros básicos
#
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions l10n_br_base/models/copied_account_payment_term.py
Expand Up @@ -5,15 +5,16 @@
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#

from __future__ import division, print_function, unicode_literals

from odoo import api, fields, models
from odoo.exceptions import ValidationError


class AccountPaymentTerm(models.Model):
_name = "account.payment.term"
_description = "Payment Term"
_order = "name"
_name = b'account.payment.term'
_description = 'Payment Term'
_order = 'name'

def _default_line_ids(self):
return [(0, 0,
Expand All @@ -32,8 +33,8 @@ def _default_line_ids(self):
)
active = fields.Boolean(
default=True,
help="If the active field is set to False, it will allow you to hide "
"the payment term without removing it.",
help='If the active field is set to False, it will allow you to hide '
'the payment term without removing it.',
)
note = fields.Text(
string='Description on the Invoice',
Expand Down
3 changes: 2 additions & 1 deletion l10n_br_base/models/copied_account_payment_term_line.py
Expand Up @@ -5,14 +5,15 @@
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#

from __future__ import division, print_function, unicode_literals

from odoo import api, fields, models
from odoo.exceptions import ValidationError
import odoo.addons.decimal_precision as dp


class AccountPaymentTermLine(models.Model):
_name = 'account.payment.term.line'
_name = b'account.payment.term.line'
_description = 'Payment Term Line'
_order = 'sequence, id'

Expand Down
20 changes: 10 additions & 10 deletions l10n_br_base/models/inherited_account_payment_term.py
Expand Up @@ -5,6 +5,7 @@
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#

from __future__ import division, print_function, unicode_literals

from odoo import api, fields, models
from odoo.exceptions import ValidationError
Expand All @@ -22,41 +23,40 @@ class AccountPaymentTerm(models.Model):
default=10,
)
is_installment_plan = fields.Boolean(
string=u'Is monthly installment plan?',
string='Is monthly installment plan?',
default=True,
)
has_down_payment = fields.Boolean(
string=u'Has down payment?',
string='Has down payment?',
)
months = fields.Integer(
string=u'Months',
string='Months',
)
# postpone_date_holiday = fields.Boolean(
# string=u'Postpone dates to next work day when holiday?',
# string='Postpone dates to next work day when holiday?',
# )
forma_pagamento = fields.Selection(
selection=FORMA_PAGAMENTO,
string=u'Forma de pagamento',
string='Forma de pagamento',
)
bandeira_cartao = fields.Selection(
selection=BANDEIRA_CARTAO,
string=u'Bandeira do cartão',
string='Bandeira do cartão',
)
integracao_cartao = fields.Selection(
selection=INTEGRACAO_CARTAO,
string=u'Integração do cartão',
string='Integração do cartão',
default=INTEGRACAO_CARTAO_NAO_INTEGRADO,
)
participante_id = fields.Many2one(
string=u'Operadora do cartão',
string='Operadora do cartão',
ondelete='restrict',
)
comercial_name = fields.Char(
string=u'Payment Terms',
string='Payment Terms',
compute='_compute_comercial_name',
)


@api.multi
def _compute_comercial_name(self):
if self.env.context.get('currency_id'):
Expand Down

0 comments on commit 6aef1aa

Please sign in to comment.