Fixed dp_reports + removed untested module dp_sequence_date_range_monthly

develop
Ahmed Aly 2017-10-12 11:50:58 +02:00
parent 89c7ff574b
commit eaaa326fdc
28 changed files with 139 additions and 244 deletions

View File

@ -19,6 +19,6 @@
#
##############################################################################
import models
from . import models
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,7 +19,7 @@
#
##############################################################################
import ir_ui_menu
from . import ir_ui_menu
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,11 +19,11 @@
#
##############################################################################
from openerp import fields, models
from openerp import api
from openerp.tools.translate import _
from openerp import SUPERUSER_ID
from openerp import tools
from odoo import fields, models
from odoo import api
from odoo.tools.translate import _
from odoo import SUPERUSER_ID
from odoo import tools
DISABLED_MENUS = [
]

View File

@ -10,12 +10,11 @@
'author': 'datenpol gmbh',
'website': 'http://www.datenpol.at/',
'depends': [
'base',
'report'
'base'
],
'data': [
'data/paperformat.xml',
'reports/layouts.xml',
'reports/report_templates.xml',
],
# only loaded in demonstration mode
'demo': [],

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import report_helper
from . import report_helper
from . import res_company

View File

@ -1,15 +1,8 @@
from odoo import api, models
from odoo.report import report_sxw
class ReportHelper(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(ReportHelper, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
})
class ReportHelper(models.AbstractModel):
_name = "report.abstract_report"
@api.model
def _field_set_in_lines(self, lines, field):
@ -44,8 +37,3 @@ class ReportHelper(report_sxw.rml_parse):
elif currency_obj and currency_obj.position == 'before':
res = '%s %s' % (currency_obj.symbol, res)
return res
class AbstractReport(models.AbstractModel):
_inherit = 'report.abstract_report'
_wrapped_report_class = ReportHelper

View File

@ -0,0 +1,9 @@
from odoo import models, fields, api
class Company(models.Model):
_inherit = 'res.company'
external_report_layout = fields.Selection(selection_add=[("custom", "Custom")])

View File

@ -2,34 +2,36 @@
<odoo>
<data>
<template id="assets_common" inherit_id="report.assets_common">
<template id="report_assets_common" inherit_id="web.report_assets_common">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/less" href="/dp_reports/static/src/less/report_backend.less"/>
</xpath>
</template>
<template id="report.external_layout">
<!-- Multicompany -->
<t t-if="not o and doc">
<t t-set="o" t-value="doc"/>
<template id="external_layout" inherit_id="web.external_layout">
<xpath expr="." position="inside">
<t t-if="company.external_report_layout == 'custom'">
<t t-call="dp_reports.external_layout_custom"><t t-raw="0"/></t>
</t>
<t t-if="o and 'company_id' in o">
<t t-set="company" t-value="o.company_id"/>
</t>
<t t-if="not o or not 'company_id' in o">
<t t-set="company" t-value="res_company"/>
</t>
<t t-call="report.external_layout_header"/>
</xpath>
</template>
<template id="external_layout_custom">
<t t-call="dp_reports.external_layout_header"/>
<div class="article o_dp_report_layout">
<t t-raw="0"/>
</div>
<t t-call="dp_reports.external_layout_footer"/>
</template>
<!-- Report Header Full -->
<template id="report.external_layout_header">
<template id="external_layout_header">
<div class="header" style="font-size:10pt;">
<div class="row">
<div class="col-xs-7">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo"
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo.decode()"
style="max-height: 85px;"/>
<div style="margin-top: 15mm;">
<div name="company_address"

View File

@ -10,8 +10,7 @@
'author': 'datenpol gmbh',
'website': 'http://www.datenpol.at/',
'depends': [
'dp_reports',
'account'
'account_invoicing'
],
'data': [
'reports/invoice.xml',

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
import report_helper
from . import report_helper

View File

@ -8,3 +8,16 @@ class AccountInvoice(models.AbstractModel):
_inherit = 'report.abstract_report'
_template = 'account.report_invoice'
@api.model
def get_report_values(self, docids, data=None):
model = 'account.invoice'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}

View File

@ -3,7 +3,7 @@
<data>
<!-- Invoice Body -->
<template id="report_invoice_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
@ -57,13 +57,12 @@
</div>
</div>
<div class="row oe_mt32">
<div class="row mt32">
<div class="col-xs-12 text-left">
<h4>
<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">
Rechnung
</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">Proforma Rechnung</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Rechnungsentwurf</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Stornierte Rechnung</span>
<span t-if="o.type == 'out_refund'">Gutschrift</span>
@ -74,7 +73,7 @@
</div>
</div>
<table class="oe_mt32 table table-condensed">
<table class="mt32 table table-condensed">
<t t-set="art_number_is_set"
t-value="field_set_in_lines(o.invoice_line_ids, 'product_id.default_code')"/>
<t t-set="discount_is_set" t-value="field_set_in_lines(o.invoice_line_ids, 'discount')"/>
@ -121,7 +120,7 @@
<div class="row">
<div class="oe_mt32 col-xs-4 pull-right">
<div class="mt32 col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td>
@ -169,7 +168,7 @@
</template>
<template id="account.report_invoice">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_account.report_invoice_document" t-lang="o.partner_id.lang"/>
</t>
@ -178,7 +177,11 @@
</data>
<record id="account.account_invoices" model="ir.actions.report.xml">
<record id="account.account_invoices" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
<record id="account.account_invoices_without_payment" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
</odoo>

View File

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
import report_helper
from . import report_helper

View File

@ -8,9 +8,36 @@ class PurchaseQuotation(models.AbstractModel):
_inherit = 'report.abstract_report'
_template = 'purchase.report_purchasequotation'
@api.model
def get_report_values(self, docids, data=None):
model = 'purchase.order'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}
class PurchaseOrder(models.AbstractModel):
_name = 'report.purchase.report_purchaseorder'
_inherit = 'report.abstract_report'
_template = 'purchase.report_purchaseorder'
@api.model
def get_report_values(self, docids, data=None):
model = 'purchase.order'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}

View File

@ -2,7 +2,7 @@
<odoo>
<data>
<template id="report_purchaseorder_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
@ -158,7 +158,7 @@
</template>
<template id="purchase.report_purchaseorder">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_purchase.report_purchaseorder_document" t-lang="o.partner_id.lang"/>
</t>
@ -168,7 +168,7 @@
</data>
<record id="purchase.action_report_purchase_order" model="ir.actions.report.xml">
<record id="purchase.action_report_purchase_order" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
</odoo>

View File

@ -2,7 +2,7 @@
<odoo>
<data>
<template id="report_purchasequotation_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
@ -141,17 +141,16 @@
</template>
<template id="purchase.report_purchasequotation">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_purchase.report_purchasequotation_document" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
</data>
<record id="purchase.report_purchase_quotation" model="ir.actions.report.xml">
<record id="purchase.report_purchase_quotation" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
</odoo>

View File

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
import report_helper
from . import report_helper

View File

@ -8,3 +8,15 @@ class SaleOrder(models.AbstractModel):
_inherit = 'report.abstract_report'
_template = 'sale.report_saleorder'
@api.model
def get_report_values(self, docids, data=None):
model = 'sale.order'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}

View File

@ -3,7 +3,7 @@
<data>
<!-- Sale Order Body -->
<template id="report_saleorder_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
@ -172,7 +172,7 @@
</template>
<template id="sale.report_saleorder">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_sale.report_saleorder_document" t-lang="o.partner_id.lang"/>
</t>
@ -182,7 +182,7 @@
</data>
<record id="sale.report_sale_order" model="ir.actions.report.xml">
<record id="sale.action_report_saleorder" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
</odoo>

View File

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
import report_helper
from . import report_helper

View File

@ -8,3 +8,15 @@ class StockPicking(models.AbstractModel):
_inherit = 'report.abstract_report'
_template = 'stock.report_deliveryslip'
@api.model
def get_report_values(self, docids, data=None):
model = 'stock.picking'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}

View File

@ -3,7 +3,7 @@
<data>
<!-- Sale Order Body -->
<template id="report_stockpicking_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
@ -61,15 +61,15 @@
<table class="oe_mt32 table table-condensed">
<t t-set="art_number_is_set"
t-value="field_set_in_lines(o.move_lines, 'product_id.default_code')"/>
<t t-set="lot_ids_is_set"
t-value="field_set_in_lines(o, 'pack_operation_product_ids.pack_lot_ids')"/>
<!--<t t-set="lot_ids_is_set"-->
<!--t-value="field_set_in_lines(o, 'pack_operation_product_ids.pack_lot_ids')"/>-->
<thead>
<tr>
<th class="text-center">Pos</th>
<th class="text-center" t-if="art_number_is_set">Art-Nr.</th>
<th class="text-left">Bezeichnung</th>
<th class="text-center">Menge</th>
<th class="text-right" t-if="lot_ids_is_set">Fertigungslos</th>
<!--<th class="text-right" t-if="lot_ids_is_set">Fertigungslos</th>-->
</tr>
</thead>
<tbody class="">
@ -88,11 +88,11 @@
<td class="text-center">
<span t-field="move_line.product_uom_qty"/>
</td>
<td class="text-right" t-if="lot_ids_is_set">
<t t-foreach="o.pack_operation_product_ids.pack_lot_ids" t-as="pack_lot">
<div class="co-xs-12" t-field="pack_lot.lot_id.name"/>
</t>
</td>
<!--<td class="text-right" t-if="lot_ids_is_set">-->
<!--<t t-foreach="o.pack_operation_product_ids.pack_lot_ids" t-as="pack_lot">-->
<!--<div class="co-xs-12" t-field="pack_lot.lot_id.name"/>-->
<!--</t>-->
<!--</td>-->
</tr>
</tbody>
</table>
@ -107,7 +107,7 @@
</template>
<template id="stock.report_deliveryslip">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_stock.report_stockpicking_document" t-lang="o.partner_id.lang"/>
</t>
@ -117,7 +117,7 @@
</data>
<record id="stock.action_report_delivery" model="ir.actions.report.xml">
<record id="stock.action_report_delivery" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
</record>
</odoo>

View File

@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import models
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# noinspection PyStatementEffect
{
'name': 'datenpol Sequence date range monthly',
'category': 'Custom',
'version': '1.0',
'description': """Für jeden Monat gibt es eine eigenen Nummernkreis""",
'author': 'datenpol gmbh',
'website': 'http://www.datenpol.at/',
'depends': [
'base',
],
'data': [
'views/ir_sequence_view.xml',
],
'installable': True,
'auto_install': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 20014-2016 datenpol gmbh (<http://www.datenpol.at/>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import ir_sequence
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,60 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from odoo import api, fields, models
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
class IrSequence(models.Model):
_inherit = 'ir.sequence'
monthly_date_range = fields.Boolean('Monthly date_range')
def _create_date_range_seq(self, date):
year = fields.Date.from_string(date).strftime('%Y')
if self.monthly_date_range:
month = fields.Date.from_string(date).strftime('%m')
last_day = datetime(int(year), int(month), 1) + relativedelta(day=31)
date_from = '{}-{}-01'.format(year, month)
date_to = '{}-{}-{}'.format(year, month, last_day.day)
else:
date_from = '{}-01-01'.format(year)
date_to = '{}-12-31'.format(year)
date_range = self.env['ir.sequence.date_range'].search \
([('sequence_id', '=', self.id), ('date_from', '>=', date), ('date_from', '<=', date_to)],
order='date_from desc', limit=1)
if date_range:
date_to = datetime.strptime(date_range.date_from, '%Y-%m-%d') + timedelta(days=-1)
date_to = date_to.strftime('%Y-%m-%d')
date_range = self.env['ir.sequence.date_range'].search \
([('sequence_id', '=', self.id), ('date_to', '>=', date_from), ('date_to', '<=', date)],
order='date_to desc',
limit=1)
if date_range:
date_from = datetime.strptime(date_range.date_to, '%Y-%m-%d') + timedelta(days=1)
date_from = date_from.strftime('%Y-%m-%d')
seq_date_range = self.env['ir.sequence.date_range'].sudo().create({
'date_from': date_from,
'date_to': date_to,
'sequence_id': self.id,
})
return seq_date_range

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- IR_SEQUENCE - EXTENDED FORM -->
<record id="dp_ir_sequence_form" model="ir.ui.view">
<field name="name">dp_ir_sequence_form</field>
<field name="model">ir.sequence</field>
<field name="inherit_id" ref="base.sequence_view"/>
<field name="arch" type="xml">
<field name="use_date_range" position="after">
<field name="monthly_date_range"/>
</field>
</field>
</record>
</data>
</odoo>