[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:
|
||||
browser: true
|
||||
es6: true
|
||||
browser: true
|
||||
es6: true
|
||||
|
||||
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
|
||||
parserOptions:
|
||||
ecmaVersion: 2019
|
||||
ecmaVersion: 2019
|
||||
|
||||
overrides:
|
||||
- files:
|
||||
- "**/*.esm.js"
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
- files:
|
||||
- "**/*.esm.js"
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
|
||||
# Globals available in Odoo that shouldn't produce errorings
|
||||
globals:
|
||||
_: readonly
|
||||
$: readonly
|
||||
fuzzy: readonly
|
||||
jQuery: readonly
|
||||
moment: readonly
|
||||
odoo: readonly
|
||||
openerp: readonly
|
||||
owl: readonly
|
||||
luxon: readonly
|
||||
_: readonly
|
||||
$: readonly
|
||||
fuzzy: readonly
|
||||
jQuery: readonly
|
||||
moment: readonly
|
||||
odoo: readonly
|
||||
openerp: readonly
|
||||
owl: readonly
|
||||
luxon: readonly
|
||||
|
||||
# Styling is handled by Prettier, so we only need to enable AST rules;
|
||||
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
|
||||
rules:
|
||||
accessor-pairs: warn
|
||||
array-callback-return: warn
|
||||
callback-return: warn
|
||||
capitalized-comments:
|
||||
- warn
|
||||
- always
|
||||
- ignoreConsecutiveComments: true
|
||||
ignoreInlineComments: true
|
||||
complexity:
|
||||
- warn
|
||||
- 15
|
||||
constructor-super: warn
|
||||
dot-notation: warn
|
||||
eqeqeq: warn
|
||||
global-require: warn
|
||||
handle-callback-err: warn
|
||||
id-blacklist: warn
|
||||
id-match: warn
|
||||
init-declarations: error
|
||||
max-depth: warn
|
||||
max-nested-callbacks: warn
|
||||
max-statements-per-line: warn
|
||||
no-alert: warn
|
||||
no-array-constructor: warn
|
||||
no-caller: warn
|
||||
no-case-declarations: warn
|
||||
no-class-assign: warn
|
||||
no-cond-assign: error
|
||||
no-const-assign: error
|
||||
no-constant-condition: warn
|
||||
no-control-regex: warn
|
||||
no-debugger: error
|
||||
no-delete-var: warn
|
||||
no-div-regex: warn
|
||||
no-dupe-args: error
|
||||
no-dupe-class-members: error
|
||||
no-dupe-keys: error
|
||||
no-duplicate-case: error
|
||||
no-duplicate-imports: error
|
||||
no-else-return: warn
|
||||
no-empty-character-class: warn
|
||||
no-empty-function: error
|
||||
no-empty-pattern: error
|
||||
no-empty: warn
|
||||
no-eq-null: error
|
||||
no-eval: error
|
||||
no-ex-assign: error
|
||||
no-extend-native: warn
|
||||
no-extra-bind: warn
|
||||
no-extra-boolean-cast: warn
|
||||
no-extra-label: warn
|
||||
no-fallthrough: warn
|
||||
no-func-assign: error
|
||||
no-global-assign: error
|
||||
no-implicit-coercion:
|
||||
- warn
|
||||
- allow: ["~"]
|
||||
no-implicit-globals: warn
|
||||
no-implied-eval: warn
|
||||
no-inline-comments: warn
|
||||
no-inner-declarations: warn
|
||||
no-invalid-regexp: warn
|
||||
no-irregular-whitespace: warn
|
||||
no-iterator: warn
|
||||
no-label-var: warn
|
||||
no-labels: warn
|
||||
no-lone-blocks: warn
|
||||
no-lonely-if: error
|
||||
no-mixed-requires: error
|
||||
no-multi-str: warn
|
||||
no-native-reassign: error
|
||||
no-negated-condition: warn
|
||||
no-negated-in-lhs: error
|
||||
no-new-func: warn
|
||||
no-new-object: warn
|
||||
no-new-require: warn
|
||||
no-new-symbol: warn
|
||||
no-new-wrappers: warn
|
||||
no-new: warn
|
||||
no-obj-calls: warn
|
||||
no-octal-escape: warn
|
||||
no-octal: warn
|
||||
no-param-reassign: warn
|
||||
no-path-concat: warn
|
||||
no-process-env: warn
|
||||
no-process-exit: warn
|
||||
no-proto: warn
|
||||
no-prototype-builtins: warn
|
||||
no-redeclare: warn
|
||||
no-regex-spaces: warn
|
||||
no-restricted-globals: warn
|
||||
no-restricted-imports: warn
|
||||
no-restricted-modules: warn
|
||||
no-restricted-syntax: warn
|
||||
no-return-assign: error
|
||||
no-script-url: warn
|
||||
no-self-assign: warn
|
||||
no-self-compare: warn
|
||||
no-sequences: warn
|
||||
no-shadow-restricted-names: warn
|
||||
# no-shadow: warn
|
||||
no-sparse-arrays: warn
|
||||
no-sync: warn
|
||||
no-this-before-super: warn
|
||||
no-throw-literal: warn
|
||||
no-undef-init: warn
|
||||
no-undef: error
|
||||
no-unmodified-loop-condition: warn
|
||||
no-unneeded-ternary: error
|
||||
no-unreachable: error
|
||||
no-unsafe-finally: error
|
||||
no-unused-expressions: error
|
||||
no-unused-labels: error
|
||||
no-unused-vars: error
|
||||
no-use-before-define: error
|
||||
no-useless-call: warn
|
||||
no-useless-computed-key: warn
|
||||
no-useless-concat: warn
|
||||
no-useless-constructor: warn
|
||||
no-useless-escape: warn
|
||||
no-useless-rename: warn
|
||||
no-void: warn
|
||||
no-with: warn
|
||||
operator-assignment: [error, always]
|
||||
prefer-const: warn
|
||||
radix: warn
|
||||
require-yield: warn
|
||||
sort-imports: warn
|
||||
spaced-comment: [error, always]
|
||||
strict: [error, function]
|
||||
use-isnan: error
|
||||
valid-jsdoc:
|
||||
- warn
|
||||
- prefer:
|
||||
arg: param
|
||||
argument: param
|
||||
augments: extends
|
||||
constructor: class
|
||||
exception: throws
|
||||
func: function
|
||||
method: function
|
||||
prop: property
|
||||
return: returns
|
||||
virtual: abstract
|
||||
yield: yields
|
||||
preferType:
|
||||
array: Array
|
||||
bool: Boolean
|
||||
boolean: Boolean
|
||||
number: Number
|
||||
object: Object
|
||||
str: String
|
||||
string: String
|
||||
requireParamDescription: false
|
||||
requireReturn: false
|
||||
requireReturnDescription: false
|
||||
requireReturnType: false
|
||||
valid-typeof: warn
|
||||
yoda: warn
|
||||
accessor-pairs: warn
|
||||
array-callback-return: warn
|
||||
callback-return: warn
|
||||
capitalized-comments:
|
||||
- warn
|
||||
- always
|
||||
- ignoreConsecutiveComments: true
|
||||
ignoreInlineComments: true
|
||||
complexity:
|
||||
- warn
|
||||
- 15
|
||||
constructor-super: warn
|
||||
dot-notation: warn
|
||||
eqeqeq: warn
|
||||
global-require: warn
|
||||
handle-callback-err: warn
|
||||
id-blacklist: warn
|
||||
id-match: warn
|
||||
init-declarations: error
|
||||
max-depth: warn
|
||||
max-nested-callbacks: warn
|
||||
max-statements-per-line: warn
|
||||
no-alert: warn
|
||||
no-array-constructor: warn
|
||||
no-caller: warn
|
||||
no-case-declarations: warn
|
||||
no-class-assign: warn
|
||||
no-cond-assign: error
|
||||
no-const-assign: error
|
||||
no-constant-condition: warn
|
||||
no-control-regex: warn
|
||||
no-debugger: error
|
||||
no-delete-var: warn
|
||||
no-div-regex: warn
|
||||
no-dupe-args: error
|
||||
no-dupe-class-members: error
|
||||
no-dupe-keys: error
|
||||
no-duplicate-case: error
|
||||
no-duplicate-imports: error
|
||||
no-else-return: warn
|
||||
no-empty-character-class: warn
|
||||
no-empty-function: error
|
||||
no-empty-pattern: error
|
||||
no-empty: warn
|
||||
no-eq-null: error
|
||||
no-eval: error
|
||||
no-ex-assign: error
|
||||
no-extend-native: warn
|
||||
no-extra-bind: warn
|
||||
no-extra-boolean-cast: warn
|
||||
no-extra-label: warn
|
||||
no-fallthrough: warn
|
||||
no-func-assign: error
|
||||
no-global-assign: error
|
||||
no-implicit-coercion:
|
||||
- warn
|
||||
- allow: ["~"]
|
||||
no-implicit-globals: warn
|
||||
no-implied-eval: warn
|
||||
no-inline-comments: warn
|
||||
no-inner-declarations: warn
|
||||
no-invalid-regexp: warn
|
||||
no-irregular-whitespace: warn
|
||||
no-iterator: warn
|
||||
no-label-var: warn
|
||||
no-labels: warn
|
||||
no-lone-blocks: warn
|
||||
no-lonely-if: error
|
||||
no-mixed-requires: error
|
||||
no-multi-str: warn
|
||||
no-native-reassign: error
|
||||
no-negated-condition: warn
|
||||
no-negated-in-lhs: error
|
||||
no-new-func: warn
|
||||
no-new-object: warn
|
||||
no-new-require: warn
|
||||
no-new-symbol: warn
|
||||
no-new-wrappers: warn
|
||||
no-new: warn
|
||||
no-obj-calls: warn
|
||||
no-octal-escape: warn
|
||||
no-octal: warn
|
||||
no-param-reassign: warn
|
||||
no-path-concat: warn
|
||||
no-process-env: warn
|
||||
no-process-exit: warn
|
||||
no-proto: warn
|
||||
no-prototype-builtins: warn
|
||||
no-redeclare: warn
|
||||
no-regex-spaces: warn
|
||||
no-restricted-globals: warn
|
||||
no-restricted-imports: warn
|
||||
no-restricted-modules: warn
|
||||
no-restricted-syntax: warn
|
||||
no-return-assign: error
|
||||
no-script-url: warn
|
||||
no-self-assign: warn
|
||||
no-self-compare: warn
|
||||
no-sequences: warn
|
||||
no-shadow-restricted-names: warn
|
||||
# no-shadow: warn
|
||||
no-sparse-arrays: warn
|
||||
no-sync: warn
|
||||
no-this-before-super: warn
|
||||
no-throw-literal: warn
|
||||
no-undef-init: warn
|
||||
no-undef: error
|
||||
no-unmodified-loop-condition: warn
|
||||
no-unneeded-ternary: error
|
||||
no-unreachable: error
|
||||
no-unsafe-finally: error
|
||||
no-unused-expressions: error
|
||||
no-unused-labels: error
|
||||
no-unused-vars: error
|
||||
no-use-before-define: error
|
||||
no-useless-call: warn
|
||||
no-useless-computed-key: warn
|
||||
no-useless-concat: warn
|
||||
no-useless-constructor: warn
|
||||
no-useless-escape: warn
|
||||
no-useless-rename: warn
|
||||
no-void: warn
|
||||
no-with: warn
|
||||
operator-assignment: [error, always]
|
||||
prefer-const: warn
|
||||
radix: warn
|
||||
require-yield: warn
|
||||
sort-imports: warn
|
||||
spaced-comment: [error, always]
|
||||
strict: [error, function]
|
||||
use-isnan: error
|
||||
valid-jsdoc:
|
||||
- warn
|
||||
- prefer:
|
||||
arg: param
|
||||
argument: param
|
||||
augments: extends
|
||||
constructor: class
|
||||
exception: throws
|
||||
func: function
|
||||
method: function
|
||||
prop: property
|
||||
return: returns
|
||||
virtual: abstract
|
||||
yield: yields
|
||||
preferType:
|
||||
array: Array
|
||||
bool: Boolean
|
||||
boolean: Boolean
|
||||
number: Number
|
||||
object: Object
|
||||
str: String
|
||||
string: String
|
||||
requireParamDescription: false
|
||||
requireReturn: false
|
||||
requireReturnDescription: false
|
||||
requireReturnType: false
|
||||
valid-typeof: warn
|
||||
yoda: warn
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ exclude: |
|
|||
# Files and folders generated by bots, to avoid loops
|
||||
^setup/|/static/description/index\.html$|
|
||||
# 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?
|
||||
^README\.md$|
|
||||
# Library files can have extraneous formatting (even minimized)
|
||||
|
|
@ -17,13 +17,10 @@ exclude: |
|
|||
readme/.*\.(rst|md)$|
|
||||
# Ignore build and dist directories in addons
|
||||
/build/|/dist/|
|
||||
# Ignore test files in addons
|
||||
/tests/samples/.*|
|
||||
# You don't usually want a bot to modify your legal texts
|
||||
(LICENSE.*|COPYING.*)|
|
||||
# exclude configs itself
|
||||
^\.eslintrc\.yml$|
|
||||
^\.pre-commit-config\.yaml$|
|
||||
# Exclude util.py
|
||||
/migrations/util.py$
|
||||
(LICENSE.*|COPYING.*)
|
||||
default_language_version:
|
||||
python: python3
|
||||
node: "16.17.0"
|
||||
|
|
@ -43,18 +40,19 @@ repos:
|
|||
language: fail
|
||||
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
||||
- repo: https://github.com/oca/maintainer-tools
|
||||
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
|
||||
rev: d5fab7ee87fceee858a3d01048c78a548974d935
|
||||
hooks:
|
||||
# update the NOT INSTALLABLE ADDONS section above
|
||||
- id: oca-update-pre-commit-excluded-addons
|
||||
- id: oca-fix-manifest-website
|
||||
args: ["https://www.bakeup.org"]
|
||||
args:
|
||||
- https://www.bakeup.org
|
||||
- id: oca-gen-addon-readme
|
||||
args:
|
||||
- --addons-dir=.
|
||||
- --branch=16.0
|
||||
- --org-name=bruecksen
|
||||
- --repo-name=ife_nfu
|
||||
- --repo-name=nfu
|
||||
- --if-source-changed
|
||||
- --keep-source-digest
|
||||
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
||||
|
|
@ -62,6 +60,8 @@ repos:
|
|||
hooks:
|
||||
- id: oca-checks-odoo-module
|
||||
- id: oca-checks-po
|
||||
args:
|
||||
- --disable=po-pretty-format
|
||||
- repo: https://github.com/myint/autoflake
|
||||
rev: v1.6.1
|
||||
hooks:
|
||||
|
|
@ -77,30 +77,37 @@ repos:
|
|||
rev: 22.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
args:
|
||||
- --line-length=120
|
||||
- --skip-magic-trailing-comma
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.7.1
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: prettier
|
||||
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:
|
||||
- "prettier@2.7.1"
|
||||
- "@prettier/plugin-xml@2.2.0"
|
||||
args:
|
||||
- --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
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: eslint
|
||||
verbose: true
|
||||
name: eslint
|
||||
entry: eslint
|
||||
args:
|
||||
- --color
|
||||
- --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
|
||||
rev: v4.3.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
# exclude autogenerated files
|
||||
|
|
@ -134,8 +141,18 @@ repos:
|
|||
args:
|
||||
- --settings=.
|
||||
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
|
||||
rev: 3.9.2
|
||||
rev: 5.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
name: flake8
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU eCommerce
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_ecommerce
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -48,10 +48,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -72,6 +72,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -11,19 +11,30 @@ class WebsiteSaleMinMax(WebsiteSale):
|
|||
"""Override to get ordered_qty and max_qty from the product."""
|
||||
product_uom_ordered_qty = fields.Float(ordered_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):
|
||||
def _get_additional_shop_values(self, 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
|
||||
batch = request.website.sale_get_order(force_create=True).batch_id
|
||||
batch_products = batch.product_ids.filtered(lambda p: p.product_packaging_id)
|
||||
packaging_info = {}
|
||||
for product in values.get("products").sudo().filtered(lambda p: p.packaging_ids):
|
||||
batch_product = batch_products.filtered(lambda p: p.product_template_id == product)
|
||||
for product in (
|
||||
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:
|
||||
batch_product = batch_product[0]
|
||||
state_color = batch_product.get_state_color()
|
||||
|
|
@ -36,11 +47,15 @@ class WebsiteSale(WebsiteSale):
|
|||
"package_qty": batch_product.product_packaging_qty,
|
||||
}
|
||||
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
|
||||
|
||||
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_product = batch.product_ids.filtered(
|
||||
lambda p: p.product_template_id == product and p.product_packaging_id
|
||||
|
|
@ -59,7 +74,14 @@ class WebsiteSale(WebsiteSale):
|
|||
return new_values
|
||||
|
||||
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(
|
||||
category=category,
|
||||
|
|
@ -84,18 +106,35 @@ class WebsiteSale(WebsiteSale):
|
|||
auth="public",
|
||||
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"))
|
||||
if open_packages:
|
||||
batch = request.website.sale_get_order(force_create=True).batch_id
|
||||
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
|
||||
else:
|
||||
post["open_product_ids"] = None
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ class ProductTemplate(models.Model):
|
|||
_inherit = "product.template"
|
||||
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ class SaleOrder(models.Model):
|
|||
@api.depends("amount_total")
|
||||
def _compute_updated_balance(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(
|
||||
self,
|
||||
|
|
@ -33,10 +35,17 @@ class SaleOrder(models.Model):
|
|||
product_custom_attribute_values=product_custom_attribute_values,
|
||||
**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
|
||||
|
||||
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(
|
||||
order_line, quantity, linked_line_id=linked_line_id, **kwargs
|
||||
)
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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
|
||||
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
|
||||
|
|
@ -416,10 +416,10 @@ and after the current order.</p>
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU EKG Stock
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ekg_stock
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_ekg_stock
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -41,10 +41,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -59,6 +59,6 @@ Authors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@
|
|||
"views/report_packing_list.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",
|
||||
"application": True,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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
|
||||
- small delivery slips</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
|
|
@ -392,10 +392,10 @@ ul.auto-toc {
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU Product
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_product
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -40,10 +40,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -63,6 +63,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -9,14 +9,18 @@ class ProductProduct(models.Model):
|
|||
for product in self:
|
||||
company_ids = vals.get("company_ids", [])[0][2]
|
||||
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
|
||||
for package in related_packages:
|
||||
if not package.company_ids:
|
||||
package.company_ids = product.company_ids
|
||||
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:
|
||||
package.company_ids = [(6, 0, company_ids)]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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">
|
||||
<li>Remove company_id and add company_ids to views</li>
|
||||
</ul>
|
||||
|
|
@ -396,10 +396,10 @@ ul.auto-toc {
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU BNN Attributes
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_product_bnn_attributes
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_product_bnn_attributes
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -43,10 +43,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -66,6 +66,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ class ProductTemplate(models.Model):
|
|||
for product in self:
|
||||
qty = vals.get("packaging_qty") or product.packaging_qty
|
||||
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:
|
||||
for product_product in product_products:
|
||||
packagings = self.env["product.packaging"].search(
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
|
|
@ -397,10 +397,10 @@ ul.auto-toc {
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU Sale Order Batch Packaging
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_sale_order_batch_packaging
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -76,6 +76,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -1,23 +1,39 @@
|
|||
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):
|
||||
_inherit = "sale.order.batch.product"
|
||||
|
||||
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")
|
||||
def _compute_product_uom_max_qty(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")
|
||||
def _compute_open_packaging_qty(self):
|
||||
|
|
@ -27,7 +43,9 @@ class SaleOrderBatchProduct(models.Model):
|
|||
product.product_uom_qty % product.product_packaging_qty, 3
|
||||
)
|
||||
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:
|
||||
product.open_packaging_qty = 0.0
|
||||
|
|
@ -36,9 +54,16 @@ class SaleOrderBatchProduct(models.Model):
|
|||
def _compute_open_packaging_max_qty(self):
|
||||
for product in self:
|
||||
if product.product_packaging_id:
|
||||
if product.product_uom_max_qty < 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
|
||||
if (
|
||||
product.product_uom_max_qty
|
||||
< 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:
|
||||
product.open_packaging_max_qty = 0.0
|
||||
|
|
@ -60,7 +85,9 @@ class SaleOrderBatchProduct(models.Model):
|
|||
for vals in vals_list:
|
||||
if vals.get("product_id") and not vals.get("product_packaging_id"):
|
||||
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:
|
||||
vals["product_packaging_id"] = packaging.id
|
||||
|
|
|
|||
|
|
@ -5,10 +5,18 @@ from odoo.exceptions import UserError
|
|||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
product_uom_ordered_qty = fields.Float(string="Ordered Qty", digits="Product Unit of Measure", default=1.0)
|
||||
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")
|
||||
product_uom_ordered_qty = fields.Float(
|
||||
string="Ordered Qty", digits="Product Unit of Measure", default=1.0
|
||||
)
|
||||
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")
|
||||
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:
|
||||
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."
|
||||
)
|
||||
)
|
||||
|
|
@ -24,12 +32,17 @@ class SaleOrderLine(models.Model):
|
|||
@api.model_create_multi
|
||||
def create(self, 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")
|
||||
vals["product_uom_max_qty"] = product_qty
|
||||
if vals.get("product_id") and not vals.get("product_packaging_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
|
||||
return super().create(vals_list)
|
||||
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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
|
||||
and adds a packaging default to sale order batch.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
|
|
@ -434,10 +434,10 @@ and adds a packaging default to sale order batch.</p>
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ NFU Wholesaler Exporter
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_wholesaler_exporter
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/nfu_wholesaler_exporter
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -74,6 +74,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -13,12 +13,23 @@ class SaleOrderBatch(models.Model):
|
|||
# Prepare CSV content
|
||||
csv_content = "Artnr,Menge\n"
|
||||
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
|
||||
if not float_is_zero(product.open_packaging_qty, precision_rounding=0.01):
|
||||
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"
|
||||
if not float_is_zero(
|
||||
product.open_packaging_qty, precision_rounding=0.01
|
||||
):
|
||||
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
|
||||
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
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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.
|
||||
It exports the article number (default_code) and the qty of the Sale Order Batch
|
||||
Product view.</p>
|
||||
|
|
@ -420,10 +420,10 @@ Das ist aktuell der default_code, falls wir den mal prefixen, muss das hier ange
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ Sale Order Batch
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -48,10 +48,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -71,6 +71,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@ from odoo.exceptions import UserError
|
|||
class SaleOrder(models.Model):
|
||||
_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):
|
||||
"""
|
||||
|
|
@ -47,7 +52,9 @@ class SaleOrder(models.Model):
|
|||
if order.batch_id:
|
||||
invalid_orders.append(order.name)
|
||||
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()
|
||||
|
||||
def write(self, vals):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@ from odoo import _, api, fields, models
|
|||
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"}}
|
||||
|
||||
|
||||
|
|
@ -25,10 +30,19 @@ class SaleOrderBatch(models.Model):
|
|||
default=lambda self: _("New"),
|
||||
)
|
||||
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(
|
||||
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(
|
||||
string="Order Date",
|
||||
|
|
@ -41,10 +55,14 @@ class SaleOrderBatch(models.Model):
|
|||
)
|
||||
sale_order_ids = fields.One2many("sale.order", "batch_id")
|
||||
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_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")
|
||||
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
||||
product_count = fields.Integer(compute="_compute_product_count")
|
||||
|
|
@ -66,11 +84,13 @@ class SaleOrderBatch(models.Model):
|
|||
def _compute_invoice_status(self):
|
||||
for batch in self:
|
||||
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"
|
||||
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"
|
||||
elif batch.sale_order_ids and all(
|
||||
|
|
@ -113,11 +133,15 @@ class SaleOrderBatch(models.Model):
|
|||
|
||||
def action_view_products(self):
|
||||
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:
|
||||
result["domain"] = [("id", "in", self.product_ids.ids)]
|
||||
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
|
||||
else:
|
||||
result = {"type": "ir.actions.act_window_close"}
|
||||
|
|
@ -125,13 +149,17 @@ class SaleOrderBatch(models.Model):
|
|||
|
||||
def action_view_invoice(self):
|
||||
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:
|
||||
action["domain"] = [("id", "in", invoices.ids)]
|
||||
elif len(invoices) == 1:
|
||||
form_view = [(self.env.ref("account.view_move_form").id, "form")]
|
||||
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:
|
||||
action["views"] = form_view
|
||||
action["res_id"] = invoices.id
|
||||
|
|
@ -169,5 +197,7 @@ class SaleOrderBatch(models.Model):
|
|||
if "company_id" in vals:
|
||||
self = self.with_company(vals["company_id"])
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -19,14 +19,26 @@ class SaleOrderBatchProduct(models.Model):
|
|||
readonly=True,
|
||||
)
|
||||
state = fields.Selection(related="batch_id.state")
|
||||
product_id = fields.Many2one(comodel_name="product.product", required=True, readonly=True)
|
||||
product_template_id = fields.Many2one(
|
||||
"product.template", related="product_id.product_tmpl_id", string="Product Template"
|
||||
product_id = fields.Many2one(
|
||||
comodel_name="product.product", required=True, readonly=True
|
||||
)
|
||||
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(
|
||||
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")
|
||||
lst_price = fields.Float(
|
||||
|
|
@ -50,26 +62,42 @@ class SaleOrderBatchProduct(models.Model):
|
|||
@api.constrains("product_id", "sale_order_line_ids")
|
||||
def _check_sale_order_line_products(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")
|
||||
|
||||
@api.depends("sale_order_line_ids.product_uom_qty")
|
||||
def _compute_uom_qty(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")
|
||||
def _compute_product_packaging_id(self):
|
||||
for line in self:
|
||||
# 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
|
||||
# suggest always the first packaging
|
||||
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
|
||||
line.product_packaging_id = suggested_packaging or line.product_packaging_id
|
||||
suggested_packaging = (
|
||||
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")
|
||||
def _compute_product_packaging_qty(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:
|
||||
batch_id = line.batch_id
|
||||
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:
|
||||
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_without_batch = self - lines_with_batch
|
||||
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()
|
||||
lines_with_batch._link_batch_product()
|
||||
lines_without_batch._unlink_batch_product()
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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
|
||||
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>
|
||||
|
|
@ -417,10 +417,10 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ Sale Order Batch Stock Binding
|
|||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fife_nfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/ife_nfu/tree/16.0/sale_order_batch_stock
|
||||
:alt: bruecksen/ife_nfu
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github
|
||||
:target: https://github.com/bruecksen/nfu/tree/16.0/sale_order_batch_stock
|
||||
:alt: bruecksen/nfu
|
||||
|
||||
|badge1| |badge2| |badge3|
|
||||
|
||||
|
|
@ -37,10 +37,10 @@ Changelog
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -60,6 +60,6 @@ Contributors
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@ STATES = [("open", "Open"), ("close", "Close")]
|
|||
class SaleOrderBatch(models.Model):
|
||||
_inherit = "sale.order.batch"
|
||||
|
||||
picking_ids = fields.Many2many("stock.picking", compute="_compute_picking_ids", string="Transfers")
|
||||
delivery_count = fields.Integer(string="Delivery Orders", compute="_compute_picking_ids")
|
||||
picking_ids = fields.Many2many(
|
||||
"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")
|
||||
def _compute_picking_ids(self):
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! 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><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
|
|
@ -397,10 +397,10 @@ ul.auto-toc {
|
|||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<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.
|
||||
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>
|
||||
</div>
|
||||
<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 class="section" id="maintainers">
|
||||
<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>
|
||||
</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 = {}
|
||||
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:
|
||||
raise NotFound()
|
||||
if abandoned_order.state != "draft":
|
||||
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
|
||||
return request.redirect("/shop/cart")
|
||||
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()
|
||||
elif abandoned_order.id != request.session.get("sale_order_id"):
|
||||
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:
|
||||
order.order_line.filtered(lambda l: not l.product_id.active).unlink()
|
||||
values["suggested_products"] = order._cart_accessories()
|
||||
|
|
@ -73,7 +87,11 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
|
||||
if post.get("type") == "popover":
|
||||
# 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)
|
||||
|
||||
|
|
@ -95,10 +113,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
sale_order = request.website.sale_get_order(force_create=True)
|
||||
|
||||
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:
|
||||
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(
|
||||
product_id=int(product_id),
|
||||
|
|
@ -145,10 +167,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
return {}
|
||||
|
||||
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:
|
||||
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(
|
||||
product_id=product_id,
|
||||
|
|
@ -167,8 +193,14 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
request.website.sale_reset()
|
||||
return values
|
||||
|
||||
values["cart_quantity"] = round(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["cart_quantity"] = round(
|
||||
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
|
||||
|
||||
if not display:
|
||||
|
|
@ -176,9 +208,15 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
|
||||
values["website_sale.cart_lines"] = request.env["ir.ui.view"]._render_template(
|
||||
"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}
|
||||
)
|
||||
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.
|
||||
"""
|
||||
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"]
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
"""
|
||||
|
||||
@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.
|
||||
The product without parent is the main product, the other are
|
||||
options.
|
||||
|
|
@ -64,7 +66,9 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
value = order._cart_update(
|
||||
product_id=main_product["product_id"],
|
||||
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"],
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -78,8 +82,12 @@ class WebsiteSaleDecimal(WebsiteSale):
|
|||
product_id=option["product_id"],
|
||||
set_qty=option["quantity"],
|
||||
linked_line_id=option_parent[parent_unique_id],
|
||||
product_custom_attribute_values=option["product_custom_attribute_values"],
|
||||
no_variant_attribute_values=option["no_variant_attribute_values"],
|
||||
product_custom_attribute_values=option[
|
||||
"product_custom_attribute_values"
|
||||
],
|
||||
no_variant_attribute_values=option[
|
||||
"no_variant_attribute_values"
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
option_parent[option["unique_id"]] = option_value["line_id"]
|
||||
|
|
|
|||
|
|
@ -36,10 +36,16 @@ class SaleOrder(models.Model):
|
|||
to represent it in decimal values
|
||||
"""
|
||||
for order in self:
|
||||
order.cart_quantity = sum(order.mapped("website_order_line.product_uom_qty"))
|
||||
order.only_services = all(line.product_id.type == "service" for line in order.website_order_line)
|
||||
order.cart_quantity = sum(
|
||||
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.
|
||||
|
||||
Making add_qty and set_qty integer are avoided in order
|
||||
|
|
@ -49,12 +55,24 @@ class SaleOrder(models.Model):
|
|||
if self.state != "draft":
|
||||
request.session.pop("sale_order_id", 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()
|
||||
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:
|
||||
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:
|
||||
order_line = self._cart_find_product_line(product_id, line_id, **kwargs)[:1]
|
||||
else:
|
||||
|
|
@ -78,7 +96,9 @@ class SaleOrder(models.Model):
|
|||
else:
|
||||
quantity = add_qty or 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:
|
||||
# If the line will be removed anyway, there is no need to verify
|
||||
# the requested quantity update.
|
||||
|
|
@ -89,18 +109,26 @@ class SaleOrder(models.Model):
|
|||
order_line = self.env["sale.order.line"]
|
||||
elif order_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:
|
||||
self._update_cart_line_values(order_line, update_values)
|
||||
elif quantity >= 0:
|
||||
# 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)
|
||||
return {
|
||||
"line_id": order_line.id,
|
||||
"quantity": quantity,
|
||||
"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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue