Skip to content

Commit

Permalink
Merge branch '11.0' into feature/nfse-carioca
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Mar 28, 2018
2 parents 3bece10 + 17543d7 commit 13d7a35
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 18 deletions.
42 changes: 41 additions & 1 deletion br_nfse_imperial/models/invoice_eletronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import time
import base64
import logging
from datetime import datetime
from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DTFT
from odoo.tools.safe_eval import safe_eval

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -182,6 +184,33 @@ def _prepare_eletronic_invoice_values(self):
res.update(nfse_vals)
return res

def _find_attachment_ids_email(self):
atts = super(InvoiceEletronic, self)._find_attachment_ids_email()
if self.model not in ('010'):
return atts
attachment_obj = self.env['ir.attachment']

danfe_report = self.env['ir.actions.report'].search(
[('report_name', '=',
'br_nfse_imperial.main_template_br_nfse_danfe_imperial')])
report_service = danfe_report.xml_id
danfse, dummy = self.env.ref(report_service).render_qweb_pdf([self.id])
report_name = safe_eval(danfe_report.print_report_name,
{'object': self, 'time': time})
filename = "%s.%s" % (report_name, "pdf")
if danfse:
danfe_id = attachment_obj.create(dict(
name=filename,
datas_fname=filename,
datas=base64.b64encode(danfse),
mimetype='application/pdf',
res_model='account.invoice',
res_id=self.invoice_id.id,
))
atts.append(danfe_id.id)

return atts

@api.multi
def action_post_validate(self):
super(InvoiceEletronic, self).action_post_validate()
Expand Down Expand Up @@ -313,3 +342,14 @@ def action_cancel_document(self, context=None, justificativa=None):
})
self._create_attachment('canc', self, cancel['sent_xml'])
self._create_attachment('canc-ret', self, cancel['received_xml'])

def issqn_due_date(self):
date_emition = datetime.strptime(self.data_emissao, DTFT)
next_month = date_emition + relativedelta(months=1)
due_date = date(next_month.year, next_month.month, 10)
if due_date.weekday() >= 5:
while due_date.weekday() != 0:
due_date = due_date + timedelta(days=1)
format = "%d/%m/%Y"
due_date = datetime.strftime(due_date, format)
return due_date
35 changes: 18 additions & 17 deletions br_nfse_imperial/reports/danfse_imperial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
string="Nota de Serviço - Imperial"
model="invoice.eletronic"
report_type="qweb-pdf"
file="br_nfse.main_template_br_nfse_danfe_imperial"
name="br_nfse.main_template_br_nfse_danfe_imperial" />
file="br_nfse_imperial.main_template_br_nfse_danfe_imperial"
name="br_nfse_imperial.main_template_br_nfse_danfe_imperial" />

<record id="paperformat_br_nfse_danfse" model="report.paperformat">
<field name="name">Danfe Imperial</field>
Expand Down Expand Up @@ -165,15 +165,23 @@
</div>
<div class="row" style="border: 1px solid black;padding: 0 0 5px 5px;">
<div class="col-xs-12" style="text-align:center;">
<strong>INTERMEDIÁRIO DE SERVIÇOS</strong>
<strong>Local da Prestação do Serviço </strong>
<br />
</div>
<div class="col-xs-4">
CPF/CNPJ:
<div class="col-xs-12">
Endereço:
<strong> ---- </strong>
</div>
<div class="col-xs-8">
Nome/Razão Social:
<div class="col-xs-12">
Bairro:
<strong> ---- </strong>
</div>
<div class="col-xs-7">
Municipio:
<strong> --- </strong>
</div>
<div class="col-xs-7">
CEP:
<strong> ---- </strong>
</div>
</div>
Expand Down Expand Up @@ -259,7 +267,6 @@
<div class="col-xs-12">
Código do serviço:
<br />
<strong t-field="doc.eletronic_item_ids[0].codigo_servico_paulistana"></strong> -
<strong t-field="doc.eletronic_item_ids[0].product_id.service_type_id.name"></strong>
</div>
</div>
Expand Down Expand Up @@ -327,14 +334,8 @@
<div class="row"
style="border: 1px solid black;min-height:170px; padding:0 0 5px 5px;">
<div style="text-align:center"><b>Outras informações</b></div>
<div style="float:left; width:50%;">
(1) Esta NFS-e foi emitida com respaldo na Lei nº 14.097/2005;
</div>
<div style="float:left; width:50%;">
(2) Esta NFS-e substitui o RPS Nº <span t-field="doc.numero" /> Série API, emitido em <span t-field="doc.data_emissao" t-options='{"format": "dd/MM/yyyy"}' />
</div>
<div style="float:left; width:50%;">
(3) Data de vencimento do ISS desta NFS-e: <span t-esc="doc.issqn_due_date()" />
<div class="col-xs-6">
Data de vencimento do ISS desta NFS-e: <span t-esc="doc.issqn_due_date()" />
</div>
<br />
<span t-field="doc.informacoes_legais"></span>
Expand All @@ -345,7 +346,7 @@
<template id="main_template_br_nfse_danfe_imperial">
<div class="article">
<t t-foreach="docs" t-as="doc">
<t t-call="br_nfse.danfse_report_template_imperial" t-lang="doc.partner_id.lang"/>
<t t-call="br_nfse_imperial.danfse_report_template_imperial" t-lang="doc.partner_id.lang"/>
</t>
</div>
</template>
Expand Down
2 changes: 2 additions & 0 deletions br_product/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
],
'data': [
'views/product_pricelist.xml',
'views/product_category.xml',
'views/product_template.xml',
],
}
24 changes: 24 additions & 0 deletions br_product/views/product_category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_br_product_category_form" model="ir.ui.view">
<field name="name">view.br_product.category.form</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="account.view_category_property_form"/>
<field name="arch" type="xml">
<field name="property_account_income_categ_id" position="attributes">
<!-- Esse carinha apenas adiciona o filtro do
'account_type' nos fields da categoria -->
<attribute name="domain">[('account_type', '=', 'income'),
('internal_type','=','other'),
('deprecated', '=', False)]</attribute>
</field>
<field name="property_account_expense_categ_id" position="attributes">
<attribute name="domain">[('account_type', '=', 'expense'),
('internal_type','=','other'),
('deprecated', '=', False)]</attribute>
</field>
</field>
</record>
</data>
</odoo>
23 changes: 23 additions & 0 deletions br_product/views/product_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_br_product_template_form" model="ir.ui.view">
<field name="name">view.br_product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<!-- Similar ao outro arquivo XML, ele apenas adiciona
o filtro do account_type aos fields do produto -->
<field name="property_account_income_id" position="attributes">
<attribute name="domain">[('account_type', '=', 'income'),
('internal_type','=','other'),
('deprecated', '=', False)]</attribute>
</field>
<field name="property_account_expense_id" position="attributes">
<attribute name="domain">[('account_type', '=', 'expense'),
('deprecated', '=', False)]</attribute>
</field>
</field>
</record>
</data>
</odoo>

0 comments on commit 13d7a35

Please sign in to comment.