[ADD]fields on category for oragnaising
[IMP]Image on category
180
.eslintrc.yml
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
env:
|
||||||
|
browser: true
|
||||||
|
|
||||||
|
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
|
||||||
|
parserOptions:
|
||||||
|
ecmaVersion: 2017
|
||||||
|
|
||||||
|
# Globals available in Odoo that shouldn't produce errorings
|
||||||
|
globals:
|
||||||
|
_: readonly
|
||||||
|
$: readonly
|
||||||
|
fuzzy: readonly
|
||||||
|
jQuery: readonly
|
||||||
|
moment: readonly
|
||||||
|
odoo: readonly
|
||||||
|
openerp: readonly
|
||||||
|
Promise: readonly
|
||||||
|
|
||||||
|
# Styling is handled by Prettier, so we only need to enable AST rules;
|
||||||
|
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
|
||||||
|
rules:
|
||||||
|
accessor-pairs: warn
|
||||||
|
array-callback-return: warn
|
||||||
|
callback-return: warn
|
||||||
|
capitalized-comments:
|
||||||
|
- warn
|
||||||
|
- always
|
||||||
|
- ignoreConsecutiveComments: true
|
||||||
|
ignoreInlineComments: true
|
||||||
|
complexity:
|
||||||
|
- warn
|
||||||
|
- 15
|
||||||
|
constructor-super: warn
|
||||||
|
dot-notation: warn
|
||||||
|
eqeqeq: warn
|
||||||
|
global-require: warn
|
||||||
|
handle-callback-err: warn
|
||||||
|
id-blacklist: warn
|
||||||
|
id-match: warn
|
||||||
|
init-declarations: error
|
||||||
|
max-depth: warn
|
||||||
|
max-nested-callbacks: warn
|
||||||
|
max-statements-per-line: warn
|
||||||
|
no-alert: warn
|
||||||
|
no-array-constructor: warn
|
||||||
|
no-caller: warn
|
||||||
|
no-case-declarations: warn
|
||||||
|
no-class-assign: warn
|
||||||
|
no-cond-assign: error
|
||||||
|
no-const-assign: error
|
||||||
|
no-constant-condition: warn
|
||||||
|
no-control-regex: warn
|
||||||
|
no-debugger: error
|
||||||
|
no-delete-var: warn
|
||||||
|
no-div-regex: warn
|
||||||
|
no-dupe-args: error
|
||||||
|
no-dupe-class-members: error
|
||||||
|
no-dupe-keys: error
|
||||||
|
no-duplicate-case: error
|
||||||
|
no-duplicate-imports: error
|
||||||
|
no-else-return: warn
|
||||||
|
no-empty-character-class: warn
|
||||||
|
no-empty-function: error
|
||||||
|
no-empty-pattern: error
|
||||||
|
no-empty: warn
|
||||||
|
no-eq-null: error
|
||||||
|
no-eval: error
|
||||||
|
no-ex-assign: error
|
||||||
|
no-extend-native: warn
|
||||||
|
no-extra-bind: warn
|
||||||
|
no-extra-boolean-cast: warn
|
||||||
|
no-extra-label: warn
|
||||||
|
no-fallthrough: warn
|
||||||
|
no-func-assign: error
|
||||||
|
no-global-assign: error
|
||||||
|
no-implicit-coercion:
|
||||||
|
- warn
|
||||||
|
- allow: ["~"]
|
||||||
|
no-implicit-globals: warn
|
||||||
|
no-implied-eval: warn
|
||||||
|
no-inline-comments: warn
|
||||||
|
no-inner-declarations: warn
|
||||||
|
no-invalid-regexp: warn
|
||||||
|
no-irregular-whitespace: warn
|
||||||
|
no-iterator: warn
|
||||||
|
no-label-var: warn
|
||||||
|
no-labels: warn
|
||||||
|
no-lone-blocks: warn
|
||||||
|
no-lonely-if: error
|
||||||
|
no-mixed-requires: error
|
||||||
|
no-multi-str: warn
|
||||||
|
no-native-reassign: error
|
||||||
|
no-negated-condition: warn
|
||||||
|
no-negated-in-lhs: error
|
||||||
|
no-new-func: warn
|
||||||
|
no-new-object: warn
|
||||||
|
no-new-require: warn
|
||||||
|
no-new-symbol: warn
|
||||||
|
no-new-wrappers: warn
|
||||||
|
no-new: warn
|
||||||
|
no-obj-calls: warn
|
||||||
|
no-octal-escape: warn
|
||||||
|
no-octal: warn
|
||||||
|
no-param-reassign: warn
|
||||||
|
no-path-concat: warn
|
||||||
|
no-process-env: warn
|
||||||
|
no-process-exit: warn
|
||||||
|
no-proto: warn
|
||||||
|
no-prototype-builtins: warn
|
||||||
|
no-redeclare: warn
|
||||||
|
no-regex-spaces: warn
|
||||||
|
no-restricted-globals: warn
|
||||||
|
no-restricted-imports: warn
|
||||||
|
no-restricted-modules: warn
|
||||||
|
no-restricted-syntax: warn
|
||||||
|
no-return-assign: error
|
||||||
|
no-script-url: warn
|
||||||
|
no-self-assign: warn
|
||||||
|
no-self-compare: warn
|
||||||
|
no-sequences: warn
|
||||||
|
no-shadow-restricted-names: warn
|
||||||
|
no-shadow: warn
|
||||||
|
no-sparse-arrays: warn
|
||||||
|
no-sync: warn
|
||||||
|
no-this-before-super: warn
|
||||||
|
no-throw-literal: warn
|
||||||
|
no-undef-init: warn
|
||||||
|
no-undef: error
|
||||||
|
no-unmodified-loop-condition: warn
|
||||||
|
no-unneeded-ternary: error
|
||||||
|
no-unreachable: error
|
||||||
|
no-unsafe-finally: error
|
||||||
|
no-unused-expressions: error
|
||||||
|
no-unused-labels: error
|
||||||
|
no-unused-vars: error
|
||||||
|
no-use-before-define: error
|
||||||
|
no-useless-call: warn
|
||||||
|
no-useless-computed-key: warn
|
||||||
|
no-useless-concat: warn
|
||||||
|
no-useless-constructor: warn
|
||||||
|
no-useless-escape: warn
|
||||||
|
no-useless-rename: warn
|
||||||
|
no-void: warn
|
||||||
|
no-with: warn
|
||||||
|
operator-assignment: [error, always]
|
||||||
|
prefer-const: warn
|
||||||
|
radix: warn
|
||||||
|
require-yield: warn
|
||||||
|
sort-imports: warn
|
||||||
|
spaced-comment: [error, always]
|
||||||
|
strict: [error, function]
|
||||||
|
use-isnan: error
|
||||||
|
valid-jsdoc:
|
||||||
|
- warn
|
||||||
|
- prefer:
|
||||||
|
arg: param
|
||||||
|
argument: param
|
||||||
|
augments: extends
|
||||||
|
constructor: class
|
||||||
|
exception: throws
|
||||||
|
func: function
|
||||||
|
method: function
|
||||||
|
prop: property
|
||||||
|
return: returns
|
||||||
|
virtual: abstract
|
||||||
|
yield: yields
|
||||||
|
preferType:
|
||||||
|
array: Array
|
||||||
|
bool: Boolean
|
||||||
|
boolean: Boolean
|
||||||
|
number: Number
|
||||||
|
object: Object
|
||||||
|
str: String
|
||||||
|
string: String
|
||||||
|
requireParamDescription: false
|
||||||
|
requireReturn: false
|
||||||
|
requireReturnDescription: false
|
||||||
|
requireReturnType: false
|
||||||
|
valid-typeof: warn
|
||||||
|
yoda: warn
|
10
.flake8
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[flake8]
|
||||||
|
max-line-length = 80
|
||||||
|
max-complexity = 16
|
||||||
|
# B = bugbear
|
||||||
|
# B9 = bugbear opinionated (incl line length)
|
||||||
|
select = C,E,F,W,B,B9
|
||||||
|
# E203: whitespace before ':' (black behaviour)
|
||||||
|
# E501: flake8 line length (covered by bugbear B950)
|
||||||
|
# W503: line break before binary operator (black behaviour)
|
||||||
|
ignore = E203,E501,W503
|
@ -1,11 +1,7 @@
|
|||||||
exclude: |
|
exclude: |
|
||||||
(?x)
|
(?x)
|
||||||
# NOT INSTALLABLE ADDONS
|
|
||||||
# END NOT INSTALLABLE ADDONS
|
|
||||||
# Files and folders generated by bots, to avoid loops
|
# Files and folders generated by bots, to avoid loops
|
||||||
^setup/|/static/description/index\.html$|
|
^setup/|/static/description/index\.html$|
|
||||||
# We don't want to mess with tool-generated files
|
|
||||||
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
|
|
||||||
# Maybe reactivate this when all README files include prettier ignore tags?
|
# Maybe reactivate this when all README files include prettier ignore tags?
|
||||||
^README\.md$|
|
^README\.md$|
|
||||||
# Library files can have extraneous formatting (even minimized)
|
# Library files can have extraneous formatting (even minimized)
|
||||||
@ -18,50 +14,32 @@ default_language_version:
|
|||||||
python: python3
|
python: python3
|
||||||
node: "14.13.0"
|
node: "14.13.0"
|
||||||
repos:
|
repos:
|
||||||
- repo: local
|
|
||||||
hooks:
|
|
||||||
# These files are most likely copier diff rejection junks; if found,
|
|
||||||
# review them manually, fix the problem (if needed) and remove them
|
|
||||||
- id: forbidden-files
|
|
||||||
name: forbidden files
|
|
||||||
entry: found forbidden files; remove them
|
|
||||||
language: fail
|
|
||||||
files: "\\.rej$"
|
|
||||||
#- repo: https://github.com/oca/maintainer-tools
|
|
||||||
#rev: ab1d7f6
|
|
||||||
#hooks:
|
|
||||||
#update the NOT INSTALLABLE ADDONS section above
|
|
||||||
#- id: oca-update-pre-commit-excluded-addons
|
|
||||||
#- id: oca-fix-manifest-website
|
|
||||||
#args: ["https://github.com/OCA/project"]
|
|
||||||
- repo: https://github.com/myint/autoflake
|
- repo: https://github.com/myint/autoflake
|
||||||
rev: v1.4
|
rev: v1.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: autoflake
|
- id: autoflake
|
||||||
args:
|
args: ["-i", "--ignore-init-module-imports"]
|
||||||
- --expand-star-imports
|
|
||||||
- --ignore-init-module-imports
|
|
||||||
- --in-place
|
|
||||||
- --remove-all-unused-imports
|
|
||||||
- --remove-duplicate-keys
|
|
||||||
- --remove-unused-variables
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 20.8b1
|
rev: 19.10b0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
- repo: https://github.com/prettier/pre-commit
|
||||||
rev: v2.1.2
|
rev: "v1.19.1"
|
||||||
hooks:
|
hooks:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
name: prettier (with plugin-xml)
|
# TODO Avoid awebdeveloper/pre-commit-prettier if possible
|
||||||
|
# HACK https://github.com/prettier/prettier/issues/7407
|
||||||
|
- repo: https://github.com/awebdeveloper/pre-commit-prettier
|
||||||
|
rev: v0.0.1
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
name: prettier xml plugin
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- "prettier@2.1.2"
|
- "prettier@1.19.1"
|
||||||
- "@prettier/plugin-xml@0.12.0"
|
- "@prettier/plugin-xml@0.7.2"
|
||||||
args:
|
files: \.xml$
|
||||||
- --plugin=@prettier/plugin-xml
|
|
||||||
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||||
rev: v7.8.1
|
rev: v6.8.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: eslint
|
- id: eslint
|
||||||
verbose: true
|
verbose: true
|
||||||
@ -69,7 +47,7 @@ repos:
|
|||||||
- --color
|
- --color
|
||||||
- --fix
|
- --fix
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.2.0
|
rev: v2.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
# exclude autogenerated files
|
# exclude autogenerated files
|
||||||
@ -90,48 +68,41 @@ repos:
|
|||||||
- id: check-xml
|
- id: check-xml
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
args: ["--fix=lf"]
|
args: ["--fix=lf"]
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
rev: v2.7.2
|
rev: 3.7.9
|
||||||
hooks:
|
|
||||||
- id: pyupgrade
|
|
||||||
args: ["--keep-percent-format"]
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.5.1
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
name: isort except __init__.py
|
|
||||||
args:
|
|
||||||
- --settings=.
|
|
||||||
exclude: /__init__\.py$
|
|
||||||
- repo: https://github.com/acsone/setuptools-odoo
|
|
||||||
rev: 2.6.0
|
|
||||||
hooks:
|
|
||||||
- id: setuptools-odoo-make-default
|
|
||||||
- id: setuptools-odoo-get-requirements
|
|
||||||
args:
|
|
||||||
- --output
|
|
||||||
- requirements.txt
|
|
||||||
- --header
|
|
||||||
- "# generated from manifests external_dependencies"
|
|
||||||
- repo: https://gitlab.com/PyCQA/flake8
|
|
||||||
rev: 3.8.3
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
name: flake8
|
name: flake8 except __init__.py
|
||||||
additional_dependencies: ["flake8-bugbear==20.1.4"]
|
exclude: /__init__\.py$
|
||||||
- repo: https://github.com/PyCQA/pylint
|
additional_dependencies: ["flake8-bugbear==19.8.0"]
|
||||||
rev: pylint-2.5.3
|
- id: flake8
|
||||||
|
name: flake8 only __init__.py
|
||||||
|
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
|
||||||
|
files: /__init__\.py$
|
||||||
|
additional_dependencies: ["flake8-bugbear==19.8.0"]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-pylint
|
||||||
|
rev: v2.5.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
name: pylint with optional checks
|
name: pylint with optional checks
|
||||||
args:
|
args: ["--rcfile=.pylintrc", "--exit-zero"]
|
||||||
- --rcfile=.pylintrc
|
|
||||||
- --exit-zero
|
|
||||||
verbose: true
|
verbose: true
|
||||||
additional_dependencies: &pylint_deps
|
additional_dependencies: ["pylint-odoo==3.5.0"]
|
||||||
- pylint-odoo==3.5.0
|
|
||||||
- id: pylint
|
- id: pylint
|
||||||
name: pylint with mandatory checks
|
name: pylint with mandatory checks
|
||||||
args:
|
args: ["--rcfile=.pylintrc-mandatory"]
|
||||||
- --rcfile=.pylintrc-mandatory
|
additional_dependencies: ["pylint-odoo==3.5.0"]
|
||||||
additional_dependencies: *pylint_deps
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v1.26.2
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v4.3.21
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
name: isort except __init__.py
|
||||||
|
exclude: /__init__\.py$
|
||||||
|
- repo: https://github.com/acsone/setuptools-odoo
|
||||||
|
rev: 2.5.2
|
||||||
|
hooks:
|
||||||
|
- id: setuptools-odoo-make-default
|
||||||
|
8
.prettierrc.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Defaults for all prettier-supported languages.
|
||||||
|
# Prettier will complete this with settings from .editorconfig file.
|
||||||
|
bracketSpacing: false
|
||||||
|
printWidth: 88
|
||||||
|
proseWrap: always
|
||||||
|
semi: true
|
||||||
|
trailingComma: "es5"
|
||||||
|
xmlWhitespaceSensitivity: "strict"
|
88
.pylintrc
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
[MASTER]
|
||||||
|
load-plugins=pylint_odoo
|
||||||
|
score=n
|
||||||
|
|
||||||
|
[ODOOLINT]
|
||||||
|
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
|
||||||
|
manifest_required_authors=Odoo Community Association (OCA)
|
||||||
|
manifest_required_keys=license
|
||||||
|
manifest_deprecated_keys=description,active
|
||||||
|
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||||
|
valid_odoo_versions=12.0
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
disable=all
|
||||||
|
|
||||||
|
# This .pylintrc contains optional AND mandatory checks and is meant to be
|
||||||
|
# loaded in an IDE to have it check everything, in the hope this will make
|
||||||
|
# optional checks more visible to contributors who otherwise never look at a
|
||||||
|
# green travis to see optional checks that failed.
|
||||||
|
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
|
||||||
|
# config as a blocking check.
|
||||||
|
|
||||||
|
enable=anomalous-backslash-in-string,
|
||||||
|
api-one-deprecated,
|
||||||
|
api-one-multi-together,
|
||||||
|
assignment-from-none,
|
||||||
|
attribute-deprecated,
|
||||||
|
class-camelcase,
|
||||||
|
dangerous-default-value,
|
||||||
|
dangerous-view-replace-wo-priority,
|
||||||
|
development-status-allowed,
|
||||||
|
duplicate-id-csv,
|
||||||
|
duplicate-key,
|
||||||
|
duplicate-xml-fields,
|
||||||
|
duplicate-xml-record-id,
|
||||||
|
eval-referenced,
|
||||||
|
eval-used,
|
||||||
|
incoherent-interpreter-exec-perm,
|
||||||
|
license-allowed,
|
||||||
|
manifest-author-string,
|
||||||
|
manifest-deprecated-key,
|
||||||
|
manifest-required-author,
|
||||||
|
manifest-required-key,
|
||||||
|
manifest-version-format,
|
||||||
|
method-compute,
|
||||||
|
method-inverse,
|
||||||
|
method-required-super,
|
||||||
|
method-search,
|
||||||
|
openerp-exception-warning,
|
||||||
|
pointless-statement,
|
||||||
|
pointless-string-statement,
|
||||||
|
print-used,
|
||||||
|
redundant-keyword-arg,
|
||||||
|
redundant-modulename-xml,
|
||||||
|
reimported,
|
||||||
|
relative-import,
|
||||||
|
return-in-init,
|
||||||
|
rst-syntax-error,
|
||||||
|
sql-injection,
|
||||||
|
too-few-format-args,
|
||||||
|
translation-field,
|
||||||
|
translation-required,
|
||||||
|
unreachable,
|
||||||
|
use-vim-comment,
|
||||||
|
wrong-tabs-instead-of-spaces,
|
||||||
|
xml-syntax-error,
|
||||||
|
# messages that do not cause the lint step to fail
|
||||||
|
consider-merging-classes-inherited,
|
||||||
|
create-user-wo-reset-password,
|
||||||
|
dangerous-filter-wo-user,
|
||||||
|
deprecated-module,
|
||||||
|
file-not-used,
|
||||||
|
invalid-commit,
|
||||||
|
missing-manifest-dependency,
|
||||||
|
missing-newline-extrafiles,
|
||||||
|
missing-readme,
|
||||||
|
no-utf8-coding-comment,
|
||||||
|
odoo-addons-relative-import,
|
||||||
|
old-api7-method-defined,
|
||||||
|
redefined-builtin,
|
||||||
|
too-complex,
|
||||||
|
unnecessary-utf8-coding-comment
|
||||||
|
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
|
||||||
|
output-format=colorized
|
||||||
|
reports=no
|
@ -8,7 +8,7 @@ manifest_required_authors=Odoo Community Association (OCA)
|
|||||||
manifest_required_keys=license
|
manifest_required_keys=license
|
||||||
manifest_deprecated_keys=description,active
|
manifest_deprecated_keys=description,active
|
||||||
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||||
valid_odoo_versions={{ odoo_version }}
|
valid_odoo_versions=12.0
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=all
|
disable=all
|
||||||
|
@ -3,36 +3,31 @@
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Document Page',
|
"name": "Documentation Page",
|
||||||
'version': '12.0.1.3.0',
|
"version": "12.0.1.2.0",
|
||||||
'category': 'Knowledge Management',
|
"category": "Knowledge Management",
|
||||||
'author': 'OpenERP SA, Odoo Community Association (OCA)',
|
"author": "OpenERP SA, Odoo Community Association (OCA)",
|
||||||
'images': [
|
"images": [
|
||||||
'images/category_list.png',
|
"images/category_list.png",
|
||||||
'images/create_category.png',
|
"images/create_category.png",
|
||||||
'images/page_list.png',
|
"images/page_list.png",
|
||||||
'images/create_page.png',
|
"images/create_page.png",
|
||||||
'images/customer_invoice.jpeg',
|
"images/customer_invoice.jpeg",
|
||||||
'images/page_history.png',
|
"images/page_history.png",
|
||||||
],
|
],
|
||||||
'website': 'https://github.com/OCA/knowledge',
|
"website": "https://github.com/OCA/knowledge",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'depends': [
|
"depends": ["mail", "knowledge"],
|
||||||
'mail',
|
"data": [
|
||||||
'knowledge',
|
"security/document_page_security.xml",
|
||||||
],
|
"security/ir.model.access.csv",
|
||||||
'data': [
|
"wizard/document_page_create_menu.xml",
|
||||||
'security/document_page_security.xml',
|
"wizard/document_page_show_diff.xml",
|
||||||
'security/ir.model.access.csv',
|
"views/document_page.xml",
|
||||||
'wizard/document_page_create_menu.xml',
|
"views/document_page_category.xml",
|
||||||
'wizard/document_page_show_diff.xml',
|
"views/document_page_history.xml",
|
||||||
'views/document_page.xml',
|
"views/document_page_assets.xml",
|
||||||
'views/document_page_category.xml',
|
"views/report_document_page.xml",
|
||||||
'views/document_page_history.xml',
|
|
||||||
'views/document_page_assets.xml',
|
|
||||||
'views/report_document_page.xml',
|
|
||||||
],
|
|
||||||
'demo': [
|
|
||||||
'demo/document_page.xml'
|
|
||||||
],
|
],
|
||||||
|
"demo": ["demo/document_page.xml"],
|
||||||
}
|
}
|
||||||
|
0
document_page/chmod
Normal file
@ -2,8 +2,10 @@
|
|||||||
<odoo noupdate="1">
|
<odoo noupdate="1">
|
||||||
|
|
||||||
<record id="base.user_demo" model="res.users">
|
<record id="base.user_demo" model="res.users">
|
||||||
<field eval="[(4, ref('knowledge.group_document_user'))]"
|
<field
|
||||||
name="groups_id"/>
|
eval="[(4, ref('knowledge.group_document_user'))]"
|
||||||
|
name="groups_id"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="demo_category1" model="document.page">
|
<record id="demo_category1" model="document.page">
|
||||||
|
0
document_page/images/category_list.png
Normal file → Executable file
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
0
document_page/images/create_category.png
Normal file → Executable file
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
0
document_page/images/create_page.png
Normal file → Executable file
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
0
document_page/images/page_history.png
Normal file → Executable file
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
0
document_page/images/page_list.png
Normal file → Executable file
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# 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 odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@ -9,53 +9,46 @@ class DocumentPage(models.Model):
|
|||||||
"""This class is use to manage Document."""
|
"""This class is use to manage Document."""
|
||||||
|
|
||||||
_name = "document.page"
|
_name = "document.page"
|
||||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
_inherit = ["mail.thread", "mail.activity.mixin"]
|
||||||
_description = "Document Page"
|
_description = "Document Page"
|
||||||
_parent_name = "parent_id"
|
_parent_name = "parent_id"
|
||||||
_parent_store = True
|
_parent_store = True
|
||||||
_rec_name = 'complete_name'
|
_rec_name = "complete_name"
|
||||||
_order = 'type, sequence, complete_name'
|
_order = "type, sequence, complete_name"
|
||||||
|
|
||||||
|
name = fields.Char("Title", required=True)
|
||||||
name = fields.Char('Title', required=True)
|
|
||||||
type = fields.Selection(
|
type = fields.Selection(
|
||||||
[('content', 'Content'), ('category', 'Category')],
|
[("content", "Content"), ("category", "Category")],
|
||||||
'Type',
|
"Type",
|
||||||
help="Page type",
|
help="Page type",
|
||||||
default="content"
|
default="content",
|
||||||
)
|
)
|
||||||
active = fields.Boolean(default=True)
|
active = fields.Boolean(default=True)
|
||||||
parent_id = fields.Many2one(
|
parent_id = fields.Many2one(
|
||||||
'document.page',
|
"document.page", "Category", domain=[("type", "=", "category")]
|
||||||
'Category',
|
|
||||||
domain=[('type', '=', 'category')]
|
|
||||||
)
|
|
||||||
child_ids = fields.One2many(
|
|
||||||
'document.page',
|
|
||||||
'parent_id',
|
|
||||||
'Children'
|
|
||||||
)
|
)
|
||||||
|
child_ids = fields.One2many("document.page", "parent_id", "Children")
|
||||||
content = fields.Text(
|
content = fields.Text(
|
||||||
"Content",
|
"Content",
|
||||||
compute='_compute_content',
|
compute="_compute_content",
|
||||||
inverse='_inverse_content',
|
inverse="_inverse_content",
|
||||||
search='_search_content',
|
search="_search_content",
|
||||||
required=True,
|
required=True,
|
||||||
copy=True,
|
copy=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# no-op computed field
|
# no-op computed field
|
||||||
draft_name = fields.Char(
|
draft_name = fields.Char(
|
||||||
string='Name',
|
string="Name",
|
||||||
help='Name for the changes made',
|
help="Name for the changes made",
|
||||||
compute=lambda x: x,
|
compute=lambda x: x,
|
||||||
inverse=lambda x: x,
|
inverse=lambda x: x,
|
||||||
)
|
)
|
||||||
|
|
||||||
# no-op computed field
|
# no-op computed field
|
||||||
draft_summary = fields.Char(
|
draft_summary = fields.Char(
|
||||||
string='Summary',
|
string="Summary",
|
||||||
help='Describe the changes made',
|
help="Describe the changes made",
|
||||||
compute=lambda x: x,
|
compute=lambda x: x,
|
||||||
inverse=lambda x: x,
|
inverse=lambda x: x,
|
||||||
)
|
)
|
||||||
@ -66,88 +59,85 @@ class DocumentPage(models.Model):
|
|||||||
"for all new page of this category.",
|
"for all new page of this category.",
|
||||||
)
|
)
|
||||||
history_head = fields.Many2one(
|
history_head = fields.Many2one(
|
||||||
'document.page.history',
|
"document.page.history",
|
||||||
'HEAD',
|
"HEAD",
|
||||||
compute='_compute_history_head',
|
compute="_compute_history_head",
|
||||||
store=True,
|
store=True,
|
||||||
auto_join=True,
|
auto_join=True,
|
||||||
)
|
)
|
||||||
history_ids = fields.One2many(
|
history_ids = fields.One2many(
|
||||||
'document.page.history',
|
"document.page.history",
|
||||||
'page_id',
|
"page_id",
|
||||||
'History',
|
"History",
|
||||||
order='create_date DESC',
|
order="create_date DESC",
|
||||||
readonly=True,
|
|
||||||
)
|
|
||||||
menu_id = fields.Many2one(
|
|
||||||
'ir.ui.menu',
|
|
||||||
"Menu",
|
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
|
menu_id = fields.Many2one("ir.ui.menu", "Menu", readonly=True,)
|
||||||
content_date = fields.Datetime(
|
content_date = fields.Datetime(
|
||||||
'Last Contribution Date',
|
"Last Contribution Date",
|
||||||
related='history_head.create_date',
|
related="history_head.create_date",
|
||||||
store=True,
|
store=True,
|
||||||
index=True,
|
index=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
content_uid = fields.Many2one(
|
content_uid = fields.Many2one(
|
||||||
'res.users',
|
"res.users",
|
||||||
'Last Contributor',
|
"Last Contributor",
|
||||||
related='history_head.create_uid',
|
related="history_head.create_uid",
|
||||||
store=True,
|
store=True,
|
||||||
index=True,
|
index=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
'res.company',
|
"res.company",
|
||||||
'Company',
|
"Company",
|
||||||
help='If set, page is accessible only from this company',
|
help="If set, page is accessible only from this company",
|
||||||
index=True,
|
index=True,
|
||||||
ondelete='cascade',
|
ondelete="cascade",
|
||||||
)
|
)
|
||||||
backend_url = fields.Char(
|
backend_url = fields.Char(
|
||||||
string='Backend URL',
|
string="Backend URL",
|
||||||
help='Use it to link resources univocally',
|
help="Use it to link resources univocally",
|
||||||
compute='_compute_backend_url',
|
compute="_compute_backend_url",
|
||||||
)
|
)
|
||||||
|
|
||||||
sequence = fields.Integer(
|
sequence = fields.Integer(
|
||||||
string='Sequence',
|
string="Sequence", default=10, help="Used to organise the category."
|
||||||
default=10,
|
)
|
||||||
help="Used to organise the category.")
|
|
||||||
|
|
||||||
parent_path = fields.Char(index=True)
|
parent_path = fields.Char(index=True)
|
||||||
complete_name = fields.Char(
|
complete_name = fields.Char(
|
||||||
'Complete Name', compute='_compute_complete_name',
|
"Complete Name", compute="_compute_complete_name", store=True
|
||||||
store=True)
|
|
||||||
|
|
||||||
image = fields.Binary(
|
|
||||||
"Image", attachment=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
color = fields.Integer(string='Color Index')
|
image = fields.Binary("Image", attachment=True,)
|
||||||
|
|
||||||
|
color = fields.Integer(string="Color Index")
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
child_ids = self
|
child_ids = self
|
||||||
if vals.get('color', False) and len(vals) ==1:
|
if vals.get("color", False) and len(vals) == 1:
|
||||||
child_ids = self.search([('type', '=', 'category'), ('parent_id', 'child_of', self.ids)])
|
child_ids = self.search(
|
||||||
|
[("type", "=", "category"),
|
||||||
|
("parent_id", "child_of", self.ids)]
|
||||||
|
)
|
||||||
res = super(DocumentPage, child_ids).write(vals)
|
res = super(DocumentPage, child_ids).write(vals)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.depends('name', 'parent_id.complete_name')
|
@api.depends("name", "parent_id.complete_name")
|
||||||
def _compute_complete_name(self):
|
def _compute_complete_name(self):
|
||||||
for category in self:
|
for category in self:
|
||||||
if category.parent_id:
|
if category.parent_id:
|
||||||
category.complete_name = '%s / %s' % (category.parent_id.complete_name, category.name)
|
category.complete_name = "{} / {}".format(
|
||||||
|
category.parent_id.complete_name, category.name,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
category.complete_name = category.name
|
category.complete_name = category.name
|
||||||
|
|
||||||
@api.depends('menu_id', 'parent_id.menu_id')
|
@api.depends("menu_id", "parent_id.menu_id")
|
||||||
def _compute_backend_url(self):
|
def _compute_backend_url(self):
|
||||||
tmpl = '/web#id={}&model=document.page&view_type=form'
|
tmpl = "/web#id={}&model=document.page&view_type=form"
|
||||||
for rec in self:
|
for rec in self:
|
||||||
url = tmpl.format(rec.id)
|
url = tmpl.format(rec.id)
|
||||||
# retrieve action
|
# retrieve action
|
||||||
@ -157,13 +147,13 @@ class DocumentPage(models.Model):
|
|||||||
action = parent.menu_id.action
|
action = parent.menu_id.action
|
||||||
parent = parent.parent_id
|
parent = parent.parent_id
|
||||||
if action:
|
if action:
|
||||||
url += '&action={}'.format(action.id)
|
url += "&action={}".format(action.id)
|
||||||
rec.backend_url = url
|
rec.backend_url = url
|
||||||
|
|
||||||
@api.constrains('parent_id')
|
@api.constrains("parent_id")
|
||||||
def _check_parent_id(self):
|
def _check_parent_id(self):
|
||||||
if not self._check_recursion():
|
if not self._check_recursion():
|
||||||
raise ValidationError(_('You cannot create recursive categories.'))
|
raise ValidationError(_("You cannot create recursive categories."))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_page_index(self, link=True):
|
def _get_page_index(self, link=True):
|
||||||
@ -172,7 +162,7 @@ class DocumentPage(models.Model):
|
|||||||
index = []
|
index = []
|
||||||
for subpage in self.child_ids:
|
for subpage in self.child_ids:
|
||||||
index += ["<li>" + subpage._get_page_index() + "</li>"]
|
index += ["<li>" + subpage._get_page_index() + "</li>"]
|
||||||
r = ''
|
r = ""
|
||||||
if link:
|
if link:
|
||||||
r = '<a href="{}">{}</a>'.format(self.backend_url, self.name)
|
r = '<a href="{}">{}</a>'.format(self.backend_url, self.name)
|
||||||
if index:
|
if index:
|
||||||
@ -180,35 +170,37 @@ class DocumentPage(models.Model):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('history_head')
|
@api.depends("history_head")
|
||||||
def _compute_content(self):
|
def _compute_content(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.type == 'category':
|
if rec.type == "category":
|
||||||
rec.content = rec._get_page_index(link=False)
|
rec.content = rec._get_page_index(link=False)
|
||||||
else:
|
else:
|
||||||
if rec.history_head:
|
if rec.history_head:
|
||||||
rec.content = rec.history_head.content
|
rec.content = rec.history_head.content
|
||||||
else:
|
else:
|
||||||
# html widget's default, so it doesn't trigger ghost save
|
# html widget's default, so it doesn't trigger ghost save
|
||||||
rec.content = '<p><br></p>'
|
rec.content = "<p><br></p>"
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _inverse_content(self):
|
def _inverse_content(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.type == 'content' and \
|
if rec.type == "content" and \
|
||||||
rec.content != rec.history_head.content:
|
rec.content != rec.history_head.content:
|
||||||
rec._create_history({
|
rec._create_history(
|
||||||
'name': rec.draft_name,
|
{
|
||||||
'summary': rec.draft_summary,
|
"name": rec.draft_name,
|
||||||
'content': rec.content,
|
"summary": rec.draft_summary,
|
||||||
})
|
"content": rec.content,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _search_content(self, operator, value):
|
def _search_content(self, operator, value):
|
||||||
return [('history_head.content', operator, value)]
|
return [("history_head.content", operator, value)]
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('history_ids')
|
@api.depends("history_ids")
|
||||||
def _compute_history_head(self):
|
def _compute_history_head(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.history_ids:
|
if rec.history_ids:
|
||||||
@ -217,20 +209,20 @@ class DocumentPage(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _create_history(self, vals):
|
def _create_history(self, vals):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
history = self.env['document.page.history']
|
history = self.env["document.page.history"]
|
||||||
vals['page_id'] = self.id
|
vals["page_id"] = self.id
|
||||||
return history.create(vals)
|
return history.create(vals)
|
||||||
|
|
||||||
@api.onchange("parent_id")
|
@api.onchange("parent_id")
|
||||||
def _onchange_parent_id(self):
|
def _onchange_parent_id(self):
|
||||||
"""We Set it the right content to the new parent."""
|
"""We Set it the right content to the new parent."""
|
||||||
if not self.content or self.content == '<p><br></p>':
|
if not self.content or self.content == "<p><br></p>":
|
||||||
if self.parent_id and self.parent_id.type == "category":
|
if self.parent_id and self.parent_id.type == "category":
|
||||||
self.content = self.parent_id.template
|
self.content = self.parent_id.template
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def unlink(self):
|
def unlink(self):
|
||||||
menus = self.mapped('menu_id')
|
menus = self.mapped("menu_id")
|
||||||
res = super().unlink()
|
res = super().unlink()
|
||||||
menus.unlink()
|
menus.unlink()
|
||||||
return res
|
return res
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
from odoo.tools.translate import _
|
from odoo.tools.translate import _
|
||||||
|
|
||||||
@ -11,19 +12,19 @@ class DocumentPageHistory(models.Model):
|
|||||||
|
|
||||||
_name = "document.page.history"
|
_name = "document.page.history"
|
||||||
_description = "Document Page History"
|
_description = "Document Page History"
|
||||||
_order = 'id DESC'
|
_order = "id DESC"
|
||||||
|
|
||||||
page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
|
page_id = fields.Many2one("document.page", "Page", ondelete="cascade")
|
||||||
name = fields.Char(index=True)
|
name = fields.Char(index=True)
|
||||||
summary = fields.Char(index=True)
|
summary = fields.Char(index=True)
|
||||||
content = fields.Text()
|
content = fields.Text()
|
||||||
diff = fields.Text(compute='_compute_diff')
|
diff = fields.Text(compute="_compute_diff")
|
||||||
|
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
'res.company',
|
"res.company",
|
||||||
'Company',
|
"Company",
|
||||||
help='If set, page is accessible only from this company',
|
help="If set, page is accessible only from this company",
|
||||||
related='page_id.company_id',
|
related="page_id.company_id",
|
||||||
store=True,
|
store=True,
|
||||||
index=True,
|
index=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
@ -32,13 +33,16 @@ class DocumentPageHistory(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _compute_diff(self):
|
def _compute_diff(self):
|
||||||
"""Shows a diff between this version and the previous version"""
|
"""Shows a diff between this version and the previous version"""
|
||||||
history = self.env['document.page.history']
|
history = self.env["document.page.history"]
|
||||||
for rec in self:
|
for rec in self:
|
||||||
prev = history.search([
|
prev = history.search(
|
||||||
('page_id', '=', rec.page_id.id),
|
[
|
||||||
('create_date', '<', rec.create_date)],
|
("page_id", "=", rec.page_id.id),
|
||||||
|
("create_date", "<", rec.create_date),
|
||||||
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
order='create_date DESC')
|
order="create_date DESC",
|
||||||
|
)
|
||||||
if prev:
|
if prev:
|
||||||
rec.diff = self._get_diff(prev.id, rec.id)
|
rec.diff = self._get_diff(prev.id, rec.id)
|
||||||
else:
|
else:
|
||||||
@ -47,23 +51,24 @@ class DocumentPageHistory(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def _get_diff(self, v1, v2):
|
def _get_diff(self, v1, v2):
|
||||||
"""Return the difference between two version of document version."""
|
"""Return the difference between two version of document version."""
|
||||||
text1 = v1 and self.browse(v1).content or ''
|
text1 = v1 and self.browse(v1).content or ""
|
||||||
text2 = v2 and self.browse(v2).content or ''
|
text2 = v2 and self.browse(v2).content or ""
|
||||||
# Include line breaks to make it more readable
|
# Include line breaks to make it more readable
|
||||||
# TODO: consider using a beautify library directly on the content
|
# TODO: consider using a beautify library directly on the content
|
||||||
text1 = text1.replace('</p><p>', '</p>\r\n<p>')
|
text1 = text1.replace("</p><p>", "</p>\r\n<p>")
|
||||||
text2 = text2.replace('</p><p>', '</p>\r\n<p>')
|
text2 = text2.replace("</p><p>", "</p>\r\n<p>")
|
||||||
line1 = text1.splitlines(True)
|
line1 = text1.splitlines(True)
|
||||||
line2 = text2.splitlines(True)
|
line2 = text2.splitlines(True)
|
||||||
if line1 == line2:
|
if line1 == line2:
|
||||||
return _('There are no changes in revisions.')
|
return _("There are no changes in revisions.")
|
||||||
else:
|
else:
|
||||||
diff = difflib.HtmlDiff()
|
diff = difflib.HtmlDiff()
|
||||||
return diff.make_table(
|
return diff.make_table(
|
||||||
line1, line2,
|
line1,
|
||||||
|
line2,
|
||||||
"Revision-{}".format(v1),
|
"Revision-{}".format(v1),
|
||||||
"Revision-{}".format(v2),
|
"Revision-{}".format(v2),
|
||||||
context=True
|
context=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
<record id="group_document_editor" model="res.groups">
|
<record id="group_document_editor" model="res.groups">
|
||||||
<field name="name">Editor</field>
|
<field name="name">Editor</field>
|
||||||
<field name="category_id" ref="knowledge.module_category_knowledge" />
|
<field name="category_id" ref="knowledge.module_category_knowledge" />
|
||||||
<field name="implied_ids" eval="[(4, ref('knowledge.group_document_user'))]"/>
|
<field
|
||||||
|
name="implied_ids"
|
||||||
|
eval="[(4, ref('knowledge.group_document_user'))]"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="group_document_manager" model="res.groups">
|
<record id="group_document_manager" model="res.groups">
|
||||||
@ -18,14 +21,18 @@
|
|||||||
<field name="name">document_page multi-company</field>
|
<field name="name">document_page multi-company</field>
|
||||||
<field name="model_id" ref="model_document_page" />
|
<field name="model_id" ref="model_document_page" />
|
||||||
<field name="global" eval="True" />
|
<field name="global" eval="True" />
|
||||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
<field
|
||||||
|
name="domain_force"
|
||||||
|
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.rule" id="document_page_history_rule">
|
<record model="ir.rule" id="document_page_history_rule">
|
||||||
<field name="name">document_page_history multi-company</field>
|
<field name="name">document_page_history multi-company</field>
|
||||||
<field name="model_id" ref="model_document_page_history" />
|
<field name="model_id" ref="model_document_page_history" />
|
||||||
<field name="global" eval="True" />
|
<field name="global" eval="True" />
|
||||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
<field
|
||||||
|
name="domain_force"
|
||||||
|
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
0
document_page/static/description/icon.png
Normal file → Executable file
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
0
document_page/static/description/index.html
Normal file → Executable file
@ -4,26 +4,25 @@ table.diff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table.diff .diff_header {
|
table.diff .diff_header {
|
||||||
background-color: #e0e0e0
|
background-color: #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.diff td.diff_header {
|
table.diff td.diff_header {
|
||||||
text-align: right
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.diff .diff_next {
|
table.diff .diff_next {
|
||||||
background-color:#c0c0c0
|
background-color: #c0c0c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.diff .diff_add {
|
table.diff .diff_add {
|
||||||
background-color:#aaffaa
|
background-color: #aaffaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.diff .diff_chg {
|
table.diff .diff_chg {
|
||||||
background-color:#ffff77
|
background-color: #ffff77;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.diff .diff_sub {
|
table.diff .diff_sub {
|
||||||
background-color:#ffaaaa
|
background-color: #ffaaaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
odoo.define('document_page.update_kanban', function (require) {
|
odoo.define("document_page.update_kanban", function(require) {
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
var core = require('web.core');
|
var KanbanRecord = require("web.KanbanRecord");
|
||||||
var Dialog = require('web.Dialog');
|
|
||||||
var KanbanRecord = require('web.KanbanRecord');
|
|
||||||
|
|
||||||
var QWeb = core.qweb;
|
|
||||||
var _t = core._t;
|
|
||||||
|
|
||||||
KanbanRecord.include({
|
KanbanRecord.include({
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -18,11 +13,16 @@ odoo.define('document_page.update_kanban', function (require) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_openRecord: function() {
|
_openRecord: function() {
|
||||||
if (this.modelName === 'document.page' && this.$(".o_document_page_kanban_boxes a").length) {
|
if (
|
||||||
this.$('.o_document_page_kanban_boxes a').first().click();
|
this.modelName === "document.page" &&
|
||||||
|
this.$(".o_document_page_kanban_boxes a").length
|
||||||
|
) {
|
||||||
|
this.$(".o_document_page_kanban_boxes a")
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
} else {
|
} else {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3,55 +3,53 @@ from odoo.tests import common
|
|||||||
|
|
||||||
|
|
||||||
class TestDocumentPage(common.TransactionCase):
|
class TestDocumentPage(common.TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDocumentPage, self).setUp()
|
super(TestDocumentPage, self).setUp()
|
||||||
self.page_obj = self.env['document.page']
|
self.page_obj = self.env["document.page"]
|
||||||
self.history_obj = self.env['document.page.history']
|
self.history_obj = self.env["document.page.history"]
|
||||||
self.category1 = self.env.ref('document_page.demo_category1')
|
self.category1 = self.env.ref("document_page.demo_category1")
|
||||||
self.page1 = self.env.ref('document_page.demo_page1')
|
self.page1 = self.env.ref("document_page.demo_page1")
|
||||||
|
|
||||||
def test_page_creation(self):
|
def test_page_creation(self):
|
||||||
page = self.page_obj.create({
|
page = self.page_obj.create(
|
||||||
'name': 'Test Page 1',
|
{
|
||||||
'parent_id': self.category1.id,
|
"name": "Test Page 1",
|
||||||
'content': 'Test content'
|
"parent_id": self.category1.id,
|
||||||
})
|
"content": "Test content",
|
||||||
self.assertEqual(page.content, 'Test content')
|
}
|
||||||
|
)
|
||||||
|
self.assertEqual(page.content, "Test content")
|
||||||
self.assertEqual(len(page.history_ids), 1)
|
self.assertEqual(len(page.history_ids), 1)
|
||||||
page.content = 'New content for Demo Page'
|
page.content = "New content for Demo Page"
|
||||||
self.assertEqual(len(page.history_ids), 2)
|
self.assertEqual(len(page.history_ids), 2)
|
||||||
|
|
||||||
def test_category_template(self):
|
def test_category_template(self):
|
||||||
page = self.page_obj.create({
|
page = self.page_obj.create(
|
||||||
'name': 'Test Page 2',
|
{"name": "Test Page 2", "parent_id": self.category1.id}
|
||||||
'parent_id': self.category1.id,
|
)
|
||||||
})
|
|
||||||
page._onchange_parent_id()
|
page._onchange_parent_id()
|
||||||
self.assertEqual(page.content, self.category1.template)
|
self.assertEqual(page.content, self.category1.template)
|
||||||
|
|
||||||
def test_page_history_diff(self):
|
def test_page_history_diff(self):
|
||||||
page = self.page_obj.create({
|
page = self.page_obj.create({
|
||||||
'name': 'Test Page 3',
|
"name": "Test Page 3",
|
||||||
'content': 'Test content'
|
"content": "Test content"})
|
||||||
})
|
page.content = "New content"
|
||||||
page.content = 'New content'
|
|
||||||
self.assertIsNotNone(page.history_ids[0].diff)
|
self.assertIsNotNone(page.history_ids[0].diff)
|
||||||
|
|
||||||
def test_page_link(self):
|
def test_page_link(self):
|
||||||
page = self.page_obj.create({
|
page = self.page_obj.create({
|
||||||
'name': 'Test Page 3',
|
"name": "Test Page 3",
|
||||||
'content': 'Test content'
|
"content": "Test content"})
|
||||||
})
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
page.backend_url,
|
page.backend_url,
|
||||||
'/web#id={}&model=document.page&view_type=form'.format(page.id)
|
"/web#id={}&model=document.page&view_type=form".format(page.id),
|
||||||
)
|
)
|
||||||
menu = self.env.ref('knowledge.menu_document')
|
menu = self.env.ref("knowledge.menu_document")
|
||||||
page.menu_id = menu
|
page.menu_id = menu
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
page.backend_url,
|
page.backend_url,
|
||||||
'/web#id={}&model=document.page&view_type=form&action={}'.format(
|
"/web#id={}&model=document.page&view_type=form&action={}".format(
|
||||||
page.id, menu.action.id
|
page.id, menu.action.id
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
@ -7,23 +7,23 @@ class TestDocumentPageCreateMenu(common.TransactionCase):
|
|||||||
|
|
||||||
def test_page_menu_creation(self):
|
def test_page_menu_creation(self):
|
||||||
"""Test page menu creation."""
|
"""Test page menu creation."""
|
||||||
menu_parent = self.env.ref('knowledge.menu_document')
|
menu_parent = self.env.ref("knowledge.menu_document")
|
||||||
|
|
||||||
menu_created = self.env['document.page.create.menu'].create(
|
menu_created = self.env["document.page.create.menu"].create(
|
||||||
{'menu_name': 'Wiki Test menu', 'menu_parent_id': menu_parent.id}
|
{"menu_name": "Wiki Test menu", "menu_parent_id": menu_parent.id}
|
||||||
)
|
)
|
||||||
|
|
||||||
menu = self.env['document.page.create.menu'].search(
|
menu = self.env["document.page.create.menu"].search(
|
||||||
[('id', '=', menu_created.id)]
|
[("id", "=", menu_created.id)]
|
||||||
)
|
)
|
||||||
menu.with_context(
|
menu.with_context(
|
||||||
active_id=[self.ref('document_page.demo_page1')]
|
active_id=[self.ref("document_page.demo_page1")]
|
||||||
).document_page_menu_create()
|
).document_page_menu_create()
|
||||||
|
|
||||||
fields_list = ["menu_name", "menu_name"]
|
fields_list = ["menu_name", "menu_name"]
|
||||||
|
|
||||||
res = menu.with_context(
|
res = menu.with_context(
|
||||||
active_id=[self.ref('document_page.demo_page1')]
|
active_id=[self.ref("document_page.demo_page1")]
|
||||||
).default_get(fields_list)
|
).default_get(fields_list)
|
||||||
|
|
||||||
self.assertEqual(res['menu_name'], 'OpenERP 6.1. Functional Demo')
|
self.assertEqual(res["menu_name"], "OpenERP 6.1. Functional Demo")
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
@ -7,14 +6,14 @@ class TestDocumentPageHistory(common.TransactionCase):
|
|||||||
|
|
||||||
def test_page_history_demo_page1(self):
|
def test_page_history_demo_page1(self):
|
||||||
"""Test page history demo page1."""
|
"""Test page history demo page1."""
|
||||||
page = self.env.ref('document_page.demo_page1')
|
page = self.env.ref("document_page.demo_page1")
|
||||||
page.content = 'Test content updated'
|
page.content = "Test content updated"
|
||||||
history_document = self.env['document.page.history']
|
history_document = self.env["document.page.history"]
|
||||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||||
active_ids = [i.id for i in history_pages]
|
active_ids = [i.id for i in history_pages]
|
||||||
|
|
||||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||||
self.assertEqual(result, 'There are no changes in revisions.')
|
self.assertEqual(result, "There are no changes in revisions.")
|
||||||
|
|
||||||
result = history_document._get_diff(active_ids[0], active_ids[1])
|
result = history_document._get_diff(active_ids[0], active_ids[1])
|
||||||
self.assertNotEqual(result, 'There are no changes in revisions.')
|
self.assertNotEqual(result, "There are no changes in revisions.")
|
||||||
|
@ -8,12 +8,12 @@ class TestDocumentPageShowDiff(common.TransactionCase):
|
|||||||
|
|
||||||
def test_show_demo_page1_diff(self):
|
def test_show_demo_page1_diff(self):
|
||||||
"""Show test page history difference."""
|
"""Show test page history difference."""
|
||||||
page = self.env.ref('document_page.demo_page1')
|
page = self.env.ref("document_page.demo_page1")
|
||||||
|
|
||||||
show_diff_object = self.env['wizard.document.page.history.show_diff']
|
show_diff_object = self.env["wizard.document.page.history.show_diff"]
|
||||||
|
|
||||||
history_document = self.env['document.page.history']
|
history_document = self.env["document.page.history"]
|
||||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
show_diff_object.with_context(
|
show_diff_object.with_context(
|
||||||
@ -21,10 +21,10 @@ class TestDocumentPageShowDiff(common.TransactionCase):
|
|||||||
)._get_diff()
|
)._get_diff()
|
||||||
)
|
)
|
||||||
|
|
||||||
page.write({'content': 'Text content updated'})
|
page.write({"content": "Text content updated"})
|
||||||
page.write({'content': 'Text updated'})
|
page.write({"content": "Text updated"})
|
||||||
|
|
||||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||||
|
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
show_diff_object.with_context(
|
show_diff_object.with_context(
|
||||||
|
@ -40,8 +40,18 @@
|
|||||||
<form string="Document Page">
|
<form string="Document Page">
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button name="toggle_active" type="object" groups="document_page.group_document_manager" class="oe_stat_button" icon="fa-archive">
|
<button
|
||||||
<field name="active" widget="boolean_button" options="{'terminology': 'archive'}"/>
|
name="toggle_active"
|
||||||
|
type="object"
|
||||||
|
groups="document_page.group_document_manager"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-archive"
|
||||||
|
>
|
||||||
|
<field
|
||||||
|
name="active"
|
||||||
|
widget="boolean_button"
|
||||||
|
options="{'terminology': 'archive'}"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<field name="type" invisible="1" />
|
<field name="type" invisible="1" />
|
||||||
@ -50,22 +60,50 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<group>
|
<group>
|
||||||
<div>
|
<div>
|
||||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
|
<field
|
||||||
|
name="content"
|
||||||
|
widget="html"
|
||||||
|
placeholder="e.g. Once upon a time..."
|
||||||
|
required="1"
|
||||||
|
options="{'safe': True}"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="info" string="Information">
|
<page name="info" string="Information">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="parent_id" string="Category" required="True" context="{'default_type':'category'}"/>
|
<field
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
name="parent_id"
|
||||||
|
string="Category"
|
||||||
|
required="True"
|
||||||
|
context="{'default_type':'category'}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="company_id"
|
||||||
|
groups="base.group_multi_company"
|
||||||
|
/>
|
||||||
<field name="content_uid" />
|
<field name="content_uid" />
|
||||||
<field name="content_date" />
|
<field name="content_date" />
|
||||||
<field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/>
|
<field
|
||||||
|
name="menu_id"
|
||||||
|
readonly="1"
|
||||||
|
attrs="{'invisible': [('menu_id','=',False)]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group string="Revision" class="oe_edit_only">
|
<group string="Revision" class="oe_edit_only">
|
||||||
<field name="draft_name" placeholder="Rev 01" required="True" class="oe_edit_only" />
|
<field
|
||||||
<field name="draft_summary" placeholder="eg: Changed ... for ..." required="True" class="oe_edit_only" />
|
name="draft_name"
|
||||||
|
placeholder="Rev 01"
|
||||||
|
required="True"
|
||||||
|
class="oe_edit_only"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="draft_summary"
|
||||||
|
placeholder="eg: Changed ... for ..."
|
||||||
|
required="True"
|
||||||
|
class="oe_edit_only"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
@ -83,7 +121,10 @@
|
|||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
<field name="message_follower_ids" widget="mail_followers"/>
|
<field
|
||||||
|
name="message_follower_ids"
|
||||||
|
widget="mail_followers"
|
||||||
|
/>
|
||||||
<field name="activity_ids" widget="mail_activity" />
|
<field name="activity_ids" widget="mail_activity" />
|
||||||
<field name="message_ids" widget="mail_thread" />
|
<field name="message_ids" widget="mail_thread" />
|
||||||
</div>
|
</div>
|
||||||
@ -100,7 +141,13 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<field name="name" placeholder="Name" />
|
<field name="name" placeholder="Name" />
|
||||||
</h1>
|
</h1>
|
||||||
<field name="content" widget="html" class="oe_view_only" required="1" options='{"safe": True}'/>
|
<field
|
||||||
|
name="content"
|
||||||
|
widget="html"
|
||||||
|
class="oe_view_only"
|
||||||
|
required="1"
|
||||||
|
options='{"safe": True}'
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@ -111,15 +158,30 @@
|
|||||||
<field name="model">document.page</field>
|
<field name="model">document.page</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Document Page">
|
<search string="Document Page">
|
||||||
<field name="name" string="Content"
|
<field
|
||||||
filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
|
name="name"
|
||||||
|
string="Content"
|
||||||
|
filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"
|
||||||
|
/>
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
<field name="create_uid" />
|
<field name="create_uid" />
|
||||||
<field name="content_uid" />
|
<field name="content_uid" />
|
||||||
<group expand="0" string="Group By...">
|
<group expand="0" string="Group By...">
|
||||||
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
|
<filter
|
||||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
|
name="group_by_category"
|
||||||
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
string="Category"
|
||||||
|
context="{'group_by':'parent_id'}"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="group_by_author"
|
||||||
|
string="Author"
|
||||||
|
context="{'group_by':'create_uid'}"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="group_by_last_contributor"
|
||||||
|
string="Last Contributor"
|
||||||
|
context="{'group_by':'content_uid'}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
@ -158,17 +220,21 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<menuitem id="menu_wiki"
|
<menuitem
|
||||||
|
id="menu_wiki"
|
||||||
name="Pages"
|
name="Pages"
|
||||||
parent="knowledge.menu_document_root"
|
parent="knowledge.menu_document_root"
|
||||||
sequence="10"/>
|
sequence="10"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
<menuitem id="menu_page"
|
<menuitem
|
||||||
|
id="menu_page"
|
||||||
name="Pages"
|
name="Pages"
|
||||||
parent="menu_wiki"
|
parent="menu_wiki"
|
||||||
action="action_page"
|
action="action_page"
|
||||||
sequence="20"/>
|
sequence="20"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
<act_window
|
<act_window
|
||||||
@ -178,6 +244,7 @@
|
|||||||
target="new"
|
target="new"
|
||||||
view_type="form"
|
view_type="form"
|
||||||
view_mode="form"
|
view_mode="form"
|
||||||
src_model="document.page"/>
|
src_model="document.page"
|
||||||
|
/>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<template id="assets_backend" name="document_page assets" inherit_id="web.assets_backend">
|
<template
|
||||||
|
id="assets_backend"
|
||||||
|
name="document_page assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<link rel="stylesheet" href="/document_page/static/src/css/document_page.css"/>
|
<link
|
||||||
<script type="text/javascript" src="/document_page/static/src/js/document_page_kanban.js"></script>
|
rel="stylesheet"
|
||||||
|
href="/document_page/static/src/css/document_page.css"
|
||||||
|
/>
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/document_page/static/src/js/document_page_kanban.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
118
document_page/views/document_page_category.xml
Executable file → Normal file
@ -17,7 +17,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="parent_id" string="Category" context="{'default_type':'category'}" />
|
<field
|
||||||
|
name="parent_id"
|
||||||
|
string="Category"
|
||||||
|
context="{'default_type':'category'}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="write_uid" groups="base.group_no_one" />
|
<field name="write_uid" groups="base.group_no_one" />
|
||||||
@ -30,7 +34,12 @@
|
|||||||
<field name="template" placeholder="e.g. Once upon a time..." />
|
<field name="template" placeholder="e.g. Once upon a time..." />
|
||||||
</page>
|
</page>
|
||||||
<page string="Documents" name="documents">
|
<page string="Documents" name="documents">
|
||||||
<field name="content" widget="html" class="oe_view_only" options='{"safe": True}' />
|
<field
|
||||||
|
name="content"
|
||||||
|
widget="html"
|
||||||
|
class="oe_view_only"
|
||||||
|
options='{"safe": True}'
|
||||||
|
/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
@ -46,7 +55,9 @@
|
|||||||
<field name="name">Browse Wiki Content</field>
|
<field name="name">Browse Wiki Content</field>
|
||||||
<field name="res_model">document.page</field>
|
<field name="res_model">document.page</field>
|
||||||
<field name="domain">[]</field>
|
<field name="domain">[]</field>
|
||||||
<field name="context">{'default_type': 'content', 'search_default_no_parent_id':1, }</field>
|
<field
|
||||||
|
name="context"
|
||||||
|
>{'default_type': 'content', 'search_default_no_parent_id':1, }</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">kanban,tree,form</field>
|
<field name="view_mode">kanban,tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
@ -55,7 +66,9 @@
|
|||||||
<field name="name">Browse Wiki Content</field>
|
<field name="name">Browse Wiki Content</field>
|
||||||
<field name="res_model">document.page</field>
|
<field name="res_model">document.page</field>
|
||||||
<field name="domain">[]</field>
|
<field name="domain">[]</field>
|
||||||
<field name="context">{'default_type': 'content', 'search_default_parent_id': [active_id] }</field>
|
<field
|
||||||
|
name="context"
|
||||||
|
>{'default_type': 'content', 'search_default_parent_id': [active_id] }</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">kanban,tree,form</field>
|
<field name="view_mode">kanban,tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
@ -77,11 +90,18 @@
|
|||||||
<field name="color" />
|
<field name="color" />
|
||||||
<templates>
|
<templates>
|
||||||
<t t-name="kanban-box">
|
<t t-name="kanban-box">
|
||||||
<div t-att-class="'oe_kanban_global_area' + ' oe_kanban_color_'+ (kanban_getcolor(record.color.raw_value)) + ' oe_kanban_global_click' ">
|
<div
|
||||||
|
t-att-class="'oe_kanban_global_area' + ' oe_kanban_color_'+ (kanban_getcolor(record.color.raw_value)) + ' oe_kanban_global_click' "
|
||||||
|
>
|
||||||
<div class="o_kanban_image">
|
<div class="o_kanban_image">
|
||||||
<div class="o_kanban_image_wrapper">
|
<div class="o_kanban_image_wrapper">
|
||||||
<t t-if="record.type.raw_value == 'category'">
|
<t t-if="record.type.raw_value == 'category'">
|
||||||
<img class="o_kanban_image" t-if="record.image.raw_value" t-att-src="kanban_image('document.page', 'image', record.id.raw_value)" t-att-alt="record.display_name"/>
|
<img
|
||||||
|
class="o_kanban_image"
|
||||||
|
t-if="record.image.raw_value"
|
||||||
|
t-att-src="kanban_image('document.page', 'image', record.id.raw_value)"
|
||||||
|
t-att-alt="record.display_name"
|
||||||
|
/>
|
||||||
<span style="font-size: 64px; color: lightslategray">
|
<span style="font-size: 64px; color: lightslategray">
|
||||||
<i t-if="!record.image.raw_value" class="o_kanban_image fa fa-folder-open" />
|
<i t-if="!record.image.raw_value" class="o_kanban_image fa fa-folder-open" />
|
||||||
</span>
|
</span>
|
||||||
@ -102,13 +122,26 @@
|
|||||||
</strong>
|
</strong>
|
||||||
<br />
|
<br />
|
||||||
<small t-if="record.parent_id.raw_value">
|
<small t-if="record.parent_id.raw_value">
|
||||||
<img t-att-src="kanban_image('document.page', 'image', record.parent_id.raw_value)" t-att-alt="record.parent_id.display_name" width="24" height="24"/>
|
<img
|
||||||
|
t-att-src="kanban_image('document.page', 'image', record.parent_id.raw_value)"
|
||||||
|
t-att-alt="record.parent_id.display_name"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
/>
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="o_dropdown_kanban dropdown" groups="base.group_user">
|
<div class="o_dropdown_kanban dropdown" groups="base.group_user">
|
||||||
<a role="button" class="dropdown-toggle o-no-caret btn" data-toggle="dropdown" data-display="static" href="#" aria-label="Dropdown menu" title="Dropdown menu">
|
<a
|
||||||
|
role="button"
|
||||||
|
class="dropdown-toggle o-no-caret btn"
|
||||||
|
data-toggle="dropdown"
|
||||||
|
data-display="static"
|
||||||
|
href="#"
|
||||||
|
aria-label="Dropdown menu"
|
||||||
|
title="Dropdown menu"
|
||||||
|
>
|
||||||
<span class="fa fa-ellipsis-v" />
|
<span class="fa fa-ellipsis-v" />
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" role="menu">
|
<div class="dropdown-menu" role="menu">
|
||||||
@ -124,14 +157,28 @@
|
|||||||
<field name="write_date" widget="date" />
|
<field name="write_date" widget="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_kanban_bottom_right">
|
<div class="oe_kanban_bottom_right">
|
||||||
<img t-att-src="kanban_image('res.users', 'image_small', record.content_uid.raw_value)" t-att-title="record.content_uid.value" t-att-alt="record.content_uid.value" width="24" height="24" class="oe_kanban_avatar"/>
|
<img
|
||||||
|
t-att-src="kanban_image('res.users', 'image_small', record.content_uid.raw_value)"
|
||||||
|
t-att-title="record.content_uid.value"
|
||||||
|
t-att-alt="record.content_uid.value"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
class="oe_kanban_avatar"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div t-if="record.type.raw_value == 'category'" class="o_document_page_kanban_boxes">
|
<div
|
||||||
<a class="o_document_page_kanban_box" name="%(action_browse_all_content)d" type="action">
|
t-if="record.type.raw_value == 'category'"
|
||||||
|
class="o_document_page_kanban_boxes"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
class="o_document_page_kanban_box"
|
||||||
|
name="%(action_browse_all_content)d"
|
||||||
|
type="action"
|
||||||
|
>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -161,15 +208,30 @@
|
|||||||
<field name="model">document.page</field>
|
<field name="model">document.page</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Document Category">
|
<search string="Document Category">
|
||||||
<field name="name" string="Content"
|
<field
|
||||||
filter_domain="['|', ('name','ilike',self), ('template','ilike',self)]"/>
|
name="name"
|
||||||
|
string="Content"
|
||||||
|
filter_domain="['|', ('name','ilike',self), ('template','ilike',self)]"
|
||||||
|
/>
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
<field name="create_uid" />
|
<field name="create_uid" />
|
||||||
<field name="content_uid" />
|
<field name="content_uid" />
|
||||||
<group expand="0" string="Group By...">
|
<group expand="0" string="Group By...">
|
||||||
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
|
<filter
|
||||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
|
name="group_by_category"
|
||||||
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
string="Category"
|
||||||
|
context="{'group_by':'parent_id'}"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="group_by_author"
|
||||||
|
string="Author"
|
||||||
|
context="{'group_by':'create_uid'}"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="group_by_last_contributor"
|
||||||
|
string="Last Contributor"
|
||||||
|
context="{'group_by':'content_uid'}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
@ -178,11 +240,15 @@
|
|||||||
<record id="view_browse_top_document_filter" model="ir.ui.view">
|
<record id="view_browse_top_document_filter" model="ir.ui.view">
|
||||||
<field name="name">document.page.category.search</field>
|
<field name="name">document.page.category.search</field>
|
||||||
<field name="model">document.page</field>
|
<field name="model">document.page</field>
|
||||||
<field name="inherit_id" ref="view_wiki_filter"></field>
|
<field name="inherit_id" ref="view_wiki_filter" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="content_uid" position="after">
|
<field name="content_uid" position="after">
|
||||||
<separator />
|
<separator />
|
||||||
<filter string="Top Level Ressources" name="no_parent_id" domain="[('parent_id', '=', False)]"/>
|
<filter
|
||||||
|
string="Top Level Ressources"
|
||||||
|
name="no_parent_id"
|
||||||
|
domain="[('parent_id', '=', False)]"
|
||||||
|
/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@ -225,8 +291,20 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_category" sequence="20" />
|
<menuitem
|
||||||
|
id="menu_category"
|
||||||
|
parent="menu_wiki"
|
||||||
|
name="Categories"
|
||||||
|
action="action_category"
|
||||||
|
sequence="20"
|
||||||
|
/>
|
||||||
|
|
||||||
<menuitem id="menu_browse_content" parent="knowledge.menu_document_root" name="Browse Wiki Content" action="action_browse_top_content" sequence="5" />
|
<menuitem
|
||||||
|
id="menu_browse_content"
|
||||||
|
parent="knowledge.menu_document_root"
|
||||||
|
name="Browse Wiki Content"
|
||||||
|
action="action_browse_top_content"
|
||||||
|
sequence="5"
|
||||||
|
/>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
36
document_page/views/document_page_history.xml
Executable file → Normal file
@ -27,7 +27,11 @@
|
|||||||
<field name="content" required="True" />
|
<field name="content" required="True" />
|
||||||
<field name="create_uid" />
|
<field name="create_uid" />
|
||||||
<group expand="0" string="Group By...">
|
<group expand="0" string="Group By...">
|
||||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}" />
|
<filter
|
||||||
|
name="group_by_author"
|
||||||
|
string="Author"
|
||||||
|
context="{'group_by':'create_uid'}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
@ -49,14 +53,26 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="name" placeholder="Rev 01" />
|
<field name="name" placeholder="Rev 01" />
|
||||||
<field name="summary" placeholder="eg: Changed ... for ..."/>
|
<field
|
||||||
|
name="summary"
|
||||||
|
placeholder="eg: Changed ... for ..."
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="content" string="Content">
|
<page name="content" string="Content">
|
||||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
|
<field
|
||||||
|
name="content"
|
||||||
|
widget="html"
|
||||||
|
placeholder="e.g. Once upon a time..."
|
||||||
|
options="{'safe': True}"
|
||||||
|
/>
|
||||||
</page>
|
</page>
|
||||||
<page name="diff" string="Changes">
|
<page name="diff" string="Changes">
|
||||||
<field name="diff" widget="html" style="overflow-x: scroll" />
|
<field
|
||||||
|
name="diff"
|
||||||
|
widget="html"
|
||||||
|
style="overflow-x: scroll"
|
||||||
|
/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
@ -72,19 +88,23 @@
|
|||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_page_history"
|
<menuitem
|
||||||
|
id="menu_page_history"
|
||||||
parent="menu_wiki"
|
parent="menu_wiki"
|
||||||
name="Pages history"
|
name="Pages history"
|
||||||
action="action_history"
|
action="action_history"
|
||||||
sequence="30"
|
sequence="30"
|
||||||
groups="base.group_no_one" />
|
groups="base.group_no_one"
|
||||||
|
/>
|
||||||
|
|
||||||
<act_window id="action_related_page_history"
|
<act_window
|
||||||
|
id="action_related_page_history"
|
||||||
context="{'search_default_page_id': [active_id], 'default_page_id': active_id}"
|
context="{'search_default_page_id': [active_id], 'default_page_id': active_id}"
|
||||||
domain="[('page_id','=',active_id)]"
|
domain="[('page_id','=',active_id)]"
|
||||||
name="Page History"
|
name="Page History"
|
||||||
res_model="document.page.history"
|
res_model="document.page.history"
|
||||||
src_model="document.page"/>
|
src_model="document.page"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
0
document_page/views/report_document_page.xml
Executable file → Normal file
@ -10,65 +10,63 @@ class DocumentPageCreateMenu(models.TransientModel):
|
|||||||
_name = "document.page.create.menu"
|
_name = "document.page.create.menu"
|
||||||
_description = "Wizard Create Menu"
|
_description = "Wizard Create Menu"
|
||||||
|
|
||||||
menu_name = fields.Char(
|
menu_name = fields.Char("Menu Name", required=True)
|
||||||
'Menu Name',
|
|
||||||
required=True
|
|
||||||
)
|
|
||||||
menu_parent_id = fields.Many2one(
|
menu_parent_id = fields.Many2one(
|
||||||
'ir.ui.menu',
|
comodel_name="ir.ui.menu", string="Parent Menu", required=True
|
||||||
'Parent Menu',
|
|
||||||
required=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
def default_get(self, fields_list):
|
||||||
"""Get Page name of the menu."""
|
"""Get Page name of the menu."""
|
||||||
res = super(DocumentPageCreateMenu, self).default_get(fields_list)
|
res = super(DocumentPageCreateMenu, self).default_get(fields_list)
|
||||||
page_id = self.env.context.get('active_id')
|
page_id = self.env.context.get("active_id")
|
||||||
obj_page = self.env['document.page']
|
obj_page = self.env["document.page"]
|
||||||
page = obj_page.browse(page_id)
|
page = obj_page.browse(page_id)
|
||||||
res['menu_name'] = page.name
|
res["menu_name"] = page.name
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def document_page_menu_create(self):
|
def document_page_menu_create(self):
|
||||||
"""Menu creation."""
|
"""Menu creation."""
|
||||||
obj_page = self.env['document.page']
|
obj_page = self.env["document.page"]
|
||||||
obj_menu = self.env['ir.ui.menu']
|
obj_menu = self.env["ir.ui.menu"]
|
||||||
obj_action = self.env['ir.actions.act_window']
|
obj_action = self.env["ir.actions.act_window"]
|
||||||
obj_model_data = self.env['ir.model.data']
|
obj_model_data = self.env["ir.model.data"]
|
||||||
page_id = self.env.context.get('active_id', False)
|
page_id = self.env.context.get("active_id", False)
|
||||||
page = obj_page.browse(page_id)
|
page = obj_page.browse(page_id)
|
||||||
|
|
||||||
data = self[0]
|
data = self[0]
|
||||||
view_id = obj_model_data.sudo().get_object_reference(
|
view_id = obj_model_data.sudo().get_object_reference(
|
||||||
'document_page', 'view_wiki_menu_form')[1]
|
"document_page", "view_wiki_menu_form"
|
||||||
|
)[1]
|
||||||
value = {
|
value = {
|
||||||
'name': 'Document Page',
|
"name": "Document Page",
|
||||||
'view_type': 'form',
|
"view_type": "form",
|
||||||
'view_mode': 'form,tree',
|
"view_mode": "form,tree",
|
||||||
'res_model': 'document.page',
|
"res_model": "document.page",
|
||||||
'view_id': view_id,
|
"view_id": view_id,
|
||||||
'type': 'ir.actions.act_window',
|
"type": "ir.actions.act_window",
|
||||||
'target': 'current',
|
"target": "current",
|
||||||
}
|
}
|
||||||
value['domain'] = "[('parent_id','=',%d)]" % page.id
|
value["domain"] = "[('parent_id','=',%d)]" % page.id
|
||||||
value['res_id'] = page.id
|
value["res_id"] = page.id
|
||||||
|
|
||||||
# only the super user is allowed to create menu due to security rules
|
# only the super user is allowed to create menu due to security rules
|
||||||
# on ir.values
|
# on ir.values
|
||||||
# see.: http://goo.gl/Y99S7V
|
# see.: http://goo.gl/Y99S7V
|
||||||
action_id = obj_action.sudo().create(value)
|
action_id = obj_action.sudo().create(value)
|
||||||
|
|
||||||
menu_id = obj_menu.sudo().create({
|
menu_id = obj_menu.sudo().create(
|
||||||
'name': data.menu_name,
|
{
|
||||||
'parent_id': data.menu_parent_id.id,
|
"name": data.menu_name,
|
||||||
'action': 'ir.actions.act_window,' + str(action_id.id),
|
"parent_id": data.menu_parent_id.id,
|
||||||
})
|
"action": "ir.actions.act_window," + str(action_id.id),
|
||||||
|
}
|
||||||
|
)
|
||||||
if page.menu_id:
|
if page.menu_id:
|
||||||
page.menu_id.unlink()
|
page.menu_id.unlink()
|
||||||
page.write({'menu_id': menu_id.id})
|
page.write({"menu_id": menu_id.id})
|
||||||
return {
|
return {
|
||||||
'type': 'ir.actions.client',
|
"type": "ir.actions.client",
|
||||||
'tag': 'reload',
|
"tag": "reload",
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
<field name="menu_parent_id" />
|
<field name="menu_parent_id" />
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="document_page_menu_create"
|
<button
|
||||||
|
name="document_page_menu_create"
|
||||||
string="Create Menu"
|
string="Create Menu"
|
||||||
type="object"
|
type="object"
|
||||||
class="oe_highlight" />
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
or
|
or
|
||||||
<button string="Cancel"
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
class="oe_link"
|
|
||||||
special="cancel" />
|
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
@ -32,8 +32,10 @@
|
|||||||
<field name="res_model">document.page.create.menu</field>
|
<field name="res_model">document.page.create.menu</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="binding_model_id"
|
<field
|
||||||
ref="document_page.model_document_page"/>
|
name="binding_model_id"
|
||||||
|
ref="document_page.model_document_page"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -9,13 +9,13 @@ from odoo.tools.translate import _
|
|||||||
class DocumentPageShowDiff(models.TransientModel):
|
class DocumentPageShowDiff(models.TransientModel):
|
||||||
"""Display Difference for History."""
|
"""Display Difference for History."""
|
||||||
|
|
||||||
_name = 'wizard.document.page.history.show_diff'
|
_name = "wizard.document.page.history.show_diff"
|
||||||
_description = 'Document Page Show Diff'
|
_description = "Document Page Show Diff"
|
||||||
|
|
||||||
def _get_diff(self):
|
def _get_diff(self):
|
||||||
"""Return the Difference between two document."""
|
"""Return the Difference between two document."""
|
||||||
history = self.env["document.page.history"]
|
history = self.env["document.page.history"]
|
||||||
ids = self.env.context.get('active_ids', [])
|
ids = self.env.context.get("active_ids", [])
|
||||||
diff = False
|
diff = False
|
||||||
if len(ids) == 2:
|
if len(ids) == 2:
|
||||||
if ids[0] > ids[1]:
|
if ids[0] > ids[1]:
|
||||||
@ -25,11 +25,7 @@ class DocumentPageShowDiff(models.TransientModel):
|
|||||||
elif len(ids) == 1:
|
elif len(ids) == 1:
|
||||||
diff = history.browse(ids[0]).diff
|
diff = history.browse(ids[0]).diff
|
||||||
else:
|
else:
|
||||||
raise UserError(
|
raise UserError(_("Select one or maximum two history revisions!"))
|
||||||
_("Select one or maximum two history revisions!"))
|
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
diff = fields.Text(
|
diff = fields.Text(readonly=True, default=_get_diff,)
|
||||||
readonly=True,
|
|
||||||
default=_get_diff,
|
|
||||||
)
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
src_model="document.page.history"
|
src_model="document.page.history"
|
||||||
view_mode="form"
|
view_mode="form"
|
||||||
target="new"
|
target="new"
|
||||||
view_type="form"/>
|
view_type="form"
|
||||||
|
/>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|