Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
document_attachment
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
document_attachment
Commits
ab90580d87c3
Commit
ab90580d87c3
authored
5 years ago
by
oury.balde
Browse files
Options
Downloads
Patches
Plain Diff
Overwrite postprocess_pdf_report hook to add doc attachment capabilities
parent
5bca3edf14ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
__manifest__.py
+5
-1
5 additions, 1 deletion
__manifest__.py
models/__init__.py
+1
-0
1 addition, 0 deletions
models/__init__.py
models/ir_actions_report.py
+80
-0
80 additions, 0 deletions
models/ir_actions_report.py
views/ir_actions_report.xml
+26
-0
26 additions, 0 deletions
views/ir_actions_report.xml
with
112 additions
and
1 deletion
__manifest__.py
+
5
−
1
View file @
ab90580d
...
...
@@ -36,7 +36,11 @@
"""
,
"
website
"
:
"
http://odoo.consulting/
"
,
"
depends
"
:
[
"
base
"
,
"
document
"
],
"
data
"
:
[
"
security/ir.model.access.csv
"
,
"
views/document_attachment.xml
"
],
"
data
"
:
[
"
security/ir.model.access.csv
"
,
"
views/document_attachment.xml
"
,
"
views/ir_actions_report.xml
"
,
],
"
test
"
:
[],
"
installable
"
:
True
,
}
This diff is collapsed.
Click to expand it.
models/__init__.py
+
1
−
0
View file @
ab90580d
# flake8: noqa
from
.
import
document_attachment
from
.
import
ir_actions_report
This diff is collapsed.
Click to expand it.
models/ir_actions_report.py
0 → 100644
+
80
−
0
View file @
ab90580d
##############################################################################
#
# Accounting customizations for GLE JAL
# Copyright (C) 2019 XCG Consulting (www.xcg-consulting.fr)
#
# 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
class
IrActReport
(
models
.
Model
):
_inherit
=
"
ir.actions.report
"
docatt_use
=
fields
.
Boolean
(
string
=
"
Save as Document Attachment
"
)
docatt_field_id
=
fields
.
Many2one
(
comodel_name
=
"
ir.model.fields
"
,
string
=
"
Field for document attachment
"
,
domain
=
"""
[
(
'
model
'
,
'
=
'
, model),
(
'
relation
'
,
'
=
'
,
'
document_attachment
'
)
]
"""
,
help
=
"
Specify the field which will contain the document attachment.
"
,
)
docatt_type_id
=
fields
.
Many2one
(
comodel_name
=
"
document_attachment.type
"
,
string
=
"
Document attachment type
"
,
domain
=
"
[(
'
model
'
,
'
=
'
, model)]
"
,
help
=
"
Specify the document attachment type
"
,
)
@api.multi
def
postprocess_pdf_report
(
self
,
record
,
buffer
):
"""
Catch invoice reports to save a typed link to the attached document.
"""
attachment
=
super
(
IrActReport
,
self
).
postprocess_pdf_report
(
record
,
buffer
)
if
(
attachment
and
self
and
len
(
self
)
==
1
and
self
.
docatt_type_id
and
self
.
docatt_field_id
and
self
.
report_name
):
setattr
(
record
,
self
.
docatt_field_id
.
name
,
(
self
.
env
[
"
document_attachment
"
]
.
with_context
(
res_id
=
record
.
id
,
res_model
=
record
.
_name
)
.
create
(
{
"
file_id
"
:
attachment
.
id
,
"
type_id
"
:
self
.
docatt_type_id
.
id
,
}
)
),
)
return
attachment
This diff is collapsed.
Click to expand it.
views/ir_actions_report.xml
0 → 100644
+
26
−
0
View file @
ab90580d
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record
id=
"docatt_act_report_xml_view"
model=
"ir.ui.view"
>
<field
name=
"name"
>
docatt_act_report_xml_view
</field>
<field
name=
"model"
>
ir.actions.report
</field>
<field
name=
"inherit_id"
ref=
"base.act_report_xml_view"
/>
<field
name=
"arch"
type=
"xml"
>
<page
name=
"advanced"
position=
"inside"
>
<group>
<field
name=
"docatt_use"
/>
<field
name=
"docatt_field_id"
attrs=
"{
'invisible': [('docatt_use', '=', False)],
'required': [('docatt_use', '=', True)]
}"
options=
"{'no_create': True}"
/>
<field
name=
"docatt_type_id"
attrs=
"{
'invisible': [('docatt_use', '=', False)],
'required': [('docatt_use', '=', True)]
}"
options=
"{'no_create': True}"
/>
</group>
</page>
</field>
</record>
</odoo>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment