[chore] update pre-commits
This commit is contained in:
parent
bcedb0b897
commit
2491d1b315
55 changed files with 728 additions and 378 deletions
350
.eslintrc.yml
350
.eslintrc.yml
|
|
@ -1,188 +1,188 @@
|
||||||
env:
|
env:
|
||||||
browser: true
|
browser: true
|
||||||
es6: true
|
es6: true
|
||||||
|
|
||||||
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
|
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
|
||||||
parserOptions:
|
parserOptions:
|
||||||
ecmaVersion: 2019
|
ecmaVersion: 2019
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
- files:
|
- files:
|
||||||
- "**/*.esm.js"
|
- "**/*.esm.js"
|
||||||
parserOptions:
|
parserOptions:
|
||||||
sourceType: module
|
sourceType: module
|
||||||
|
|
||||||
# Globals available in Odoo that shouldn't produce errorings
|
# Globals available in Odoo that shouldn't produce errorings
|
||||||
globals:
|
globals:
|
||||||
_: readonly
|
_: readonly
|
||||||
$: readonly
|
$: readonly
|
||||||
fuzzy: readonly
|
fuzzy: readonly
|
||||||
jQuery: readonly
|
jQuery: readonly
|
||||||
moment: readonly
|
moment: readonly
|
||||||
odoo: readonly
|
odoo: readonly
|
||||||
openerp: readonly
|
openerp: readonly
|
||||||
owl: readonly
|
owl: readonly
|
||||||
luxon: readonly
|
luxon: readonly
|
||||||
|
|
||||||
# Styling is handled by Prettier, so we only need to enable AST rules;
|
# 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
|
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
|
||||||
rules:
|
rules:
|
||||||
accessor-pairs: warn
|
accessor-pairs: warn
|
||||||
array-callback-return: warn
|
array-callback-return: warn
|
||||||
callback-return: warn
|
callback-return: warn
|
||||||
capitalized-comments:
|
capitalized-comments:
|
||||||
- warn
|
- warn
|
||||||
- always
|
- always
|
||||||
- ignoreConsecutiveComments: true
|
- ignoreConsecutiveComments: true
|
||||||
ignoreInlineComments: true
|
ignoreInlineComments: true
|
||||||
complexity:
|
complexity:
|
||||||
- warn
|
- warn
|
||||||
- 15
|
- 15
|
||||||
constructor-super: warn
|
constructor-super: warn
|
||||||
dot-notation: warn
|
dot-notation: warn
|
||||||
eqeqeq: warn
|
eqeqeq: warn
|
||||||
global-require: warn
|
global-require: warn
|
||||||
handle-callback-err: warn
|
handle-callback-err: warn
|
||||||
id-blacklist: warn
|
id-blacklist: warn
|
||||||
id-match: warn
|
id-match: warn
|
||||||
init-declarations: error
|
init-declarations: error
|
||||||
max-depth: warn
|
max-depth: warn
|
||||||
max-nested-callbacks: warn
|
max-nested-callbacks: warn
|
||||||
max-statements-per-line: warn
|
max-statements-per-line: warn
|
||||||
no-alert: warn
|
no-alert: warn
|
||||||
no-array-constructor: warn
|
no-array-constructor: warn
|
||||||
no-caller: warn
|
no-caller: warn
|
||||||
no-case-declarations: warn
|
no-case-declarations: warn
|
||||||
no-class-assign: warn
|
no-class-assign: warn
|
||||||
no-cond-assign: error
|
no-cond-assign: error
|
||||||
no-const-assign: error
|
no-const-assign: error
|
||||||
no-constant-condition: warn
|
no-constant-condition: warn
|
||||||
no-control-regex: warn
|
no-control-regex: warn
|
||||||
no-debugger: error
|
no-debugger: error
|
||||||
no-delete-var: warn
|
no-delete-var: warn
|
||||||
no-div-regex: warn
|
no-div-regex: warn
|
||||||
no-dupe-args: error
|
no-dupe-args: error
|
||||||
no-dupe-class-members: error
|
no-dupe-class-members: error
|
||||||
no-dupe-keys: error
|
no-dupe-keys: error
|
||||||
no-duplicate-case: error
|
no-duplicate-case: error
|
||||||
no-duplicate-imports: error
|
no-duplicate-imports: error
|
||||||
no-else-return: warn
|
no-else-return: warn
|
||||||
no-empty-character-class: warn
|
no-empty-character-class: warn
|
||||||
no-empty-function: error
|
no-empty-function: error
|
||||||
no-empty-pattern: error
|
no-empty-pattern: error
|
||||||
no-empty: warn
|
no-empty: warn
|
||||||
no-eq-null: error
|
no-eq-null: error
|
||||||
no-eval: error
|
no-eval: error
|
||||||
no-ex-assign: error
|
no-ex-assign: error
|
||||||
no-extend-native: warn
|
no-extend-native: warn
|
||||||
no-extra-bind: warn
|
no-extra-bind: warn
|
||||||
no-extra-boolean-cast: warn
|
no-extra-boolean-cast: warn
|
||||||
no-extra-label: warn
|
no-extra-label: warn
|
||||||
no-fallthrough: warn
|
no-fallthrough: warn
|
||||||
no-func-assign: error
|
no-func-assign: error
|
||||||
no-global-assign: error
|
no-global-assign: error
|
||||||
no-implicit-coercion:
|
no-implicit-coercion:
|
||||||
- warn
|
- warn
|
||||||
- allow: ["~"]
|
- allow: ["~"]
|
||||||
no-implicit-globals: warn
|
no-implicit-globals: warn
|
||||||
no-implied-eval: warn
|
no-implied-eval: warn
|
||||||
no-inline-comments: warn
|
no-inline-comments: warn
|
||||||
no-inner-declarations: warn
|
no-inner-declarations: warn
|
||||||
no-invalid-regexp: warn
|
no-invalid-regexp: warn
|
||||||
no-irregular-whitespace: warn
|
no-irregular-whitespace: warn
|
||||||
no-iterator: warn
|
no-iterator: warn
|
||||||
no-label-var: warn
|
no-label-var: warn
|
||||||
no-labels: warn
|
no-labels: warn
|
||||||
no-lone-blocks: warn
|
no-lone-blocks: warn
|
||||||
no-lonely-if: error
|
no-lonely-if: error
|
||||||
no-mixed-requires: error
|
no-mixed-requires: error
|
||||||
no-multi-str: warn
|
no-multi-str: warn
|
||||||
no-native-reassign: error
|
no-native-reassign: error
|
||||||
no-negated-condition: warn
|
no-negated-condition: warn
|
||||||
no-negated-in-lhs: error
|
no-negated-in-lhs: error
|
||||||
no-new-func: warn
|
no-new-func: warn
|
||||||
no-new-object: warn
|
no-new-object: warn
|
||||||
no-new-require: warn
|
no-new-require: warn
|
||||||
no-new-symbol: warn
|
no-new-symbol: warn
|
||||||
no-new-wrappers: warn
|
no-new-wrappers: warn
|
||||||
no-new: warn
|
no-new: warn
|
||||||
no-obj-calls: warn
|
no-obj-calls: warn
|
||||||
no-octal-escape: warn
|
no-octal-escape: warn
|
||||||
no-octal: warn
|
no-octal: warn
|
||||||
no-param-reassign: warn
|
no-param-reassign: warn
|
||||||
no-path-concat: warn
|
no-path-concat: warn
|
||||||
no-process-env: warn
|
no-process-env: warn
|
||||||
no-process-exit: warn
|
no-process-exit: warn
|
||||||
no-proto: warn
|
no-proto: warn
|
||||||
no-prototype-builtins: warn
|
no-prototype-builtins: warn
|
||||||
no-redeclare: warn
|
no-redeclare: warn
|
||||||
no-regex-spaces: warn
|
no-regex-spaces: warn
|
||||||
no-restricted-globals: warn
|
no-restricted-globals: warn
|
||||||
no-restricted-imports: warn
|
no-restricted-imports: warn
|
||||||
no-restricted-modules: warn
|
no-restricted-modules: warn
|
||||||
no-restricted-syntax: warn
|
no-restricted-syntax: warn
|
||||||
no-return-assign: error
|
no-return-assign: error
|
||||||
no-script-url: warn
|
no-script-url: warn
|
||||||
no-self-assign: warn
|
no-self-assign: warn
|
||||||
no-self-compare: warn
|
no-self-compare: warn
|
||||||
no-sequences: warn
|
no-sequences: warn
|
||||||
no-shadow-restricted-names: warn
|
no-shadow-restricted-names: warn
|
||||||
# no-shadow: warn
|
# no-shadow: warn
|
||||||
no-sparse-arrays: warn
|
no-sparse-arrays: warn
|
||||||
no-sync: warn
|
no-sync: warn
|
||||||
no-this-before-super: warn
|
no-this-before-super: warn
|
||||||
no-throw-literal: warn
|
no-throw-literal: warn
|
||||||
no-undef-init: warn
|
no-undef-init: warn
|
||||||
no-undef: error
|
no-undef: error
|
||||||
no-unmodified-loop-condition: warn
|
no-unmodified-loop-condition: warn
|
||||||
no-unneeded-ternary: error
|
no-unneeded-ternary: error
|
||||||
no-unreachable: error
|
no-unreachable: error
|
||||||
no-unsafe-finally: error
|
no-unsafe-finally: error
|
||||||
no-unused-expressions: error
|
no-unused-expressions: error
|
||||||
no-unused-labels: error
|
no-unused-labels: error
|
||||||
no-unused-vars: error
|
no-unused-vars: error
|
||||||
no-use-before-define: error
|
no-use-before-define: error
|
||||||
no-useless-call: warn
|
no-useless-call: warn
|
||||||
no-useless-computed-key: warn
|
no-useless-computed-key: warn
|
||||||
no-useless-concat: warn
|
no-useless-concat: warn
|
||||||
no-useless-constructor: warn
|
no-useless-constructor: warn
|
||||||
no-useless-escape: warn
|
no-useless-escape: warn
|
||||||
no-useless-rename: warn
|
no-useless-rename: warn
|
||||||
no-void: warn
|
no-void: warn
|
||||||
no-with: warn
|
no-with: warn
|
||||||
operator-assignment: [error, always]
|
operator-assignment: [error, always]
|
||||||
prefer-const: warn
|
prefer-const: warn
|
||||||
radix: warn
|
radix: warn
|
||||||
require-yield: warn
|
require-yield: warn
|
||||||
sort-imports: warn
|
sort-imports: warn
|
||||||
spaced-comment: [error, always]
|
spaced-comment: [error, always]
|
||||||
strict: [error, function]
|
strict: [error, function]
|
||||||
use-isnan: error
|
use-isnan: error
|
||||||
valid-jsdoc:
|
valid-jsdoc:
|
||||||
- warn
|
- warn
|
||||||
- prefer:
|
- prefer:
|
||||||
arg: param
|
arg: param
|
||||||
argument: param
|
argument: param
|
||||||
augments: extends
|
augments: extends
|
||||||
constructor: class
|
constructor: class
|
||||||
exception: throws
|
exception: throws
|
||||||
func: function
|
func: function
|
||||||
method: function
|
method: function
|
||||||
prop: property
|
prop: property
|
||||||
return: returns
|
return: returns
|
||||||
virtual: abstract
|
virtual: abstract
|
||||||
yield: yields
|
yield: yields
|
||||||
preferType:
|
preferType:
|
||||||
array: Array
|
array: Array
|
||||||
bool: Boolean
|
bool: Boolean
|
||||||
boolean: Boolean
|
boolean: Boolean
|
||||||
number: Number
|
number: Number
|
||||||
object: Object
|
object: Object
|
||||||
str: String
|
str: String
|
||||||
string: String
|
string: String
|
||||||
requireParamDescription: false
|
requireParamDescription: false
|
||||||
requireReturn: false
|
requireReturn: false
|
||||||
requireReturnDescription: false
|
requireReturnDescription: false
|
||||||
requireReturnType: false
|
requireReturnType: false
|
||||||
valid-typeof: warn
|
valid-typeof: warn
|
||||||
yoda: warn
|
yoda: warn
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ exclude: |
|
||||||
# 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
|
# We don't want to mess with tool-generated files
|
||||||
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
|
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^.pre-commit-config.yaml$|^eslint.config.cjs|^prettier.config.cjs|
|
||||||
# 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)
|
||||||
|
|
@ -17,13 +17,10 @@ exclude: |
|
||||||
readme/.*\.(rst|md)$|
|
readme/.*\.(rst|md)$|
|
||||||
# Ignore build and dist directories in addons
|
# Ignore build and dist directories in addons
|
||||||
/build/|/dist/|
|
/build/|/dist/|
|
||||||
|
# Ignore test files in addons
|
||||||
|
/tests/samples/.*|
|
||||||
# You don't usually want a bot to modify your legal texts
|
# You don't usually want a bot to modify your legal texts
|
||||||
(LICENSE.*|COPYING.*)|
|
(LICENSE.*|COPYING.*)
|
||||||
# exclude configs itself
|
|
||||||
^\.eslintrc\.yml$|
|
|
||||||
^\.pre-commit-config\.yaml$|
|
|
||||||
# Exclude util.py
|
|
||||||
/migrations/util.py$
|
|
||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3
|
python: python3
|
||||||
node: "16.17.0"
|
node: "16.17.0"
|
||||||
|
|
@ -43,18 +40,19 @@ repos:
|
||||||
language: fail
|
language: fail
|
||||||
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
||||||
- repo: https://github.com/oca/maintainer-tools
|
- repo: https://github.com/oca/maintainer-tools
|
||||||
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
|
rev: d5fab7ee87fceee858a3d01048c78a548974d935
|
||||||
hooks:
|
hooks:
|
||||||
# update the NOT INSTALLABLE ADDONS section above
|
# update the NOT INSTALLABLE ADDONS section above
|
||||||
- id: oca-update-pre-commit-excluded-addons
|
- id: oca-update-pre-commit-excluded-addons
|
||||||
- id: oca-fix-manifest-website
|
- id: oca-fix-manifest-website
|
||||||
args: ["https://www.bakeup.org"]
|
args:
|
||||||
|
- https://www.bakeup.org
|
||||||
- id: oca-gen-addon-readme
|
- id: oca-gen-addon-readme
|
||||||
args:
|
args:
|
||||||
- --addons-dir=.
|
- --addons-dir=.
|
||||||
- --branch=16.0
|
- --branch=16.0
|
||||||
- --org-name=bruecksen
|
- --org-name=bruecksen
|
||||||
- --repo-name=ife_nfu
|
- --repo-name=nfu
|
||||||
- --if-source-changed
|
- --if-source-changed
|
||||||
- --keep-source-digest
|
- --keep-source-digest
|
||||||
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
||||||
|
|
@ -62,6 +60,8 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: oca-checks-odoo-module
|
- id: oca-checks-odoo-module
|
||||||
- id: oca-checks-po
|
- id: oca-checks-po
|
||||||
|
args:
|
||||||
|
- --disable=po-pretty-format
|
||||||
- repo: https://github.com/myint/autoflake
|
- repo: https://github.com/myint/autoflake
|
||||||
rev: v1.6.1
|
rev: v1.6.1
|
||||||
hooks:
|
hooks:
|
||||||
|
|
@ -77,30 +77,37 @@ repos:
|
||||||
rev: 22.8.0
|
rev: 22.8.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args:
|
- repo: local
|
||||||
- --line-length=120
|
|
||||||
- --skip-magic-trailing-comma
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
||||||
rev: v2.7.1
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
name: prettier (with plugin-xml)
|
name: prettier (with plugin-xml)
|
||||||
|
entry: prettier
|
||||||
|
args:
|
||||||
|
- --write
|
||||||
|
- --list-different
|
||||||
|
- --ignore-unknown
|
||||||
|
types: [text]
|
||||||
|
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
||||||
|
language: node
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- "prettier@2.7.1"
|
- "prettier@2.7.1"
|
||||||
- "@prettier/plugin-xml@2.2.0"
|
- "@prettier/plugin-xml@2.2.0"
|
||||||
args:
|
- repo: local
|
||||||
- --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
|
|
||||||
rev: v8.31.0
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: eslint
|
- id: eslint
|
||||||
verbose: true
|
name: eslint
|
||||||
|
entry: eslint
|
||||||
args:
|
args:
|
||||||
- --color
|
- --color
|
||||||
- --fix
|
- --fix
|
||||||
|
verbose: true
|
||||||
|
types: [javascript]
|
||||||
|
language: node
|
||||||
|
additional_dependencies:
|
||||||
|
- "eslint@8.24.0"
|
||||||
|
- "eslint-plugin-jsdoc@"
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.3.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
# exclude autogenerated files
|
# exclude autogenerated files
|
||||||
|
|
@ -134,8 +141,18 @@ repos:
|
||||||
args:
|
args:
|
||||||
- --settings=.
|
- --settings=.
|
||||||
exclude: /__init__\.py$
|
exclude: /__init__\.py$
|
||||||
|
- repo: https://github.com/acsone/setuptools-odoo
|
||||||
|
rev: 3.1.8
|
||||||
|
hooks:
|
||||||
|
- id: setuptools-odoo-make-default
|
||||||
|
- id: setuptools-odoo-get-requirements
|
||||||
|
args:
|
||||||
|
- --output
|
||||||
|
- requirements.txt
|
||||||
|
- --header
|
||||||
|
- "# generated from manifests external_dependencies"
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.9.2
|
rev: 5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
name: flake8
|
name: flake8
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU eCommerce
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_ecommerce
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -48,10 +48,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_ecommerce%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_ecommerce%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -72,6 +72,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_ecommerce>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,30 @@ class WebsiteSaleMinMax(WebsiteSale):
|
||||||
"""Override to get ordered_qty and max_qty from the product."""
|
"""Override to get ordered_qty and max_qty from the product."""
|
||||||
product_uom_ordered_qty = fields.Float(ordered_qty)
|
product_uom_ordered_qty = fields.Float(ordered_qty)
|
||||||
product_uom_max_qty = fields.Float(max_qty)
|
product_uom_max_qty = fields.Float(max_qty)
|
||||||
return super().cart_update(*args, ordered_qty=product_uom_ordered_qty, max_qty=product_uom_max_qty, **kw)
|
return super().cart_update(
|
||||||
|
*args,
|
||||||
|
ordered_qty=product_uom_ordered_qty,
|
||||||
|
max_qty=product_uom_max_qty,
|
||||||
|
**kw
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class WebsiteSale(WebsiteSale):
|
class WebsiteSale(WebsiteSale):
|
||||||
def _get_additional_shop_values(self, values):
|
def _get_additional_shop_values(self, values):
|
||||||
new_values = super()._get_additional_shop_values(values)
|
new_values = super()._get_additional_shop_values(values)
|
||||||
new_values["open_packagings"] = True if request.httprequest.args.get("open_packagings") else False
|
new_values["open_packagings"] = (
|
||||||
|
True if request.httprequest.args.get("open_packagings") else False
|
||||||
|
)
|
||||||
# ToDo: Add batch qtys if open batch
|
# ToDo: Add batch qtys if open batch
|
||||||
batch = request.website.sale_get_order(force_create=True).batch_id
|
batch = request.website.sale_get_order(force_create=True).batch_id
|
||||||
batch_products = batch.product_ids.filtered(lambda p: p.product_packaging_id)
|
batch_products = batch.product_ids.filtered(lambda p: p.product_packaging_id)
|
||||||
packaging_info = {}
|
packaging_info = {}
|
||||||
for product in values.get("products").sudo().filtered(lambda p: p.packaging_ids):
|
for product in (
|
||||||
batch_product = batch_products.filtered(lambda p: p.product_template_id == product)
|
values.get("products").sudo().filtered(lambda p: p.packaging_ids)
|
||||||
|
):
|
||||||
|
batch_product = batch_products.filtered(
|
||||||
|
lambda p: p.product_template_id == product
|
||||||
|
)
|
||||||
if batch_product:
|
if batch_product:
|
||||||
batch_product = batch_product[0]
|
batch_product = batch_product[0]
|
||||||
state_color = batch_product.get_state_color()
|
state_color = batch_product.get_state_color()
|
||||||
|
|
@ -36,11 +47,15 @@ class WebsiteSale(WebsiteSale):
|
||||||
"package_qty": batch_product.product_packaging_qty,
|
"package_qty": batch_product.product_packaging_qty,
|
||||||
}
|
}
|
||||||
new_values["packaging_info"] = packaging_info
|
new_values["packaging_info"] = packaging_info
|
||||||
new_values["get_product_packagings"] = lambda product: lazy(lambda: packaging_info.get(product.id, False))
|
new_values["get_product_packagings"] = lambda product: lazy(
|
||||||
|
lambda: packaging_info.get(product.id, False)
|
||||||
|
)
|
||||||
return new_values
|
return new_values
|
||||||
|
|
||||||
def _prepare_product_values(self, product, category, search, **kwargs):
|
def _prepare_product_values(self, product, category, search, **kwargs):
|
||||||
new_values = super()._prepare_product_values(product, category, search, **kwargs)
|
new_values = super()._prepare_product_values(
|
||||||
|
product, category, search, **kwargs
|
||||||
|
)
|
||||||
batch = request.website.sale_get_order(force_create=True).batch_id
|
batch = request.website.sale_get_order(force_create=True).batch_id
|
||||||
batch_product = batch.product_ids.filtered(
|
batch_product = batch.product_ids.filtered(
|
||||||
lambda p: p.product_template_id == product and p.product_packaging_id
|
lambda p: p.product_template_id == product and p.product_packaging_id
|
||||||
|
|
@ -59,7 +74,14 @@ class WebsiteSale(WebsiteSale):
|
||||||
return new_values
|
return new_values
|
||||||
|
|
||||||
def _get_search_options(
|
def _get_search_options(
|
||||||
self, category=None, attrib_values=None, pricelist=None, min_price=0.0, max_price=0.0, conversion_rate=1, **post
|
self,
|
||||||
|
category=None,
|
||||||
|
attrib_values=None,
|
||||||
|
pricelist=None,
|
||||||
|
min_price=0.0,
|
||||||
|
max_price=0.0,
|
||||||
|
conversion_rate=1,
|
||||||
|
**post
|
||||||
):
|
):
|
||||||
res = super()._get_search_options(
|
res = super()._get_search_options(
|
||||||
category=category,
|
category=category,
|
||||||
|
|
@ -84,18 +106,35 @@ class WebsiteSale(WebsiteSale):
|
||||||
auth="public",
|
auth="public",
|
||||||
website=True,
|
website=True,
|
||||||
)
|
)
|
||||||
def shop(self, page=0, category=None, search="", min_price=0.0, max_price=0.0, ppg=False, **post):
|
def shop(
|
||||||
|
self,
|
||||||
|
page=0,
|
||||||
|
category=None,
|
||||||
|
search="",
|
||||||
|
min_price=0.0,
|
||||||
|
max_price=0.0,
|
||||||
|
ppg=False,
|
||||||
|
**post
|
||||||
|
):
|
||||||
open_packages = bool(post.get("open_packagings"))
|
open_packages = bool(post.get("open_packagings"))
|
||||||
if open_packages:
|
if open_packages:
|
||||||
batch = request.website.sale_get_order(force_create=True).batch_id
|
batch = request.website.sale_get_order(force_create=True).batch_id
|
||||||
open_product_ids = (
|
open_product_ids = (
|
||||||
batch.product_ids.filtered(lambda p: p.open_packaging_qty > 0).mapped("product_template_id").ids
|
batch.product_ids.filtered(lambda p: p.open_packaging_qty > 0)
|
||||||
|
.mapped("product_template_id")
|
||||||
|
.ids
|
||||||
)
|
)
|
||||||
post["open_product_ids"] = open_product_ids
|
post["open_product_ids"] = open_product_ids
|
||||||
else:
|
else:
|
||||||
post["open_product_ids"] = None
|
post["open_product_ids"] = None
|
||||||
res = super().shop(
|
res = super().shop(
|
||||||
page=page, category=category, search=search, min_price=min_price, max_price=max_price, ppg=ppg, **post
|
page=page,
|
||||||
|
category=category,
|
||||||
|
search=search,
|
||||||
|
min_price=min_price,
|
||||||
|
max_price=max_price,
|
||||||
|
ppg=ppg,
|
||||||
|
**post
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ class ProductTemplate(models.Model):
|
||||||
_inherit = "product.template"
|
_inherit = "product.template"
|
||||||
|
|
||||||
is_published = fields.Boolean(
|
is_published = fields.Boolean(
|
||||||
copy=False, default=lambda self: self._default_is_published(), index=True, company_dependent=True
|
copy=False,
|
||||||
|
default=lambda self: self._default_is_published(),
|
||||||
|
index=True,
|
||||||
|
company_dependent=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def action_publish_on_website(self):
|
def action_publish_on_website(self):
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ class SaleOrder(models.Model):
|
||||||
@api.depends("amount_total")
|
@api.depends("amount_total")
|
||||||
def _compute_updated_balance(self):
|
def _compute_updated_balance(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
order.updated_balance = order.balance - (order.amount_total / order.currency_rate)
|
order.updated_balance = order.balance - (
|
||||||
|
order.amount_total / order.currency_rate
|
||||||
|
)
|
||||||
|
|
||||||
def _prepare_order_line_values(
|
def _prepare_order_line_values(
|
||||||
self,
|
self,
|
||||||
|
|
@ -33,10 +35,17 @@ class SaleOrder(models.Model):
|
||||||
product_custom_attribute_values=product_custom_attribute_values,
|
product_custom_attribute_values=product_custom_attribute_values,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
values.update({"product_uom_ordered_qty": quantity, "product_uom_max_qty": kwargs.get("max_qty", quantity)})
|
values.update(
|
||||||
|
{
|
||||||
|
"product_uom_ordered_qty": quantity,
|
||||||
|
"product_uom_max_qty": kwargs.get("max_qty", quantity),
|
||||||
|
}
|
||||||
|
)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def _prepare_order_line_update_values(self, order_line, quantity, linked_line_id=False, **kwargs):
|
def _prepare_order_line_update_values(
|
||||||
|
self, order_line, quantity, linked_line_id=False, **kwargs
|
||||||
|
):
|
||||||
values = super()._prepare_order_line_update_values(
|
values = super()._prepare_order_line_update_values(
|
||||||
order_line, quantity, linked_line_id=linked_line_id, **kwargs
|
order_line, quantity, linked_line_id=linked_line_id, **kwargs
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:4dfaea54e4d01502b433eb5c0dcca409a5fbe2c3f175e29382a19230343183c9
|
!! source digest: sha256:4dfaea54e4d01502b433eb5c0dcca409a5fbe2c3f175e29382a19230343183c9
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_ecommerce"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds a maximum order quantity field to Website Sale Orders. It also adds
|
<p>This module adds a maximum order quantity field to Website Sale Orders. It also adds
|
||||||
an ordered qantitiy field to store the original ordered quantity in case a manager
|
an ordered qantitiy field to store the original ordered quantity in case a manager
|
||||||
adjustes the uom quantitiy. In webshop checkout it adds the customer balance to before
|
adjustes the uom quantitiy. In webshop checkout it adds the customer balance to before
|
||||||
|
|
@ -416,10 +416,10 @@ and after the current order.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_ecommerce%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_ecommerce%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -439,7 +439,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_ecommerce">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU EKG Stock
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ekg_stock
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_ekg_stock
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -41,10 +41,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_ekg_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_ekg_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -59,6 +59,6 @@ Authors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ekg_stock>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_ekg_stock>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@
|
||||||
"views/report_packing_list.xml",
|
"views/report_packing_list.xml",
|
||||||
"report/stock_report_views.xml",
|
"report/stock_report_views.xml",
|
||||||
],
|
],
|
||||||
"assets": {"web.report_assets_common": ["nfu_ekg_stock/static/src/scss/report_stock_rule.scss"]},
|
"assets": {
|
||||||
|
"web.report_assets_common": [
|
||||||
|
"nfu_ekg_stock/static/src/scss/report_stock_rule.scss"
|
||||||
|
]
|
||||||
|
},
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"application": True,
|
"application": True,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:4dfaea54e4d01502b433eb5c0dcca409a5fbe2c3f175e29382a19230343183c9
|
!! source digest: sha256:4dfaea54e4d01502b433eb5c0dcca409a5fbe2c3f175e29382a19230343183c9
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ekg_stock"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_ekg_stock"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds EKG-specific stock c functionalities for the “Nachschub für uns”-Project
|
<p>This module adds EKG-specific stock c functionalities for the “Nachschub für uns”-Project
|
||||||
- small delivery slips</p>
|
- small delivery slips</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
|
|
@ -392,10 +392,10 @@ ul.auto-toc {
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_ekg_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_ekg_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -408,7 +408,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ekg_stock">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_ekg_stock">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU Product
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_product
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -40,10 +40,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -63,6 +63,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_product>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,18 @@ class ProductProduct(models.Model):
|
||||||
for product in self:
|
for product in self:
|
||||||
company_ids = vals.get("company_ids", [])[0][2]
|
company_ids = vals.get("company_ids", [])[0][2]
|
||||||
if company_ids:
|
if company_ids:
|
||||||
related_packages = self.env["product.packaging"].search([("product_id", "=", product.id)])
|
related_packages = self.env["product.packaging"].search(
|
||||||
|
[("product_id", "=", product.id)]
|
||||||
|
)
|
||||||
|
|
||||||
# First, set the company_ids on packages if not set
|
# First, set the company_ids on packages if not set
|
||||||
for package in related_packages:
|
for package in related_packages:
|
||||||
if not package.company_ids:
|
if not package.company_ids:
|
||||||
package.company_ids = product.company_ids
|
package.company_ids = product.company_ids
|
||||||
else:
|
else:
|
||||||
allowed_company_ids = list(set(package.company_ids.ids) & set(company_ids))
|
allowed_company_ids = list(
|
||||||
|
set(package.company_ids.ids) & set(company_ids)
|
||||||
|
)
|
||||||
if not allowed_company_ids:
|
if not allowed_company_ids:
|
||||||
package.company_ids = [(6, 0, company_ids)]
|
package.company_ids = [(6, 0, company_ids)]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:1b38428d6cd06a0605518e76e4c89cb55b01114d59a8a1ef38ebcc5129c57305
|
!! source digest: sha256:1b38428d6cd06a0605518e76e4c89cb55b01114d59a8a1ef38ebcc5129c57305
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_product"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Remove company_id and add company_ids to views</li>
|
<li>Remove company_id and add company_ids to views</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -396,10 +396,10 @@ ul.auto-toc {
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -418,7 +418,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_product">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU BNN Attributes
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product_bnn_attributes
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_product_bnn_attributes
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -43,10 +43,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_product_bnn_attributes%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_product_bnn_attributes%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -66,6 +66,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product_bnn_attributes>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_product_bnn_attributes>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ class ProductTemplate(models.Model):
|
||||||
for product in self:
|
for product in self:
|
||||||
qty = vals.get("packaging_qty") or product.packaging_qty
|
qty = vals.get("packaging_qty") or product.packaging_qty
|
||||||
name = vals.get("packaging_name") or product.packaging_name
|
name = vals.get("packaging_name") or product.packaging_name
|
||||||
product_products = self.env["product.product"].search([("product_tmpl_id", "=", product.id)])
|
product_products = self.env["product.product"].search(
|
||||||
|
[("product_tmpl_id", "=", product.id)]
|
||||||
|
)
|
||||||
if qty and name:
|
if qty and name:
|
||||||
for product_product in product_products:
|
for product_product in product_products:
|
||||||
packagings = self.env["product.packaging"].search(
|
packagings = self.env["product.packaging"].search(
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:134ea25670afe61406a31cb8ab2661c3b00137b759c76a3241a78d7e56d21ebe
|
!! source digest: sha256:134ea25670afe61406a31cb8ab2661c3b00137b759c76a3241a78d7e56d21ebe
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product_bnn_attributes"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_product_bnn_attributes"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds a page to product form view to store BNN Attributes.</p>
|
<p>This module adds a page to product form view to store BNN Attributes.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
|
|
@ -397,10 +397,10 @@ ul.auto-toc {
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_product_bnn_attributes%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_product_bnn_attributes%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -419,7 +419,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product_bnn_attributes">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_product_bnn_attributes">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU Sale Order Batch Packaging
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_sale_order_batch_packaging
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -52,10 +52,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_sale_order_batch_packaging%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_sale_order_batch_packaging%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -76,6 +76,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_sale_order_batch_packaging>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,39 @@
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
PACKAGING_STATES = [("open", "Open"), ("full", "Full"), ("last_open", "Last package open")]
|
PACKAGING_STATES = [
|
||||||
|
("open", "Open"),
|
||||||
|
("full", "Full"),
|
||||||
|
("last_open", "Last package open"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderBatchProduct(models.Model):
|
class SaleOrderBatchProduct(models.Model):
|
||||||
_inherit = "sale.order.batch.product"
|
_inherit = "sale.order.batch.product"
|
||||||
|
|
||||||
product_uom_max_qty = fields.Float(
|
product_uom_max_qty = fields.Float(
|
||||||
"Max Qty", compute="_compute_product_uom_max_qty", precompute=True, store=True, digits=[12, 3]
|
"Max Qty",
|
||||||
|
compute="_compute_product_uom_max_qty",
|
||||||
|
precompute=True,
|
||||||
|
store=True,
|
||||||
|
digits=[12, 3],
|
||||||
|
)
|
||||||
|
open_packaging_qty = fields.Float(
|
||||||
|
compute="_compute_open_packaging_qty", store=True, digits=[12, 3]
|
||||||
|
)
|
||||||
|
open_packaging_max_qty = fields.Float(
|
||||||
|
compute="_compute_open_packaging_max_qty", store=True, digits=[12, 3]
|
||||||
|
)
|
||||||
|
open_packaging_state = fields.Selection(
|
||||||
|
selection=PACKAGING_STATES, compute="_compute_open_packaging_state"
|
||||||
)
|
)
|
||||||
open_packaging_qty = fields.Float(compute="_compute_open_packaging_qty", store=True, digits=[12, 3])
|
|
||||||
open_packaging_max_qty = fields.Float(compute="_compute_open_packaging_max_qty", store=True, digits=[12, 3])
|
|
||||||
open_packaging_state = fields.Selection(selection=PACKAGING_STATES, compute="_compute_open_packaging_state")
|
|
||||||
|
|
||||||
@api.depends("sale_order_line_ids.product_uom_max_qty")
|
@api.depends("sale_order_line_ids.product_uom_max_qty")
|
||||||
def _compute_product_uom_max_qty(self):
|
def _compute_product_uom_max_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
product.product_uom_max_qty = sum(product.sale_order_line_ids.mapped("product_uom_max_qty"))
|
product.product_uom_max_qty = sum(
|
||||||
|
product.sale_order_line_ids.mapped("product_uom_max_qty")
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("product_uom_qty")
|
@api.depends("product_uom_qty")
|
||||||
def _compute_open_packaging_qty(self):
|
def _compute_open_packaging_qty(self):
|
||||||
|
|
@ -27,7 +43,9 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
product.product_uom_qty % product.product_packaging_qty, 3
|
product.product_uom_qty % product.product_packaging_qty, 3
|
||||||
)
|
)
|
||||||
product.open_packaging_qty = (
|
product.open_packaging_qty = (
|
||||||
0.0 if open_packaging_qty == product.product_packaging_qty else open_packaging_qty
|
0.0
|
||||||
|
if open_packaging_qty == product.product_packaging_qty
|
||||||
|
else open_packaging_qty
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
product.open_packaging_qty = 0.0
|
product.open_packaging_qty = 0.0
|
||||||
|
|
@ -36,9 +54,16 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
def _compute_open_packaging_max_qty(self):
|
def _compute_open_packaging_max_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
if product.product_packaging_id:
|
if product.product_packaging_id:
|
||||||
if product.product_uom_max_qty < product.product_uom_qty + product.open_packaging_qty:
|
if (
|
||||||
product.open_packaging_max_qty = product.product_packaging_qty - round(
|
product.product_uom_max_qty
|
||||||
product.product_uom_max_qty % product.product_packaging_qty, 3
|
< product.product_uom_qty + product.open_packaging_qty
|
||||||
|
):
|
||||||
|
product.open_packaging_max_qty = (
|
||||||
|
product.product_packaging_qty
|
||||||
|
- round(
|
||||||
|
product.product_uom_max_qty % product.product_packaging_qty,
|
||||||
|
3,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
product.open_packaging_max_qty = 0.0
|
product.open_packaging_max_qty = 0.0
|
||||||
|
|
@ -60,7 +85,9 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
||||||
packaging = (
|
packaging = (
|
||||||
self.env["product.product"].search([("id", "=", vals.get("product_id"))])._get_nfu_packaging()
|
self.env["product.product"]
|
||||||
|
.search([("id", "=", vals.get("product_id"))])
|
||||||
|
._get_nfu_packaging()
|
||||||
)
|
)
|
||||||
if packaging:
|
if packaging:
|
||||||
vals["product_packaging_id"] = packaging.id
|
vals["product_packaging_id"] = packaging.id
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,18 @@ from odoo.exceptions import UserError
|
||||||
class SaleOrderLine(models.Model):
|
class SaleOrderLine(models.Model):
|
||||||
_inherit = "sale.order.line"
|
_inherit = "sale.order.line"
|
||||||
|
|
||||||
product_uom_ordered_qty = fields.Float(string="Ordered Qty", digits="Product Unit of Measure", default=1.0)
|
product_uom_ordered_qty = fields.Float(
|
||||||
product_uom_max_qty = fields.Float(string="Max Qty", digits="Product Unit of Measure")
|
string="Ordered Qty", digits="Product Unit of Measure", default=1.0
|
||||||
batch_uom_qty = fields.Float(related="batch_product_id.product_uom_qty", string="Batch UOM Qty")
|
)
|
||||||
batch_uom_max_qty = fields.Float(related="batch_product_id.product_uom_max_qty", string="Batch UOM Max Qty")
|
product_uom_max_qty = fields.Float(
|
||||||
|
string="Max Qty", digits="Product Unit of Measure"
|
||||||
|
)
|
||||||
|
batch_uom_qty = fields.Float(
|
||||||
|
related="batch_product_id.product_uom_qty", string="Batch UOM Qty"
|
||||||
|
)
|
||||||
|
batch_uom_max_qty = fields.Float(
|
||||||
|
related="batch_product_id.product_uom_max_qty", string="Batch UOM Max Qty"
|
||||||
|
)
|
||||||
|
|
||||||
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
||||||
def _check_product_uom_qty(self):
|
def _check_product_uom_qty(self):
|
||||||
|
|
@ -16,7 +24,7 @@ class SaleOrderLine(models.Model):
|
||||||
if order_line.product_uom_qty > order_line.product_uom_max_qty:
|
if order_line.product_uom_qty > order_line.product_uom_max_qty:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_(
|
_(
|
||||||
f"{order_line.order_id.name},{order_line.product_id.name}:"
|
f"{order_line.order_id.name}, {order_line.product_id.name}: "
|
||||||
"The quantity must be less than or equal to the maximum quantity."
|
"The quantity must be less than or equal to the maximum quantity."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -24,12 +32,17 @@ class SaleOrderLine(models.Model):
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if not vals.get("product_uom_max_qty") or vals.get("product_uom_max_qty") == 0:
|
if (
|
||||||
|
not vals.get("product_uom_max_qty")
|
||||||
|
or vals.get("product_uom_max_qty") == 0
|
||||||
|
):
|
||||||
product_qty = vals.get("product_uom_qty")
|
product_qty = vals.get("product_uom_qty")
|
||||||
vals["product_uom_max_qty"] = product_qty
|
vals["product_uom_max_qty"] = product_qty
|
||||||
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
||||||
product_id = vals.get("product_id")
|
product_id = vals.get("product_id")
|
||||||
packaging = self.env["product.packaging"].search([("product_id", "=", product_id)], limit=1)
|
packaging = self.env["product.packaging"].search(
|
||||||
|
[("product_id", "=", product_id)], limit=1
|
||||||
|
)
|
||||||
vals["product_packaging_id"] = packaging.id
|
vals["product_packaging_id"] = packaging.id
|
||||||
return super().create(vals_list)
|
return super().create(vals_list)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:cf35c3a80aa0718148099036cd6a3dd60afb61acdb420573b1bd129be3ea2cf1
|
!! source digest: sha256:cf35c3a80aa0718148099036cd6a3dd60afb61acdb420573b1bd129be3ea2cf1
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_sale_order_batch_packaging"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds a minium and a maximum order quantity field to Sale Orders
|
<p>This module adds a minium and a maximum order quantity field to Sale Orders
|
||||||
and adds a packaging default to sale order batch.</p>
|
and adds a packaging default to sale order batch.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
|
|
@ -434,10 +434,10 @@ and adds a packaging default to sale order batch.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_sale_order_batch_packaging%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_sale_order_batch_packaging%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -457,7 +457,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_sale_order_batch_packaging">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ NFU Wholesaler Exporter
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_wholesaler_exporter
|
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_wholesaler_exporter
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -51,10 +51,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_wholesaler_exporter%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_wholesaler_exporter%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -74,6 +74,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_wholesaler_exporter>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/nfu_wholesaler_exporter>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,23 @@ class SaleOrderBatch(models.Model):
|
||||||
# Prepare CSV content
|
# Prepare CSV content
|
||||||
csv_content = "Artnr,Menge\n"
|
csv_content = "Artnr,Menge\n"
|
||||||
for product in self.product_ids.filtered(lambda p: p.product_id.default_code):
|
for product in self.product_ids.filtered(lambda p: p.product_id.default_code):
|
||||||
if not float_is_zero(product.product_uom_qty, precision_rounding=product.product_id.uom_id.rounding):
|
if not float_is_zero(
|
||||||
|
product.product_uom_qty,
|
||||||
|
precision_rounding=product.product_id.uom_id.rounding,
|
||||||
|
):
|
||||||
# We think 10g variance is okay
|
# We think 10g variance is okay
|
||||||
if not float_is_zero(product.open_packaging_qty, precision_rounding=0.01):
|
if not float_is_zero(
|
||||||
raise UserError(_(f"Packaging is still open for product {product.product_id.name}"))
|
product.open_packaging_qty, precision_rounding=0.01
|
||||||
wholesaler_qty = int(round(product.product_uom_qty / product.product_packaging_qty))
|
):
|
||||||
csv_content += f"{product.product_id.default_code},{wholesaler_qty}\n"
|
raise UserError(
|
||||||
|
_(
|
||||||
|
f"Packaging is still open for product {product.product_id.name}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
wholesaler_qty = int(
|
||||||
|
round(product.product_uom_qty / product.product_packaging_qty)
|
||||||
|
)
|
||||||
|
csv_content += f"{product.product_id.default_code},{wholesaler_qty}\n" # noqa: E231
|
||||||
|
|
||||||
# Encode CSV content to base64
|
# Encode CSV content to base64
|
||||||
csv_base64 = base64.b64encode(csv_content.encode("utf-8"))
|
csv_base64 = base64.b64encode(csv_content.encode("utf-8"))
|
||||||
|
|
@ -34,4 +45,8 @@ class SaleOrderBatch(models.Model):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"type": "ir.actions.act_url", "url": f"/web/content/{attachment.id}?download=true", "target": "self"}
|
return {
|
||||||
|
"type": "ir.actions.act_url",
|
||||||
|
"url": f"/web/content/{attachment.id}?download=true",
|
||||||
|
"target": "self",
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:f5c1fd3329fff4e1de63fae68edca9ba70a1f2444b6674d5fac9ede1a6ff1f94
|
!! source digest: sha256:f5c1fd3329fff4e1de63fae68edca9ba70a1f2444b6674d5fac9ede1a6ff1f94
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_wholesaler_exporter"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_wholesaler_exporter"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds a CSV exporter action to Sale Order Batch module.
|
<p>This module adds a CSV exporter action to Sale Order Batch module.
|
||||||
It exports the article number (default_code) and the qty of the Sale Order Batch
|
It exports the article number (default_code) and the qty of the Sale Order Batch
|
||||||
Product view.</p>
|
Product view.</p>
|
||||||
|
|
@ -420,10 +420,10 @@ Das ist aktuell der default_code, falls wir den mal prefixen, muss das hier ange
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20nfu_wholesaler_exporter%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20nfu_wholesaler_exporter%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -442,7 +442,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_wholesaler_exporter">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/nfu_wholesaler_exporter">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ Sale Order Batch
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch
|
:target: https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -48,10 +48,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -71,6 +71,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,12 @@ from odoo.exceptions import UserError
|
||||||
class SaleOrder(models.Model):
|
class SaleOrder(models.Model):
|
||||||
_inherit = "sale.order"
|
_inherit = "sale.order"
|
||||||
|
|
||||||
batch_id = fields.Many2one("sale.order.batch", copy=False, check_company=True, domain="[('state','!=','closed')]")
|
batch_id = fields.Many2one(
|
||||||
|
"sale.order.batch",
|
||||||
|
copy=False,
|
||||||
|
check_company=True,
|
||||||
|
domain="[('state','!=','closed')]",
|
||||||
|
)
|
||||||
|
|
||||||
def _get_current_batch(self):
|
def _get_current_batch(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -47,7 +52,9 @@ class SaleOrder(models.Model):
|
||||||
if order.batch_id:
|
if order.batch_id:
|
||||||
invalid_orders.append(order.name)
|
invalid_orders.append(order.name)
|
||||||
if invalid_orders:
|
if invalid_orders:
|
||||||
raise UserError(_(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}"))
|
raise UserError(
|
||||||
|
_(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}")
|
||||||
|
)
|
||||||
return super().action_confirm()
|
return super().action_confirm()
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,12 @@ from odoo import _, api, fields, models
|
||||||
from odoo.addons.sale.models.sale_order import INVOICE_STATUS
|
from odoo.addons.sale.models.sale_order import INVOICE_STATUS
|
||||||
|
|
||||||
|
|
||||||
STATES = [("open", "Open"), ("in_progress", "In Progress"), ("closed", "Closed"), ("cancel", "Cancelled")]
|
STATES = [
|
||||||
|
("open", "Open"),
|
||||||
|
("in_progress", "In Progress"),
|
||||||
|
("closed", "Closed"),
|
||||||
|
("cancel", "Cancelled"),
|
||||||
|
]
|
||||||
READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}}
|
READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,10 +30,19 @@ class SaleOrderBatch(models.Model):
|
||||||
default=lambda self: _("New"),
|
default=lambda self: _("New"),
|
||||||
)
|
)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name="res.company", required=True, index=True, default=lambda self: self.env.company
|
comodel_name="res.company",
|
||||||
|
required=True,
|
||||||
|
index=True,
|
||||||
|
default=lambda self: self.env.company,
|
||||||
)
|
)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
selection=STATES, string="Status", readonly=True, copy=False, index=True, tracking=1, default="open"
|
selection=STATES,
|
||||||
|
string="Status",
|
||||||
|
readonly=True,
|
||||||
|
copy=False,
|
||||||
|
index=True,
|
||||||
|
tracking=1,
|
||||||
|
default="open",
|
||||||
)
|
)
|
||||||
date_order = fields.Datetime(
|
date_order = fields.Datetime(
|
||||||
string="Order Date",
|
string="Order Date",
|
||||||
|
|
@ -41,10 +55,14 @@ class SaleOrderBatch(models.Model):
|
||||||
)
|
)
|
||||||
sale_order_ids = fields.One2many("sale.order", "batch_id")
|
sale_order_ids = fields.One2many("sale.order", "batch_id")
|
||||||
sale_order_count = fields.Integer(compute="_compute_sale_order_count")
|
sale_order_count = fields.Integer(compute="_compute_sale_order_count")
|
||||||
sale_order_line_ids = fields.One2many("sale.order.line", "batch_id", states=READONLY_FIELD_STATES)
|
sale_order_line_ids = fields.One2many(
|
||||||
|
"sale.order.line", "batch_id", states=READONLY_FIELD_STATES
|
||||||
|
)
|
||||||
invoice_ids = fields.Many2many("account.move", compute="_compute_invoice_ids")
|
invoice_ids = fields.Many2many("account.move", compute="_compute_invoice_ids")
|
||||||
invoice_count = fields.Integer(compute="_compute_invoice_ids")
|
invoice_count = fields.Integer(compute="_compute_invoice_ids")
|
||||||
invoice_status = fields.Selection(selection=INVOICE_STATUS, compute="_compute_invoice_status", store=True)
|
invoice_status = fields.Selection(
|
||||||
|
selection=INVOICE_STATUS, compute="_compute_invoice_status", store=True
|
||||||
|
)
|
||||||
amount_total = fields.Float(compute="_compute_amount_total", string="Total")
|
amount_total = fields.Float(compute="_compute_amount_total", string="Total")
|
||||||
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
||||||
product_count = fields.Integer(compute="_compute_product_count")
|
product_count = fields.Integer(compute="_compute_product_count")
|
||||||
|
|
@ -66,11 +84,13 @@ class SaleOrderBatch(models.Model):
|
||||||
def _compute_invoice_status(self):
|
def _compute_invoice_status(self):
|
||||||
for batch in self:
|
for batch in self:
|
||||||
if batch.sale_order_ids and any(
|
if batch.sale_order_ids and any(
|
||||||
invoice_status == "to invoice" for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
invoice_status == "to invoice"
|
||||||
|
for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
||||||
):
|
):
|
||||||
batch.invoice_status = "to invoice"
|
batch.invoice_status = "to invoice"
|
||||||
elif batch.sale_order_ids and all(
|
elif batch.sale_order_ids and all(
|
||||||
invoice_status == "invoiced" for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
invoice_status == "invoiced"
|
||||||
|
for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
||||||
):
|
):
|
||||||
batch.invoice_status = "invoiced"
|
batch.invoice_status = "invoiced"
|
||||||
elif batch.sale_order_ids and all(
|
elif batch.sale_order_ids and all(
|
||||||
|
|
@ -113,11 +133,15 @@ class SaleOrderBatch(models.Model):
|
||||||
|
|
||||||
def action_view_products(self):
|
def action_view_products(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
result = self.env["ir.actions.act_window"]._for_xml_id("product.product_normal_action_sell")
|
result = self.env["ir.actions.act_window"]._for_xml_id(
|
||||||
|
"product.product_normal_action_sell"
|
||||||
|
)
|
||||||
if len(self.product_ids) > 1:
|
if len(self.product_ids) > 1:
|
||||||
result["domain"] = [("id", "in", self.product_ids.ids)]
|
result["domain"] = [("id", "in", self.product_ids.ids)]
|
||||||
elif len(self.product_ids) == 1:
|
elif len(self.product_ids) == 1:
|
||||||
result["views"] = [(self.env.ref("product.product_product_tree_view", False).id, "form")]
|
result["views"] = [
|
||||||
|
(self.env.ref("product.product_product_tree_view", False).id, "form")
|
||||||
|
]
|
||||||
result["res_id"] = self.product_ids.id
|
result["res_id"] = self.product_ids.id
|
||||||
else:
|
else:
|
||||||
result = {"type": "ir.actions.act_window_close"}
|
result = {"type": "ir.actions.act_window_close"}
|
||||||
|
|
@ -125,13 +149,17 @@ class SaleOrderBatch(models.Model):
|
||||||
|
|
||||||
def action_view_invoice(self):
|
def action_view_invoice(self):
|
||||||
invoices = self.mapped("invoice_ids")
|
invoices = self.mapped("invoice_ids")
|
||||||
action = self.env["ir.actions.actions"]._for_xml_id("account.action_move_out_invoice_type")
|
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||||
|
"account.action_move_out_invoice_type"
|
||||||
|
)
|
||||||
if len(invoices) > 1:
|
if len(invoices) > 1:
|
||||||
action["domain"] = [("id", "in", invoices.ids)]
|
action["domain"] = [("id", "in", invoices.ids)]
|
||||||
elif len(invoices) == 1:
|
elif len(invoices) == 1:
|
||||||
form_view = [(self.env.ref("account.view_move_form").id, "form")]
|
form_view = [(self.env.ref("account.view_move_form").id, "form")]
|
||||||
if "views" in action:
|
if "views" in action:
|
||||||
action["views"] = form_view + [(state, view) for state, view in action["views"] if view != "form"]
|
action["views"] = form_view + [
|
||||||
|
(state, view) for state, view in action["views"] if view != "form"
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
action["views"] = form_view
|
action["views"] = form_view
|
||||||
action["res_id"] = invoices.id
|
action["res_id"] = invoices.id
|
||||||
|
|
@ -169,5 +197,7 @@ class SaleOrderBatch(models.Model):
|
||||||
if "company_id" in vals:
|
if "company_id" in vals:
|
||||||
self = self.with_company(vals["company_id"])
|
self = self.with_company(vals["company_id"])
|
||||||
if vals.get("name", _("New")) == _("New"):
|
if vals.get("name", _("New")) == _("New"):
|
||||||
vals["name"] = self.env["ir.sequence"].next_by_code("sale.order.batch") or _("New")
|
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||||
|
"sale.order.batch"
|
||||||
|
) or _("New")
|
||||||
return super().create(vals_list)
|
return super().create(vals_list)
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,26 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
state = fields.Selection(related="batch_id.state")
|
state = fields.Selection(related="batch_id.state")
|
||||||
product_id = fields.Many2one(comodel_name="product.product", required=True, readonly=True)
|
product_id = fields.Many2one(
|
||||||
product_template_id = fields.Many2one(
|
comodel_name="product.product", required=True, readonly=True
|
||||||
"product.template", related="product_id.product_tmpl_id", string="Product Template"
|
)
|
||||||
|
product_template_id = fields.Many2one(
|
||||||
|
"product.template",
|
||||||
|
related="product_id.product_tmpl_id",
|
||||||
|
string="Product Template",
|
||||||
|
)
|
||||||
|
sale_order_line_ids = fields.One2many(
|
||||||
|
"sale.order.line", "batch_product_id", states=READONLY_FIELD_STATES
|
||||||
|
)
|
||||||
|
product_uom_category_id = fields.Many2one(
|
||||||
|
related="product_id.uom_id.category_id", depends=["product_id"]
|
||||||
)
|
)
|
||||||
sale_order_line_ids = fields.One2many("sale.order.line", "batch_product_id", states=READONLY_FIELD_STATES)
|
|
||||||
product_uom_category_id = fields.Many2one(related="product_id.uom_id.category_id", depends=["product_id"])
|
|
||||||
product_uom_qty = fields.Float(
|
product_uom_qty = fields.Float(
|
||||||
string="Quantity", compute="_compute_uom_qty", precompute=True, store=True, digits=[12, 3]
|
string="Quantity",
|
||||||
|
compute="_compute_uom_qty",
|
||||||
|
precompute=True,
|
||||||
|
store=True,
|
||||||
|
digits=[12, 3],
|
||||||
)
|
)
|
||||||
product_uom = fields.Many2one(related="product_id.uom_id")
|
product_uom = fields.Many2one(related="product_id.uom_id")
|
||||||
lst_price = fields.Float(
|
lst_price = fields.Float(
|
||||||
|
|
@ -50,26 +62,42 @@ class SaleOrderBatchProduct(models.Model):
|
||||||
@api.constrains("product_id", "sale_order_line_ids")
|
@api.constrains("product_id", "sale_order_line_ids")
|
||||||
def _check_sale_order_line_products(self):
|
def _check_sale_order_line_products(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
if any(line.product_id != product.product_id for line in product.sale_order_line_ids):
|
if any(
|
||||||
|
line.product_id != product.product_id
|
||||||
|
for line in product.sale_order_line_ids
|
||||||
|
):
|
||||||
raise ValueError("Product must be the same for all Sale Order Lines")
|
raise ValueError("Product must be the same for all Sale Order Lines")
|
||||||
|
|
||||||
@api.depends("sale_order_line_ids.product_uom_qty")
|
@api.depends("sale_order_line_ids.product_uom_qty")
|
||||||
def _compute_uom_qty(self):
|
def _compute_uom_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
product.product_uom_qty = sum(product.sale_order_line_ids.mapped("product_uom_qty"))
|
product.product_uom_qty = sum(
|
||||||
|
product.sale_order_line_ids.mapped("product_uom_qty")
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("product_id", "product_uom_qty", "product_uom")
|
@api.depends("product_id", "product_uom_qty", "product_uom")
|
||||||
def _compute_product_packaging_id(self):
|
def _compute_product_packaging_id(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
# remove packaging if not match the product
|
# remove packaging if not match the product
|
||||||
if line.product_packaging_id and line.product_packaging_id.product_id != line.product_id:
|
if (
|
||||||
|
line.product_packaging_id
|
||||||
|
and line.product_packaging_id.product_id != line.product_id
|
||||||
|
):
|
||||||
line.product_packaging_id = False
|
line.product_packaging_id = False
|
||||||
# suggest always the first packaging
|
# suggest always the first packaging
|
||||||
if line.product_id and line.product_uom_qty and line.product_uom:
|
if line.product_id and line.product_uom_qty and line.product_uom:
|
||||||
suggested_packaging = line.product_id.packaging_ids[0] if line.product_id.packaging_ids else False
|
suggested_packaging = (
|
||||||
line.product_packaging_id = suggested_packaging or line.product_packaging_id
|
line.product_id.packaging_ids[0]
|
||||||
|
if line.product_id.packaging_ids
|
||||||
|
else False
|
||||||
|
)
|
||||||
|
line.product_packaging_id = (
|
||||||
|
suggested_packaging or line.product_packaging_id
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("product_packaging_id")
|
@api.depends("product_packaging_id")
|
||||||
def _compute_product_packaging_qty(self):
|
def _compute_product_packaging_qty(self):
|
||||||
for product in self:
|
for product in self:
|
||||||
product.product_packaging_qty = product.product_packaging_id.qty if product.product_packaging_id else 1
|
product.product_packaging_qty = (
|
||||||
|
product.product_packaging_id.qty if product.product_packaging_id else 1
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ class SaleOrderLine(models.Model):
|
||||||
for line in lines_with_batch:
|
for line in lines_with_batch:
|
||||||
batch_id = line.batch_id
|
batch_id = line.batch_id
|
||||||
batch_product = self.env["sale.order.batch.product"].search(
|
batch_product = self.env["sale.order.batch.product"].search(
|
||||||
[("product_id", "=", line.product_id.id), ("batch_id", "=", batch_id.id)], limit=1
|
[
|
||||||
|
("product_id", "=", line.product_id.id),
|
||||||
|
("batch_id", "=", batch_id.id),
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
)
|
)
|
||||||
if not batch_product:
|
if not batch_product:
|
||||||
batch_product = self.env["sale.order.batch.product"].create(
|
batch_product = self.env["sale.order.batch.product"].create(
|
||||||
|
|
@ -30,7 +34,8 @@ class SaleOrderLine(models.Model):
|
||||||
lines_with_batch = self.filtered(lambda l: l.batch_id)
|
lines_with_batch = self.filtered(lambda l: l.batch_id)
|
||||||
lines_without_batch = self - lines_with_batch
|
lines_without_batch = self - lines_with_batch
|
||||||
lines_with_batch.filtered(
|
lines_with_batch.filtered(
|
||||||
lambda l: l.batch_product_id and l.batch_product_id.product_id != l.product_id
|
lambda l: l.batch_product_id
|
||||||
|
and l.batch_product_id.product_id != l.product_id
|
||||||
)._unlink_batch_product()
|
)._unlink_batch_product()
|
||||||
lines_with_batch._link_batch_product()
|
lines_with_batch._link_batch_product()
|
||||||
lines_without_batch._unlink_batch_product()
|
lines_without_batch._unlink_batch_product()
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:6686f0672ede8093b17d5d7b165f72f8e49341c7849f9e0d5a162e350fc36d71
|
!! source digest: sha256:6686f0672ede8093b17d5d7b165f72f8e49341c7849f9e0d5a162e350fc36d71
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds the possibility to group Sale orders into batches. Attributes of a Sale Order Batch will be written to all
|
<p>This module adds the possibility to group Sale orders into batches. Attributes of a Sale Order Batch will be written to all
|
||||||
Sale Order. Wenn attached to a batch they can be processed together. On the other hand they cannot be proccesed individual
|
Sale Order. Wenn attached to a batch they can be processed together. On the other hand they cannot be proccesed individual
|
||||||
anymore as log as they are part of a batch. Only Sale Orders in state Qutotation or Quotation Send can be attached to a batch.</p>
|
anymore as log as they are part of a batch. Only Sale Orders in state Qutotation or Quotation Send can be attached to a batch.</p>
|
||||||
|
|
@ -417,10 +417,10 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20sale_order_batch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -439,7 +439,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ Sale Order Batch Stock Binding
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch_stock
|
:target: https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch_stock
|
||||||
:alt: bruecksen/ife_nfu
|
:alt: bruecksen/nfu
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
|
@ -37,10 +37,10 @@ Changelog
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/ife_nfu/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/bruecksen/nfu/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20sale_order_batch_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/bruecksen/nfu/issues/new?body=module:%20sale_order_batch_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
|
@ -60,6 +60,6 @@ Contributors
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `bruecksen/ife_nfu <https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch_stock>`_ project on GitHub.
|
This module is part of the `bruecksen/nfu <https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch_stock>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@ STATES = [("open", "Open"), ("close", "Close")]
|
||||||
class SaleOrderBatch(models.Model):
|
class SaleOrderBatch(models.Model):
|
||||||
_inherit = "sale.order.batch"
|
_inherit = "sale.order.batch"
|
||||||
|
|
||||||
picking_ids = fields.Many2many("stock.picking", compute="_compute_picking_ids", string="Transfers")
|
picking_ids = fields.Many2many(
|
||||||
delivery_count = fields.Integer(string="Delivery Orders", compute="_compute_picking_ids")
|
"stock.picking", compute="_compute_picking_ids", string="Transfers"
|
||||||
|
)
|
||||||
|
delivery_count = fields.Integer(
|
||||||
|
string="Delivery Orders", compute="_compute_picking_ids"
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("sale_order_ids.picking_ids")
|
@api.depends("sale_order_ids.picking_ids")
|
||||||
def _compute_picking_ids(self):
|
def _compute_picking_ids(self):
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:c32b4440b58e98f3bea5539d78dfa2916d64aebc757c140d78b67b2a2ce288da
|
!! source digest: sha256:c32b4440b58e98f3bea5539d78dfa2916d64aebc757c140d78b67b2a2ce288da
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch_stock"><img alt="bruecksen/ife_nfu" src="https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch_stock"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<p>This module adds Deliverys to Sale ORder Batch Views.</p>
|
<p>This module adds Deliverys to Sale ORder Batch Views.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
|
|
@ -397,10 +397,10 @@ ul.auto-toc {
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/bruecksen/nfu/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/bruecksen/ife_nfu/issues/new?body=module:%20sale_order_batch_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/bruecksen/nfu/issues/new?body=module:%20sale_order_batch_stock%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
|
@ -419,7 +419,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch_stock">bruecksen/ife_nfu</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch_stock">bruecksen/nfu</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
2
setup/.setuptools-odoo-make-default-ignore
Normal file
2
setup/.setuptools-odoo-make-default-ignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# addons listed in this file are ignored by
|
||||||
|
# setuptools-odoo-make-default (one addon per line)
|
||||||
2
setup/README
Normal file
2
setup/README
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
To learn more about this directory, please visit
|
||||||
|
https://pypi.python.org/pypi/setuptools-odoo
|
||||||
1
setup/nfu_ecommerce/odoo/addons/nfu_ecommerce
Symbolic link
1
setup/nfu_ecommerce/odoo/addons/nfu_ecommerce
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_ecommerce
|
||||||
6
setup/nfu_ecommerce/setup.py
Normal file
6
setup/nfu_ecommerce/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
1
setup/nfu_ekg_stock/odoo/addons/nfu_ekg_stock
Symbolic link
1
setup/nfu_ekg_stock/odoo/addons/nfu_ekg_stock
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_ekg_stock
|
||||||
6
setup/nfu_ekg_stock/setup.py
Normal file
6
setup/nfu_ekg_stock/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
1
setup/nfu_product/odoo/addons/nfu_product
Symbolic link
1
setup/nfu_product/odoo/addons/nfu_product
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_product
|
||||||
6
setup/nfu_product/setup.py
Normal file
6
setup/nfu_product/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_product_bnn_attributes
|
||||||
6
setup/nfu_product_bnn_attributes/setup.py
Normal file
6
setup/nfu_product_bnn_attributes/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_sale_order_batch_packaging
|
||||||
6
setup/nfu_sale_order_batch_packaging/setup.py
Normal file
6
setup/nfu_sale_order_batch_packaging/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../nfu_wholesaler_exporter
|
||||||
6
setup/nfu_wholesaler_exporter/setup.py
Normal file
6
setup/nfu_wholesaler_exporter/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
1
setup/sale_order_batch/odoo/addons/sale_order_batch
Symbolic link
1
setup/sale_order_batch/odoo/addons/sale_order_batch
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../sale_order_batch
|
||||||
6
setup/sale_order_batch/setup.py
Normal file
6
setup/sale_order_batch/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
1
setup/sale_order_batch_stock/odoo/addons/sale_order_batch_stock
Symbolic link
1
setup/sale_order_batch_stock/odoo/addons/sale_order_batch_stock
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../sale_order_batch_stock
|
||||||
6
setup/sale_order_batch_stock/setup.py
Normal file
6
setup/sale_order_batch_stock/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../website_decimal_quantity
|
||||||
6
setup/website_decimal_quantity/setup.py
Normal file
6
setup/website_decimal_quantity/setup.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
|
|
@ -51,21 +51,35 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
|
|
||||||
values = {}
|
values = {}
|
||||||
if access_token:
|
if access_token:
|
||||||
abandoned_order = request.env["sale.order"].sudo().search([("access_token", "=", access_token)], limit=1)
|
abandoned_order = (
|
||||||
|
request.env["sale.order"]
|
||||||
|
.sudo()
|
||||||
|
.search([("access_token", "=", access_token)], limit=1)
|
||||||
|
)
|
||||||
if not abandoned_order:
|
if not abandoned_order:
|
||||||
raise NotFound()
|
raise NotFound()
|
||||||
if abandoned_order.state != "draft":
|
if abandoned_order.state != "draft":
|
||||||
values.update({"abandoned_proceed": True})
|
values.update({"abandoned_proceed": True})
|
||||||
elif revive == "squash" or (revive == "merge" and not request.session.get("sale_order_id")):
|
elif revive == "squash" or (
|
||||||
|
revive == "merge" and not request.session.get("sale_order_id")
|
||||||
|
):
|
||||||
request.session["sale_order_id"] = abandoned_order.id
|
request.session["sale_order_id"] = abandoned_order.id
|
||||||
return request.redirect("/shop/cart")
|
return request.redirect("/shop/cart")
|
||||||
elif revive == "merge":
|
elif revive == "merge":
|
||||||
abandoned_order.order_line.write({"order_id": request.session["sale_order_id"]})
|
abandoned_order.order_line.write(
|
||||||
|
{"order_id": request.session["sale_order_id"]}
|
||||||
|
)
|
||||||
abandoned_order.action_cancel()
|
abandoned_order.action_cancel()
|
||||||
elif abandoned_order.id != request.session.get("sale_order_id"):
|
elif abandoned_order.id != request.session.get("sale_order_id"):
|
||||||
values.update({"access_token": abandoned_order.access_token})
|
values.update({"access_token": abandoned_order.access_token})
|
||||||
|
|
||||||
values.update({"website_sale_order": order, "date": fields.Date.today(), "suggested_products": []})
|
values.update(
|
||||||
|
{
|
||||||
|
"website_sale_order": order,
|
||||||
|
"date": fields.Date.today(),
|
||||||
|
"suggested_products": [],
|
||||||
|
}
|
||||||
|
)
|
||||||
if order:
|
if order:
|
||||||
order.order_line.filtered(lambda l: not l.product_id.active).unlink()
|
order.order_line.filtered(lambda l: not l.product_id.active).unlink()
|
||||||
values["suggested_products"] = order._cart_accessories()
|
values["suggested_products"] = order._cart_accessories()
|
||||||
|
|
@ -73,7 +87,11 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
|
|
||||||
if post.get("type") == "popover":
|
if post.get("type") == "popover":
|
||||||
# force no-cache so IE11 doesn't cache this XHR
|
# force no-cache so IE11 doesn't cache this XHR
|
||||||
return request.render("website_sale.cart_popover", values, headers={"Cache-Control": "no-cache"})
|
return request.render(
|
||||||
|
"website_sale.cart_popover",
|
||||||
|
values,
|
||||||
|
headers={"Cache-Control": "no-cache"},
|
||||||
|
)
|
||||||
|
|
||||||
return request.render("website_sale.cart", values)
|
return request.render("website_sale.cart", values)
|
||||||
|
|
||||||
|
|
@ -95,10 +113,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
sale_order = request.website.sale_get_order(force_create=True)
|
sale_order = request.website.sale_get_order(force_create=True)
|
||||||
|
|
||||||
if product_custom_attribute_values:
|
if product_custom_attribute_values:
|
||||||
product_custom_attribute_values = json_scriptsafe.loads(product_custom_attribute_values)
|
product_custom_attribute_values = json_scriptsafe.loads(
|
||||||
|
product_custom_attribute_values
|
||||||
|
)
|
||||||
|
|
||||||
if no_variant_attribute_values:
|
if no_variant_attribute_values:
|
||||||
no_variant_attribute_values = json_scriptsafe.loads(no_variant_attribute_values)
|
no_variant_attribute_values = json_scriptsafe.loads(
|
||||||
|
no_variant_attribute_values
|
||||||
|
)
|
||||||
|
|
||||||
sale_order._cart_update(
|
sale_order._cart_update(
|
||||||
product_id=int(product_id),
|
product_id=int(product_id),
|
||||||
|
|
@ -145,10 +167,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
if product_custom_attribute_values:
|
if product_custom_attribute_values:
|
||||||
product_custom_attribute_values = json_scriptsafe.loads(product_custom_attribute_values)
|
product_custom_attribute_values = json_scriptsafe.loads(
|
||||||
|
product_custom_attribute_values
|
||||||
|
)
|
||||||
|
|
||||||
if no_variant_attribute_values:
|
if no_variant_attribute_values:
|
||||||
no_variant_attribute_values = json_scriptsafe.loads(no_variant_attribute_values)
|
no_variant_attribute_values = json_scriptsafe.loads(
|
||||||
|
no_variant_attribute_values
|
||||||
|
)
|
||||||
|
|
||||||
values = order._cart_update(
|
values = order._cart_update(
|
||||||
product_id=product_id,
|
product_id=product_id,
|
||||||
|
|
@ -167,8 +193,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
request.website.sale_reset()
|
request.website.sale_reset()
|
||||||
return values
|
return values
|
||||||
|
|
||||||
values["cart_quantity"] = round(sum(order.mapped("website_order_line.product_uom_qty")), 1)
|
values["cart_quantity"] = round(
|
||||||
values["minor_amount"] = (payment_utils.to_minor_currency_units(order.amount_total, order.currency_id),)
|
sum(order.mapped("website_order_line.product_uom_qty")), 1
|
||||||
|
)
|
||||||
|
values["minor_amount"] = (
|
||||||
|
payment_utils.to_minor_currency_units(
|
||||||
|
order.amount_total, order.currency_id
|
||||||
|
),
|
||||||
|
)
|
||||||
values["amount"] = order.amount_total
|
values["amount"] = order.amount_total
|
||||||
|
|
||||||
if not display:
|
if not display:
|
||||||
|
|
@ -176,9 +208,15 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
|
|
||||||
values["website_sale.cart_lines"] = request.env["ir.ui.view"]._render_template(
|
values["website_sale.cart_lines"] = request.env["ir.ui.view"]._render_template(
|
||||||
"website_sale.cart_lines",
|
"website_sale.cart_lines",
|
||||||
{"website_sale_order": order, "date": fields.Date.today(), "suggested_products": order._cart_accessories()},
|
{
|
||||||
|
"website_sale_order": order,
|
||||||
|
"date": fields.Date.today(),
|
||||||
|
"suggested_products": order._cart_accessories(),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
values["website_sale.short_cart_summary"] = request.env["ir.ui.view"]._render_template(
|
values["website_sale.short_cart_summary"] = request.env[
|
||||||
|
"ir.ui.view"
|
||||||
|
]._render_template(
|
||||||
"website_sale.short_cart_summary", {"website_sale_order": order}
|
"website_sale.short_cart_summary", {"website_sale_order": order}
|
||||||
)
|
)
|
||||||
return values
|
return values
|
||||||
|
|
@ -189,5 +227,7 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
This method updates the cart quantity count in the session based on the order's website order lines.
|
This method updates the cart quantity count in the session based on the order's website order lines.
|
||||||
"""
|
"""
|
||||||
if "website_sale_cart_quantity" not in request.session:
|
if "website_sale_cart_quantity" not in request.session:
|
||||||
return request.website.sale_get_order().mapped("website_order_line.product_uom_qty")
|
return request.website.sale_get_order().mapped(
|
||||||
|
"website_order_line.product_uom_qty"
|
||||||
|
)
|
||||||
return request.session["website_sale_cart_quantity"]
|
return request.session["website_sale_cart_quantity"]
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,9 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@http.route()
|
@http.route()
|
||||||
def cart_options_update_json(self, product_and_options, goto_shop=None, lang=None, **kwargs):
|
def cart_options_update_json(
|
||||||
|
self, product_and_options, goto_shop=None, lang=None, **kwargs
|
||||||
|
):
|
||||||
"""This route is called when submitting the optional product modal.
|
"""This route is called when submitting the optional product modal.
|
||||||
The product without parent is the main product, the other are
|
The product without parent is the main product, the other are
|
||||||
options.
|
options.
|
||||||
|
|
@ -64,7 +66,9 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
value = order._cart_update(
|
value = order._cart_update(
|
||||||
product_id=main_product["product_id"],
|
product_id=main_product["product_id"],
|
||||||
add_qty=main_product["quantity"],
|
add_qty=main_product["quantity"],
|
||||||
product_custom_attribute_values=main_product["product_custom_attribute_values"],
|
product_custom_attribute_values=main_product[
|
||||||
|
"product_custom_attribute_values"
|
||||||
|
],
|
||||||
no_variant_attribute_values=main_product["no_variant_attribute_values"],
|
no_variant_attribute_values=main_product["no_variant_attribute_values"],
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
@ -78,8 +82,12 @@ class WebsiteSaleDecimal(WebsiteSale):
|
||||||
product_id=option["product_id"],
|
product_id=option["product_id"],
|
||||||
set_qty=option["quantity"],
|
set_qty=option["quantity"],
|
||||||
linked_line_id=option_parent[parent_unique_id],
|
linked_line_id=option_parent[parent_unique_id],
|
||||||
product_custom_attribute_values=option["product_custom_attribute_values"],
|
product_custom_attribute_values=option[
|
||||||
no_variant_attribute_values=option["no_variant_attribute_values"],
|
"product_custom_attribute_values"
|
||||||
|
],
|
||||||
|
no_variant_attribute_values=option[
|
||||||
|
"no_variant_attribute_values"
|
||||||
|
],
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
option_parent[option["unique_id"]] = option_value["line_id"]
|
option_parent[option["unique_id"]] = option_value["line_id"]
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,16 @@ class SaleOrder(models.Model):
|
||||||
to represent it in decimal values
|
to represent it in decimal values
|
||||||
"""
|
"""
|
||||||
for order in self:
|
for order in self:
|
||||||
order.cart_quantity = sum(order.mapped("website_order_line.product_uom_qty"))
|
order.cart_quantity = sum(
|
||||||
order.only_services = all(line.product_id.type == "service" for line in order.website_order_line)
|
order.mapped("website_order_line.product_uom_qty")
|
||||||
|
)
|
||||||
|
order.only_services = all(
|
||||||
|
line.product_id.type == "service" for line in order.website_order_line
|
||||||
|
)
|
||||||
|
|
||||||
def _cart_update(self, product_id, line_id=None, add_qty=0, set_qty=0, **kwargs): # noqa: C901
|
def _cart_update( # noqa: C901
|
||||||
|
self, product_id, line_id=None, add_qty=0, set_qty=0, **kwargs
|
||||||
|
):
|
||||||
"""Add or set product quantity, add_qty can be negative.
|
"""Add or set product quantity, add_qty can be negative.
|
||||||
|
|
||||||
Making add_qty and set_qty integer are avoided in order
|
Making add_qty and set_qty integer are avoided in order
|
||||||
|
|
@ -49,12 +55,24 @@ class SaleOrder(models.Model):
|
||||||
if self.state != "draft":
|
if self.state != "draft":
|
||||||
request.session.pop("sale_order_id", None)
|
request.session.pop("sale_order_id", None)
|
||||||
request.session.pop("website_sale_cart_quantity", None)
|
request.session.pop("website_sale_cart_quantity", None)
|
||||||
raise UserError(_("It is forbidden to modify a sales order which is not in draft status."))
|
raise UserError(
|
||||||
|
_(
|
||||||
|
"It is forbidden to modify a sales order which is not in draft status."
|
||||||
|
)
|
||||||
|
)
|
||||||
product = self.env["product.product"].browse(product_id).exists()
|
product = self.env["product.product"].browse(product_id).exists()
|
||||||
if not product or not product._is_add_to_cart_allowed():
|
if not product or not product._is_add_to_cart_allowed():
|
||||||
raise UserError(_("The given product does not exist therefore it cannot be added to cart."))
|
raise UserError(
|
||||||
|
_(
|
||||||
|
"The given product does not exist therefore it cannot be added to cart."
|
||||||
|
)
|
||||||
|
)
|
||||||
if product.lst_price == 0 and product.website_id.prevent_zero_price_sale:
|
if product.lst_price == 0 and product.website_id.prevent_zero_price_sale:
|
||||||
raise UserError(_("The given product does not have a price therefore it cannot be added to cart."))
|
raise UserError(
|
||||||
|
_(
|
||||||
|
"The given product does not have a price therefore it cannot be added to cart."
|
||||||
|
)
|
||||||
|
)
|
||||||
if line_id is not False:
|
if line_id is not False:
|
||||||
order_line = self._cart_find_product_line(product_id, line_id, **kwargs)[:1]
|
order_line = self._cart_find_product_line(product_id, line_id, **kwargs)[:1]
|
||||||
else:
|
else:
|
||||||
|
|
@ -78,7 +96,9 @@ class SaleOrder(models.Model):
|
||||||
else:
|
else:
|
||||||
quantity = add_qty or 0
|
quantity = add_qty or 0
|
||||||
if quantity > 0:
|
if quantity > 0:
|
||||||
quantity, warning = self._verify_updated_quantity(order_line, product_id, quantity, **kwargs)
|
quantity, warning = self._verify_updated_quantity(
|
||||||
|
order_line, product_id, quantity, **kwargs
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# If the line will be removed anyway, there is no need to verify
|
# If the line will be removed anyway, there is no need to verify
|
||||||
# the requested quantity update.
|
# the requested quantity update.
|
||||||
|
|
@ -89,18 +109,26 @@ class SaleOrder(models.Model):
|
||||||
order_line = self.env["sale.order.line"]
|
order_line = self.env["sale.order.line"]
|
||||||
elif order_line:
|
elif order_line:
|
||||||
# Update existing line
|
# Update existing line
|
||||||
update_values = self._prepare_order_line_update_values(order_line, quantity, **kwargs)
|
update_values = self._prepare_order_line_update_values(
|
||||||
|
order_line, quantity, **kwargs
|
||||||
|
)
|
||||||
if update_values:
|
if update_values:
|
||||||
self._update_cart_line_values(order_line, update_values)
|
self._update_cart_line_values(order_line, update_values)
|
||||||
elif quantity >= 0:
|
elif quantity >= 0:
|
||||||
# Create new line
|
# Create new line
|
||||||
order_line_values = self._prepare_order_line_values(product_id, quantity, **kwargs)
|
order_line_values = self._prepare_order_line_values(
|
||||||
|
product_id, quantity, **kwargs
|
||||||
|
)
|
||||||
order_line = self.env["sale.order.line"].sudo().create(order_line_values)
|
order_line = self.env["sale.order.line"].sudo().create(order_line_values)
|
||||||
return {
|
return {
|
||||||
"line_id": order_line.id,
|
"line_id": order_line.id,
|
||||||
"quantity": quantity,
|
"quantity": quantity,
|
||||||
"option_ids": list(
|
"option_ids": list(
|
||||||
set(order_line.option_line_ids.filtered(lambda l: l.order_id == order_line.order_id).ids)
|
set(
|
||||||
|
order_line.option_line_ids.filtered(
|
||||||
|
lambda l: l.order_id == order_line.order_id
|
||||||
|
).ids
|
||||||
|
)
|
||||||
),
|
),
|
||||||
"warning": warning,
|
"warning": warning,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue