diff --git a/.eslintrc.yml b/.eslintrc.yml index 9429bc688..fed88d70d 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -22,6 +22,7 @@ globals: 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 diff --git a/.flake8 b/.flake8 index e397e8ed4..0adcf4233 100644 --- a/.flake8 +++ b/.flake8 @@ -7,6 +7,7 @@ select = C,E,F,W,B,B9 # E203: whitespace before ':' (black behaviour) # E501: flake8 line length (covered by bugbear B950) # W503: line break before binary operator (black behaviour) -ignore = E203,E501,W503 +# C901: Function is too complex +ignore = E203,E501,W503,C901 per-file-ignores= __init__.py:F401 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..602ecbca2 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,46 @@ +name: pre-commit + +on: + pull_request: + branches: + - "14.0*" + push: + branches: + - "14.0" + - "14.0-ocabot-*" + +jobs: + pre-commit: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v2 + with: + python-version: "3.11" + - name: Get python version + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install pre-commit + run: pip install pre-commit + - name: Run pre-commit + run: pre-commit run --all-files --show-diff-on-failure --color=always + env: + # Consider valid a PR that changes README fragments but doesn't + # change the README.rst file itself. It's not really a problem + # because the bot will update it anyway after merge. This way, we + # lower the barrier for functional contributors that want to fix the + # readme fragments, while still letting developers get README + # auto-generated (which also helps functionals when using runboat). + # DOCS https://pre-commit.com/#temporarily-disabling-hooks + SKIP: oca-gen-addon-readme + - name: Check that all files generated by pre-commit are in git + run: | + newfiles="$(git ls-files --others --exclude-from=.gitignore)" + if [ "$newfiles" != "" ] ; then + echo "Please check-in the following files:" + echo "$newfiles" + exit 1 + fi diff --git a/.gitignore b/.gitignore index 9c283fd41..0090721f5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ *.py[cod] /.venv /.pytest_cache +/.ruff_cache # C extensions *.so diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d625265e..a378fc062 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,12 @@ exclude: | /static/(src/)?lib/| # Repos using Sphinx to generate docs don't need prettying ^docs/_templates/.*\.html$| + # Don't bother non-technical authors with formatting issues in docs + 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.*) default_language_version: @@ -33,14 +39,19 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: 969238e47c07d0c40573acff81d170f63245d738 + rev: 9a170331575a265c092ee6b24b845ec508e8ef75 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons - id: oca-fix-manifest-website args: ["https://github.com/avanzosc/mrp-addons"] + - repo: https://github.com/OCA/odoo-pre-commit-hooks + rev: v0.0.25 + hooks: + - id: oca-checks-odoo-module + - id: oca-checks-po - repo: https://github.com/myint/autoflake - rev: v2.2.1 + rev: v1.4 hooks: - id: autoflake args: @@ -51,11 +62,11 @@ repos: - --remove-duplicate-keys - --remove-unused-variables - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + rev: v2.1.2 hooks: - id: prettier name: prettier (with plugin-xml) @@ -66,7 +77,7 @@ repos: - --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.48.0 + rev: v7.8.1 hooks: - id: eslint verbose: true @@ -74,7 +85,7 @@ repos: - --color - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v3.2.0 hooks: - id: trailing-whitespace # exclude autogenerated files @@ -96,7 +107,7 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v2.7.2 hooks: - id: pyupgrade args: ["--keep-percent-format"] @@ -109,7 +120,7 @@ repos: - --settings=. exclude: /__init__\.py$ - repo: https://github.com/acsone/setuptools-odoo - rev: 3.1.12 + rev: 3.1.8 hooks: - id: setuptools-odoo-make-default - id: setuptools-odoo-get-requirements @@ -119,13 +130,13 @@ repos: - --header - "# generated from manifests external_dependencies" - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 3.8.3 hooks: - id: flake8 name: flake8 - additional_dependencies: ["flake8-bugbear==21.9.2"] + additional_dependencies: ["flake8-bugbear==20.1.4"] - repo: https://github.com/OCA/pylint-odoo - rev: v8.0.20 + rev: 7.0.2 hooks: - id: pylint_odoo name: pylint with optional checks diff --git a/.pylintrc b/.pylintrc index b28107b6c..ac714a941 100644 --- a/.pylintrc +++ b/.pylintrc @@ -63,39 +63,6 @@ enable=anomalous-backslash-in-string, use-vim-comment, wrong-tabs-instead-of-spaces, xml-syntax-error, - attribute-string-redundant, - character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, - create-user-wo-reset-password, - dangerous-filter-wo-user, - dangerous-qweb-replace-wo-priority, - deprecated-data-xml-node, - deprecated-openerp-xml-node, - duplicate-po-message-definition, - except-pass, - file-not-used, - invalid-commit, - manifest-maintainers-list, - missing-newline-extrafiles, - missing-readme, - missing-return, - odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, - renamed-field-parameter, - resource-not-exist, - str-format-used, - test-folder-imported, - translation-contains-variable, - translation-positional-used, - unnecessary-utf8-coding-comment, - website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, - external-request-timeout, # messages that do not cause the lint step to fail consider-merging-classes-inherited, create-user-wo-reset-password, diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 967b0ffaf..b4ce55ef6 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -55,40 +55,7 @@ enable=anomalous-backslash-in-string, unreachable, use-vim-comment, wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, - character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, - create-user-wo-reset-password, - dangerous-filter-wo-user, - dangerous-qweb-replace-wo-priority, - deprecated-data-xml-node, - deprecated-openerp-xml-node, - duplicate-po-message-definition, - except-pass, - file-not-used, - invalid-commit, - manifest-maintainers-list, - missing-newline-extrafiles, - missing-readme, - missing-return, - odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, - renamed-field-parameter, - resource-not-exist, - str-format-used, - test-folder-imported, - translation-contains-variable, - translation-positional-used, - unnecessary-utf8-coding-comment, - website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, - external-request-timeout + xml-syntax-error [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/.travis.yml b/.travis.yml index ec444145b..67eeaa5fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,23 @@ language: python +sudo: false +cache: pip python: - "3.6" -sudo: false -cache: pip - addons: postgresql: "9.6" apt: packages: - expect-dev # provides unbuffer utility - python-lxml # because pip installation is slow - - python-unidecode - antiword # document module - cups - libcups2-dev env: global: - - VERSION="14.0" TESTS="0" LINT_CHECK="0" + - VERSION="14.0" TESTS="0" LINT_CHECK="0" WKHTMLTOPDF_VERSION="0.12.4" matrix: - LINT_CHECK="1" - TESTS="1" ODOO_REPO="OCA/OCB" @@ -29,10 +27,11 @@ install: - git clone --depth=1 https://github.com/avanzosc/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} + - pip install unidecode - travis_install_nightly script: - - travis_wait travis_run_tests + - travis_run_tests after_success: - travis_after_tests_success diff --git a/LICENSE b/LICENSE index 3ffc56789..a930cc7e9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ -GNU AFFERO GENERAL PUBLIC LICENSE + GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -658,4 +658,4 @@ specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see -. \ No newline at end of file +. diff --git a/custom_mrp_descarga/__manifest__.py b/custom_mrp_descarga/__manifest__.py index b04918ebc..2a1c01e94 100644 --- a/custom_mrp_descarga/__manifest__.py +++ b/custom_mrp_descarga/__manifest__.py @@ -7,7 +7,7 @@ "category": "MRP", "license": "AGPL-3", "author": "AvanzOSC", - "website": "http://www.avanzosc.es", + "website": "https://github.com/avanzosc/mrp-addons", "depends": [ "custom_mrp_line_cost", "custom_descarga", @@ -36,6 +36,7 @@ "views/stock_move_line_view.xml", "views/killing_cost_view.xml", "report/mrp_production_summary_xlsx.xml", + "report/mrp_production_quartering_summary_xlsx.xml", ], "installable": True, "auto_install": True, diff --git a/custom_mrp_descarga/data/ir_sequence.xml b/custom_mrp_descarga/data/ir_sequence.xml index af6aa2e2d..0092c2f4d 100644 --- a/custom_mrp_descarga/data/ir_sequence.xml +++ b/custom_mrp_descarga/data/ir_sequence.xml @@ -1,14 +1,13 @@ - - - - Secuencia para órdenes de producción de despiece - DESP/ - 5 - - - Secuencia para órdenes de producción de clasificado - CLAS/ - 5 - - + + + + Secuencia para órdenes de producción de despiece + DESP/ + 5 + + + Secuencia para órdenes de producción de clasificado + CLAS/ + 5 + diff --git a/custom_mrp_descarga/data/mrp_bom_category.xml b/custom_mrp_descarga/data/mrp_bom_category.xml index 6e36a92fc..5a23d0839 100644 --- a/custom_mrp_descarga/data/mrp_bom_category.xml +++ b/custom_mrp_descarga/data/mrp_bom_category.xml @@ -1,12 +1,17 @@ - - - - Despiece - - - - Clasificado - - - + + + + Despiece + + + + Clasificado + + diff --git a/custom_mrp_descarga/data/quartering_product.xml b/custom_mrp_descarga/data/quartering_product.xml index e96690bd0..9d3c57998 100644 --- a/custom_mrp_descarga/data/quartering_product.xml +++ b/custom_mrp_descarga/data/quartering_product.xml @@ -1,7 +1,6 @@ - - - - Despiece - - + + + + Despiece + diff --git a/custom_mrp_descarga/i18n/custom_mrp_descarga.pot b/custom_mrp_descarga/i18n/custom_mrp_descarga.pot index ae0bb95a2..3f43a8d33 100644 --- a/custom_mrp_descarga/i18n/custom_mrp_descarga.pot +++ b/custom_mrp_descarga/i18n/custom_mrp_descarga.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-11 10:14+0000\n" -"PO-Revision-Date: 2024-04-11 10:14+0000\n" +"POT-Creation-Date: 2024-06-25 08:03+0000\n" +"PO-Revision-Date: 2024-06-25 08:03+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,6 +15,12 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "% rendimiento" +msgstr "" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 @@ -159,6 +165,7 @@ msgid "Cost" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -171,6 +178,7 @@ msgid "Count Production" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -222,6 +230,12 @@ msgstr "" msgid "Dest Kg" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Diferencia" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__birth_difference #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__qty_difference @@ -239,6 +253,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line__display_name @@ -276,6 +291,13 @@ msgid "Emtying Hatchers" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Entradas" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -332,6 +354,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line__id @@ -342,6 +365,7 @@ msgid "ID" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -374,6 +398,30 @@ msgstr "" msgid "Inventory Line" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG bruto" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG envases" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG neto" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG palets" +msgstr "" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 @@ -393,6 +441,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line____last_update @@ -437,6 +486,11 @@ msgstr "" msgid "Líneas de despieces" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model,name:custom_mrp_descarga.model_report_mrp_production_quartering_summary_xlsx +msgid "MRP Production Quartering Summary Report" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model,name:custom_mrp_descarga.model_report_mrp_production_summary_xlsx msgid "MRP Production Summary Report" @@ -524,12 +578,19 @@ msgstr "" msgid "PAASA" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Palets" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__performance msgid "Performance" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -584,6 +645,12 @@ msgstr "" msgid "Production Orders" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Producto" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__purchase_price msgid "Purchase Amount" @@ -637,6 +704,17 @@ msgstr "" msgid "Reproductor" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Resumen de despiece" +msgstr "" + +#. module: custom_mrp_descarga +#: model:ir.actions.report,name:custom_mrp_descarga.report_mrp_quartering_summary_xlsx +msgid "Resumen de despiece XLSX" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.actions.report,name:custom_mrp_descarga.report_mrp_production_summary_xlsx msgid "Resumen de mantanza XLSX" @@ -677,6 +755,12 @@ msgstr "" msgid "Saca Line" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Salidas" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__seized_units msgid "Seized" @@ -759,6 +843,12 @@ msgstr "" msgid "Total Done" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Total Entradas" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view msgid "Total Pallet" @@ -803,6 +893,12 @@ msgstr "" msgid "Total Quantity" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Total Salidas" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.production_move_line_ids_tree_view msgid "Total Units" @@ -814,6 +910,7 @@ msgid "Total amount" msgstr "" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format diff --git a/custom_mrp_descarga/i18n/es.po b/custom_mrp_descarga/i18n/es.po index d62938802..a76946a69 100644 --- a/custom_mrp_descarga/i18n/es.po +++ b/custom_mrp_descarga/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-11 10:14+0000\n" -"PO-Revision-Date: 2024-04-11 10:14+0000\n" +"POT-Creation-Date: 2024-06-25 08:04+0000\n" +"PO-Revision-Date: 2024-06-25 08:04+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,6 +15,12 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "% rendimiento" +msgstr "" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 @@ -161,6 +167,7 @@ msgid "Cost" msgstr "Coste" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -173,6 +180,7 @@ msgid "Count Production" msgstr "Contador OF" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -224,6 +232,12 @@ msgstr "" msgid "Dest Kg" msgstr "Cantidad destino" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Diferencia" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__birth_difference #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__qty_difference @@ -241,6 +255,7 @@ msgstr "% diferencia" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line__display_name #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line__display_name @@ -278,6 +293,13 @@ msgid "Emtying Hatchers" msgstr "Vaciar nacedoras" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Entradas" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -334,6 +356,7 @@ msgstr "Galllinas" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line__id #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line__id @@ -344,6 +367,7 @@ msgid "ID" msgstr "Identificador" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -376,6 +400,30 @@ msgstr "Integración" msgid "Inventory Line" msgstr "Línea inventario" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG bruto" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG envases" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG neto" +msgstr "" + +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "KG palets" +msgstr "" + #. module: custom_mrp_descarga #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 @@ -395,6 +443,7 @@ msgstr "" #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update +#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_summary_xlsx____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_saca_line____last_update #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_inventory_line____last_update @@ -439,6 +488,11 @@ msgstr "" msgid "Líneas de despieces" msgstr "" +#. module: custom_mrp_descarga +#: model:ir.model,name:custom_mrp_descarga.model_report_mrp_production_quartering_summary_xlsx +msgid "MRP Production Quartering Summary Report" +msgstr "Informe de despiece" + #. module: custom_mrp_descarga #: model:ir.model,name:custom_mrp_descarga.model_report_mrp_production_summary_xlsx msgid "MRP Production Summary Report" @@ -526,12 +580,19 @@ msgstr "Salidas" msgid "PAASA" msgstr "" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Palets" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__performance msgid "Performance" msgstr "Rendimiento" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format @@ -586,6 +647,12 @@ msgstr "Orden de producción" msgid "Production Orders" msgstr "Órdenes de producción" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Producto" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__purchase_price msgid "Purchase Amount" @@ -639,6 +706,17 @@ msgstr "" msgid "Reproductor" msgstr "Reproductora" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Resumen de despiece" +msgstr "" + +#. module: custom_mrp_descarga +#: model:ir.actions.report,name:custom_mrp_descarga.report_mrp_quartering_summary_xlsx +msgid "Resumen de despiece XLSX" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.actions.report,name:custom_mrp_descarga.report_mrp_production_summary_xlsx msgid "Resumen de mantanza XLSX" @@ -679,6 +757,12 @@ msgstr "Fecha de saca" msgid "Saca Line" msgstr "Línea de saca" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Salidas" +msgstr "" + #. module: custom_mrp_descarga #: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__seized_units msgid "Seized" @@ -761,6 +845,12 @@ msgstr "Total envases" msgid "Total Done" msgstr "Total hecho" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Total Entradas" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view msgid "Total Pallet" @@ -805,6 +895,12 @@ msgstr "Total disponible" msgid "Total Quantity" msgstr "Cantidad total" +#. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 +#, python-format +msgid "Total Salidas" +msgstr "" + #. module: custom_mrp_descarga #: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.production_move_line_ids_tree_view msgid "Total Units" @@ -816,6 +912,7 @@ msgid "Total amount" msgstr "Importe total" #. module: custom_mrp_descarga +#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #: code:addons/custom_mrp_descarga/report/mrp_production_summary_xlsx.py:0 #, python-format diff --git a/custom_mrp_descarga/models/account_analytic_line.py b/custom_mrp_descarga/models/account_analytic_line.py index 4066cea73..9a1f458c1 100644 --- a/custom_mrp_descarga/models/account_analytic_line.py +++ b/custom_mrp_descarga/models/account_analytic_line.py @@ -6,10 +6,9 @@ class AccountAnalyticLine(models.Model): _inherit = "account.analytic.line" - production_id = fields.Many2one( - string="Production", - comodel_name="mrp.production") + production_id = fields.Many2one(string="Production", comodel_name="mrp.production") unload_date = fields.Datetime( string="Unload Date", related="production_id.saca_line_id.unload_date", - store=True) + store=True, + ) diff --git a/custom_mrp_descarga/models/mrp_bom.py b/custom_mrp_descarga/models/mrp_bom.py index 96a88fd1e..aeba76507 100644 --- a/custom_mrp_descarga/models/mrp_bom.py +++ b/custom_mrp_descarga/models/mrp_bom.py @@ -7,16 +7,11 @@ class MrpBom(models.Model): _inherit = "mrp.bom" quartering = fields.Boolean( - string="Quartering", - compute="_compute_quartering", - store=True + string="Quartering", compute="_compute_quartering", store=True ) - no_duplicate_lines = fields.Boolean( - string="No Duplicate Lines", - default=False) + no_duplicate_lines = fields.Boolean(string="No Duplicate Lines", default=False) no_produce_product = fields.Boolean( - string="Don't produce the header product", - default=False + string="Don't produce the header product", default=False ) @api.depends("category_id") @@ -24,8 +19,7 @@ def _compute_quartering(self): for line in self: quartering = False try: - quartering = ( - self.env.ref("custom_mrp_descarga.quartering_category")) + quartering = self.env.ref("custom_mrp_descarga.quartering_category") if line.category_id == quartering: quartering = True except Exception: diff --git a/custom_mrp_descarga/models/mrp_production.py b/custom_mrp_descarga/models/mrp_production.py index 9f4e8d6b4..6197ccf34 100644 --- a/custom_mrp_descarga/models/mrp_production.py +++ b/custom_mrp_descarga/models/mrp_production.py @@ -1,164 +1,131 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import _, api, fields, models -from datetime import datetime +from datetime import datetime, timedelta + from dateutil import rrule -from _datetime import timedelta + +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class MrpProduction(models.Model): _inherit = "mrp.production" + def _default_production_date(self): + result = fields.Datetime.now() + return result + saca_line_id = fields.Many2one( - string="Saca Line", - comodel_name="saca.line", - copy=False) + string="Saca Line", comodel_name="saca.line", copy=False + ) saca_id = fields.Many2one( - string="Saca", - comodel_name="saca", - related="saca_line_id.saca_id", - store=True) + string="Saca", comodel_name="saca", related="saca_line_id.saca_id", store=True + ) origin_qty = fields.Float( - string="Origin Qty", - related="saca_line_id.net_origin", - store=True) - dest_qty = fields.Float( - related="saca_line_id.net_dest", - store=True) - purchase_price = fields.Float( - related="saca_line_id.purchase_price", - store=True) + string="Origin Qty", related="saca_line_id.net_origin", store=True + ) + dest_qty = fields.Float(related="saca_line_id.net_dest", store=True) + purchase_price = fields.Float(related="saca_line_id.purchase_price", store=True) purchase_unit_price = fields.Float( - related="saca_line_id.purchase_unit_price", - store=True) - saca_date = fields.Date( - string="Saca Date", - related="saca_line_id.date", - store=True) + related="saca_line_id.purchase_unit_price", store=True + ) + saca_date = fields.Date(string="Saca Date", related="saca_line_id.date", store=True) reproductor_quant_ids = fields.One2many( string="Reproductor", comodel_name="stock.quant", - compute="_compute_reproductor_quant_ids") + compute="_compute_reproductor_quant_ids", + ) batch_id = fields.Many2one( - string="Mother", - comodel_name="stock.picking.batch", - copy=False) + string="Mother", comodel_name="stock.picking.batch", copy=False + ) chick_production = fields.Boolean( string="Chick Production", related="picking_type_id.chick_production", - store=True) - production_date = fields.Datetime( - default=fields.Datetime.now()) + store=True, + ) + production_date = fields.Datetime(default=_default_production_date) birth_week = fields.Integer( - string="Birth Week", - compute="_compute_birth_week", - store=True) - paasa = fields.Boolean( - string="PAASA", - related="company_id.paasa", - store=True) - tolvasa = fields.Boolean( - string="Tolvasa", - related="company_id.tolvasa", - store=True) + string="Birth Week", compute="_compute_birth_week", store=True + ) + paasa = fields.Boolean(string="PAASA", related="company_id.paasa", store=True) + tolvasa = fields.Boolean(string="Tolvasa", related="company_id.tolvasa", store=True) guide_number = fields.Char( - string="Guide Number", - related="saca_line_id.guide_number", - store=True) + string="Guide Number", related="saca_line_id.guide_number", store=True + ) channel_temperature = fields.Float( string="Channel Temperature", related="saca_line_id.channel_temperature", - store=True) - staff = fields.Integer( - string="Staff", - related="saca_line_id.staff", - store=True) - product_qty = fields.Float( - copy=False) + store=True, + ) + staff = fields.Integer(string="Staff", related="saca_line_id.staff", store=True) + product_qty = fields.Float(copy=False) hen_unit = fields.Integer( - string="Hen Units", - related="batch_id.hen_unit", - store=True) + string="Hen Units", related="batch_id.hen_unit", store=True + ) birth_rate = fields.Float( - string="Birth %", - compute="_compute_birth_rate", - store=True) + string="Birth %", compute="_compute_birth_rate", store=True + ) expected_birth = fields.Float( - string="Expected Births", - compute="_compute_expected_birth", - store=True) + string="Expected Births", compute="_compute_expected_birth", store=True + ) expected_rate = fields.Float( - string="Expected %", - compute="_compute_expected_birth", - store=True) + string="Expected %", compute="_compute_expected_birth", store=True + ) birth_difference = fields.Float( - string="Difference", - compute="_compute_birth_difference", - store=True) + string="Difference", compute="_compute_birth_difference", store=True + ) difference_rate = fields.Float( - string="Difference %", - compute="_compute_difference_rate", - store=True) + string="Difference %", compute="_compute_difference_rate", store=True + ) batch_location_id = fields.Many2one( - string="Mother Location", - related="batch_id.location_id", - store=True) + string="Mother Location", related="batch_id.location_id", store=True + ) clasified_date = fields.Date( - string="Clasified Date", - compute="_compute_clasified_date") + string="Clasified Date", compute="_compute_clasified_date" + ) clasified_time_start = fields.Float( - string="Clasified Time Start", - compute="_compute_clasified_date") + string="Clasified Time Start", compute="_compute_clasified_date" + ) clasified_time_stop = fields.Float( - string="Clasified Time Stop", - compute="_compute_clasified_date") + string="Clasified Time Stop", compute="_compute_clasified_date" + ) real_average_weight = fields.Float( string="Real Average Weight", compute="_compute_real_average_weight", store=True, - digits="Weight Decimal Precision") + digits="Weight Decimal Precision", + ) unload_date = fields.Datetime( - string="Unload Date", - related="saca_line_id.unload_date", - store=True) + string="Unload Date", related="saca_line_id.unload_date", store=True + ) download_unit = fields.Integer( - string="Download Unit", - related="saca_line_id.download_unit", - store=True) + string="Download Unit", related="saca_line_id.download_unit", store=True + ) unit_difference = fields.Integer( - string="Unit Difference", - compute="_compute_unit_difference", - store=True) - total_unit = fields.Float( - string="Units", - compute="_compute_total_unit", - store=True) + string="Unit Difference", compute="_compute_unit_difference", store=True + ) + total_unit = fields.Float(string="Units", compute="_compute_total_unit", store=True) average_weight = fields.Float( string="Average Weight", related="saca_line_id.average_weight_origin", - store=True) + store=True, + ) gross_yield = fields.Float( - string="Gross Yield", - compute="_compute_gross_yield", - store=True) + string="Gross Yield", compute="_compute_gross_yield", store=True + ) descarga_order = fields.Char( - string="Descarga Order", - related="saca_line_id.descarga_order") + string="Descarga Order", related="saca_line_id.descarga_order" + ) produced_qty = fields.Float( - string="Produced Qty", - compute="_compute_produced_qty", - store=True) + string="Produced Qty", compute="_compute_produced_qty", store=True + ) qty_difference = fields.Float( - string="Difference", - compute="_compute_qty_difference", - store=True) - quartering = fields.Boolean( - string="Quartering") + string="Difference", compute="_compute_qty_difference", store=True + ) + quartering = fields.Boolean(string="Quartering") no_duplicate_lines = fields.Boolean( - string="No Duplicate Lines", - related="bom_id.no_duplicate_lines", - store=True) + string="No Duplicate Lines", related="bom_id.no_duplicate_lines", store=True + ) bom_id = fields.Many2one( domain="""[ '&', @@ -171,123 +138,142 @@ class MrpProduction(models.Model): '&', ('product_tmpl_id.product_variant_ids','=',product_id), ('product_id','=',False), - ('type', '=', 'normal')]""") + ('type', '=', 'normal')]""" + ) clasification = fields.Selection( - string="Clasification", selection=[ + string="Clasification", + selection=[ ("normal", "Normal"), ("relaxed", "Relaxed"), - ("demanding", "Demanding")]) - channel_temperature = fields.Float( - string="Channel Temperature") + ("demanding", "Demanding"), + ], + ) + channel_temperature = fields.Float(string="Channel Temperature") waiting_time = fields.Float(string="Waiting Time") clasified_ids = fields.One2many( string="Classified", comodel_name="account.analytic.line", - inverse_name="production_id") + inverse_name="production_id", + ) farm_warehouse_id = fields.Many2one( string="Farm", comodel_name="stock.warehouse", related="saca_line_id.farm_warehouse_id", - store=True) + store=True, + ) farm_id = fields.Many2one( string="Farm", comodel_name="res.partner", related="saca_line_id.farm_id", - store=True) + store=True, + ) vehicle_id = fields.Many2one( string="Vehicle", comodel_name="fleet.vehicle", related="saca_line_id.vehicle_id", - store=True) + store=True, + ) remolque_id = fields.Many2one( string="Remolque", comodel_name="fleet.vehicle", related="saca_line_id.remolque_id", - store=True) + store=True, + ) breeding_id = fields.Many2one( string="Breeding", comodel_name="stock.picking.batch", related="saca_line_id.breeding_id", - store=True) + store=True, + ) asphyxiation_units = fields.Integer( - string="Asphyxiated", - compute="_compute_asphyxiation_units", - store=True) + string="Asphyxiated", compute="_compute_asphyxiation_units", store=True + ) seized_units = fields.Integer( - string="Seized", - compute="_compute_seized_units", - store=True) + string="Seized", compute="_compute_seized_units", store=True + ) rto_percentage = fields.Float( - string="Rto. %", - compute="_compute_rto_percentage", - store=True) + string="Rto. %", compute="_compute_rto_percentage", store=True + ) bom_category_id = fields.Many2one( - string="Category", - related="bom_id.category_id", - store=True) + string="Category", related="bom_id.category_id", store=True + ) no_produce_product = fields.Boolean( string="Don't produce the header product", related="bom_id.no_produce_product", - store=True) + store=True, + ) @api.depends("move_line_ids.percentage") def _compute_rto_percentage(self): for line in self: rto_percentage = 0 if line.move_line_ids: - rto_percentage = sum( - line.move_line_ids.mapped("percentage")) + rto_percentage = sum(line.move_line_ids.mapped("percentage")) line.rto_percentage = rto_percentage - @api.depends("move_line_ids.product_id", - "move_line_ids.product_id.chicken_seized", - "move_line_ids.unit", "quartering") + @api.depends( + "move_line_ids.product_id", + "move_line_ids.product_id.chicken_seized", + "move_line_ids.unit", + "quartering", + ) def _compute_seized_units(self): for line in self: seized_units = 0 - if line.move_line_ids and line.move_line_ids.filtered( - lambda c: c.product_id.chicken_seized) and not ( - line.quartering): + if ( + line.move_line_ids + and line.move_line_ids.filtered(lambda c: c.product_id.chicken_seized) + and not (line.quartering) + ): seized_units = sum( line.move_line_ids.filtered( - lambda c: c.product_id.chicken_seized).mapped("unit")) + lambda c: c.product_id.chicken_seized + ).mapped("unit") + ) line.seized_units = seized_units - @api.depends("move_line_ids.product_id", - "move_line_ids.product_id.asphyxiated", "quartering", - "move_line_ids.unit") + @api.depends( + "move_line_ids.product_id", + "move_line_ids.product_id.asphyxiated", + "quartering", + "move_line_ids.unit", + ) def _compute_asphyxiation_units(self): for line in self: asphyxiation_units = 0 - if line.move_line_ids and line.move_line_ids.filtered( - lambda c: c.product_id.asphyxiated) and not ( - line.quartering): + if ( + line.move_line_ids + and line.move_line_ids.filtered(lambda c: c.product_id.asphyxiated) + and not (line.quartering) + ): asphyxiation_units = sum( line.move_line_ids.filtered( - lambda c: c.product_id.asphyxiated).mapped("unit")) + lambda c: c.product_id.asphyxiated + ).mapped("unit") + ) line.asphyxiation_units = asphyxiation_units def _compute_classified_ids(self): for line in self: - cond = [("production_id", "=", line.id), ( - "classified", "=", True)] + cond = [("production_id", "=", line.id), ("classified", "=", True)] classified = self.env["account.analytic.line"].search(cond) line.clasified_ids = [(6, 0, classified.ids)] @api.depends("produced_qty", "consume_qty") def _compute_qty_difference(self): for production in self: - production.qty_difference = ( - production.consume_qty - production.produced_qty) + production.qty_difference = production.consume_qty - production.produced_qty @api.depends("finished_move_line_ids.qty_done") def _compute_produced_qty(self): for production in self: produced_qty = 0 if production.finished_move_line_ids: - produced_qty = sum(production.finished_move_line_ids.filtered( - lambda c: c.product_uom_id == production.product_uom_id - ).mapped("qty_done")) + produced_qty = sum( + production.finished_move_line_ids.filtered( + lambda c: c.product_uom_id == production.product_uom_id + ).mapped("qty_done") + ) production.produced_qty = produced_qty @api.depends("move_line_ids.qty_done", "origin_qty") @@ -295,8 +281,9 @@ def _compute_gross_yield(self): for line in self: gross_yield = 0 if line.origin_qty != 0: - gross_yield = sum( - line.move_line_ids.mapped("qty_done")) / line.origin_qty + gross_yield = ( + sum(line.move_line_ids.mapped("qty_done")) / line.origin_qty + ) line.gross_yield = gross_yield @api.depends("move_line_ids.unit") @@ -312,8 +299,9 @@ def _compute_unit_difference(self): for line in self: unit_difference = line.download_unit if line.move_line_ids: - unit_difference = sum( - line.move_line_ids.mapped("unit")) - line.download_unit + unit_difference = ( + sum(line.move_line_ids.mapped("unit")) - line.download_unit + ) line.unit_difference = unit_difference @api.depends("origin_qty", "move_line_ids.unit") @@ -344,8 +332,7 @@ def _compute_difference_rate(self): for line in self: difference_rate = 0 if line.product_qty != 0: - difference_rate = ( - line.birth_difference * 100 / line.product_qty) + difference_rate = line.birth_difference * 100 / line.product_qty line.difference_rate = difference_rate @api.depends("product_qty", "expected_birth") @@ -353,21 +340,20 @@ def _compute_birth_difference(self): for line in self: line.birth_difference = line.product_qty - line.expected_birth - @api.depends("batch_id.birth_rate_ids", "product_qty", - "production_date") + @api.depends("batch_id.birth_rate_ids", "product_qty", "production_date") def _compute_expected_birth(self): for line in self: expected_birth = 0 if line.production_date: rate = line.batch_id.birth_rate_ids.filtered( - lambda c: c.birth_start_date and c.birth_start_date <= ( - line.production_date.date()) and ( - c.birth_start_date + timedelta(days=7)) > ( - line.production_date.date())) + lambda c: c.birth_start_date + and c.birth_start_date <= (line.production_date.date()) + and (c.birth_start_date + timedelta(days=7)) + > (line.production_date.date()) + ) if rate: line.expected_rate = rate[0].percentage_birth - expected_birth = ( - line.product_qty * rate[0].percentage_birth) / 100 + expected_birth = (line.product_qty * rate[0].percentage_birth) / 100 line.expected_birth = expected_birth @api.depends("product_qty", "consume_qty") @@ -383,16 +369,15 @@ def _compute_birth_week(self): for line in self: week = 0 if line.production_date: - start_date = datetime( - line.production_date.year, 1, 1, 0, 0).date() + start_date = datetime(line.production_date.year, 1, 1, 0, 0).date() start_date = line.calculate_weeks_start(start_date) end_date = line.production_date.date() if end_date < start_date: start_date = datetime( - line.production_date.year - 1, 1, 1, 0, 0).date() + line.production_date.year - 1, 1, 1, 0, 0 + ).date() start_date = line.calculate_weeks_start(start_date) - end_date = datetime( - line.production_date.year, 1, 1, 0, 0).date() + end_date = datetime(line.production_date.year, 1, 1, 0, 0).date() week = line.weeks_between(start_date, end_date) if week == 53: week = 1 @@ -405,20 +390,24 @@ def weeks_between(self, start_date, end_date): def _compute_reproductor_quant_ids(self): for production in self: production.reproductor_quant_ids = ( - self.env["stock.quant"].sudo().search([])).filtered( - lambda c: c.product_id.egg is True and ( - c.location_id.is_hatchery is True)) + self.env["stock.quant"].sudo().search([]) + ).filtered( + lambda c: c.product_id.egg is True + and (c.location_id.is_hatchery is True) + ) @api.onchange("picking_type_id") def onchange_picking_type(self): result = super(MrpProduction, self).onchange_picking_type() product = self.env["product.product"].search( - [("one_day_chicken", "=", True)], limit=1) + [("one_day_chicken", "=", True)], limit=1 + ) if self.chick_production and product: self.product_id = product.id elif self.env.company.paasa: - product = self.env["product.product"].search([ - ("download_product", "=", True)]) + product = self.env["product.product"].search( + [("download_product", "=", True)] + ) if product and len(product) == 1: self.product_id = product.id else: @@ -454,43 +443,43 @@ def _onchange_product_id(self): def action_emptying_hatchers(self): for production in self: if not production.batch_id: - raise ValidationError( - _("No mother has been put on.") - ) + raise ValidationError(_("No mother has been put on.")) if not production.lot_producing_id: - raise ValidationError( - _("No lot has been put on.") - ) + raise ValidationError(_("No lot has been put on.")) production.move_line_ids.unlink() for quant in production.reproductor_quant_ids: - if ( - quant.available_quantity > 0) and ( - quant.lot_id.batch_id == production.batch_id): + if (quant.available_quantity > 0) and ( + quant.lot_id.batch_id == production.batch_id + ): line = production.move_line_ids.filtered( - lambda c: c.product_id == quant.product_id and ( - c.location_id == quant.location_id) and ( - c.lot_id == quant.lot_id)) + lambda c: c.product_id == quant.product_id + and (c.location_id == quant.location_id) + and (c.lot_id == quant.lot_id) + ) if line: line.qty_done += quant.available_quantity if not line: self.env["stock.move.line"].create( - {"product_id": quant.product_id.id, - "location_id": quant.location_id.id, - "location_dest_id": ( - production.production_location_id.id), - "product_uom_id": quant.product_id.uom_id.id, - "qty_done": quant.available_quantity, - "lot_id": quant.lot_id.id, - "batch_id": production.batch_id.id, - "standard_price": quant.product_id.standard_price, - "amount": ( - quant.available_quantity) * ( - quant.product_id.standard_price), - "company_id": production.company_id.id, - "production_id": production.id, - "move_id": production.move_raw_ids.filtered( - lambda c: c.product_id == quant.product_id - ).id}) + { + "product_id": quant.product_id.id, + "location_id": quant.location_id.id, + "location_dest_id": ( + production.production_location_id.id + ), + "product_uom_id": quant.product_id.uom_id.id, + "qty_done": quant.available_quantity, + "lot_id": quant.lot_id.id, + "batch_id": production.batch_id.id, + "standard_price": quant.product_id.standard_price, + "amount": (quant.available_quantity) + * (quant.product_id.standard_price), + "company_id": production.company_id.id, + "production_id": production.id, + "move_id": production.move_raw_ids.filtered( + lambda c: c.product_id == quant.product_id + ).id, + } + ) def action_view_reproductor_quant_ids(self): context = self.env.context.copy() @@ -501,7 +490,7 @@ def action_view_reproductor_quant_ids(self): "res_model": "stock.quant", "domain": [("id", "in", self.reproductor_quant_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } def action_confirm(self): @@ -513,9 +502,12 @@ def button_mark_done(self): if self.move_finished_ids: self.move_finished_ids._do_unreserve() result = super(MrpProduction, self).button_mark_done() - if result is not True and "res_model" in result and result[ - "res_model" - ] == "mrp.consumption.warning" and self.no_duplicate_lines: + if ( + result is not True + and "res_model" in result + and result["res_model"] == "mrp.consumption.warning" + and self.no_duplicate_lines + ): entry_qty = sum(self.move_line_ids.mapped("qty_done")) out_qty = sum(self.finished_move_line_ids.mapped("qty_done")) for move in self.move_raw_ids: @@ -539,8 +531,8 @@ def action_delete_producing_line(self): for line in self: if line.no_produce_product: for move in line.move_finished_ids.filtered( - lambda c: c.product_id == ( - line.product_id)): + lambda c: c.product_id == (line.product_id) + ): move.do_cancel_done() move.state = "cancel" @@ -550,31 +542,41 @@ def action_generate_serial(self): if not self.lot_producing_id: super(MrpProduction, self).action_generate_serial() if self.batch_id: - self.lot_producing_id.name = u"{}{}{}".format( - self.batch_id.name, date.strftime("%d%m"), ( - date.strftime("%Y")[2:])) + self.lot_producing_id.name = "{}{}{}".format( + self.batch_id.name, date.strftime("%d%m"), (date.strftime("%Y")[2:]) + ) if self.batch_id and self.lot_producing_id: - self.lot_producing_id.name = u"{}{}{}".format( - self.batch_id.name, date.strftime("%d%m"), ( - date.strftime("%Y")[2:])) + self.lot_producing_id.name = "{}{}{}".format( + self.batch_id.name, date.strftime("%d%m"), (date.strftime("%Y")[2:]) + ) self.lot_producing_id.batch_id = self.batch_id.id def action_assign_serials(self): for production in self: if production.move_line_ids and production.lot_producing_id: for line in production.move_line_ids: - if line.product_id.tracking != "none" and not ( - line.lot_id): - lot = self.env["stock.production.lot"].search( - [("name", "=", production.lot_producing_id.name), - ("product_id", "=", line.product_id.id)], - limit=1).id + if line.product_id.tracking != "none" and not (line.lot_id): + lot = ( + self.env["stock.production.lot"] + .search( + [ + ("name", "=", production.lot_producing_id.name), + ("product_id", "=", line.product_id.id), + ], + limit=1, + ) + .id + ) if not lot: - lot = self.env[( - "stock.production.lot")].action_create_lot( + lot = ( + self.env[("stock.production.lot")] + .action_create_lot( line.product_id, production.lot_producing_id.name, - production.company_id).id + production.company_id, + ) + .id + ) line.lot_id = lot def action_delete_moves_with_qty_zero(self): @@ -589,23 +591,29 @@ def calculate_weeks_start(self, start_date): if weekday <= 3: return start_date - timedelta(days=weekday) else: - return start_date + timedelta(days=(7-weekday)) + return start_date + timedelta(days=(7 - weekday)) @api.model - def read_group(self, domain, fields, groupby, offset=0, limit=None, - orderby=False, lazy=True): + def read_group( + self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True + ): result = super(MrpProduction, self).read_group( - domain, fields, groupby, offset=offset, limit=limit, - orderby=orderby, lazy=lazy + domain, + fields, + groupby, + offset=offset, + limit=limit, + orderby=orderby, + lazy=lazy, ) for line in result: - if '__domain' in line: + if "__domain" in line: lines = self.search(line["__domain"]) - average_weight = sum(lines.mapped("average_weight"))/len(lines) - rto_percentage = sum(lines.mapped("rto_percentage"))/len(lines) - purchase_unit_price = sum( - lines.mapped("purchase_unit_price") - )/len(lines) + average_weight = sum(lines.mapped("average_weight")) / len(lines) + rto_percentage = sum(lines.mapped("rto_percentage")) / len(lines) + purchase_unit_price = sum(lines.mapped("purchase_unit_price")) / len( + lines + ) line["average_weight"] = average_weight line["rto_percentage"] = rto_percentage line["purchase_unit_price"] = purchase_unit_price diff --git a/custom_mrp_descarga/models/project_task.py b/custom_mrp_descarga/models/project_task.py index 88869e332..52146bcb3 100644 --- a/custom_mrp_descarga/models/project_task.py +++ b/custom_mrp_descarga/models/project_task.py @@ -6,6 +6,4 @@ class ProjectTask(models.Model): _inherit = "project.task" - production_id = fields.Many2one( - string="Production", - comodel_name="mrp.production") + production_id = fields.Many2one(string="Production", comodel_name="mrp.production") diff --git a/custom_mrp_descarga/models/saca_line.py b/custom_mrp_descarga/models/saca_line.py index 03c5d7e7f..3ddd26a22 100644 --- a/custom_mrp_descarga/models/saca_line.py +++ b/custom_mrp_descarga/models/saca_line.py @@ -11,10 +11,11 @@ class SacaLine(models.Model): string="Production", comodel_name="mrp.production", inverse_name="saca_line_id", - compute="_compute_production_ids") + compute="_compute_production_ids", + ) count_production = fields.Integer( - string="Count Production", - compute="_compute_count_production") + string="Count Production", compute="_compute_count_production" + ) def _compute_count_production(self): for line in self: @@ -22,25 +23,29 @@ def _compute_count_production(self): def _compute_production_ids(self): for line in self: - cond = [("saca_line_id", "=", line.id), ( - "quartering", "=", False)] + cond = [("saca_line_id", "=", line.id), ("quartering", "=", False)] production = self.env["mrp.production"].search(cond) line.production_ids = [(6, 0, production.ids)] def action_view_production(self): context = self.env.context.copy() - context.update({'default_saca_line_id': False, - "production_id": self.production_ids[0].id, - "active_model": "mrp.production", - "active_id": self.production_ids[0].id, - "active_ids": self.production_ids[0].ids}) + context.update( + { + "default_saca_line_id": False, + "production_id": self.production_ids[0].id, + "active_model": "mrp.production", + "active_id": self.production_ids[0].id, + "active_ids": self.production_ids[0].ids, + } + ) return { - 'name': _("Production"), - 'view_mode': 'tree,form', - 'res_model': 'mrp.production', - 'domain': [('id', 'in', self.production_ids.ids)], - 'type': 'ir.actions.act_window', - 'context': context, + "name": _("Production"), + "view_mode": "tree,form", + "res_model": "mrp.production", + "domain": [("id", "in", self.production_ids.ids)], + "search_view_id": self.env.ref("mrp.view_mrp_production_filter").id, + "type": "ir.actions.act_window", + "context": context, } def action_next_stage(self): @@ -49,26 +54,28 @@ def action_next_stage(self): project = self.env.ref("custom_saca_timesheet.project_saca") if self.company_id != self.env.company: raise ValidationError( - _("The company of the saca and your company is not the same.")) + _("The company of the saca and your company is not the same.") + ) if self.stage_id == stage_clasificado: - for line in ( - self.move_line_ids.filtered( - lambda c: not c.move_id.sale_line_id)): + for line in self.move_line_ids.filtered( + lambda c: not c.move_id.sale_line_id + ): bom = self.env["mrp.bom"].search( - [("product_tmpl_id", "=", ( - line.product_id.product_tmpl_id.id))], limit=1) - new_production = self.env["mrp.production"].new({ - "bom_id": bom.id, - "product_id": line.product_id.id, - "product_uom_id": line.product_uom_id.id, - "product_qty": self.net_origin, - "saca_line_id": self.id, - "lot_producing_id": line.lot_id.id, - "company_id": self.company_id.id - }) - for ( - comp_onchange) in ( - new_production._onchange_methods["company_id"]): + [("product_tmpl_id", "=", (line.product_id.product_tmpl_id.id))], + limit=1, + ) + new_production = self.env["mrp.production"].new( + { + "bom_id": bom.id, + "product_id": line.product_id.id, + "product_uom_id": line.product_uom_id.id, + "product_qty": self.net_origin, + "saca_line_id": self.id, + "lot_producing_id": line.lot_id.id, + "company_id": self.company_id.id, + } + ) + for comp_onchange in new_production._onchange_methods["company_id"]: comp_onchange(new_production) vals = new_production._convert_to_write(new_production._cache) production = self.env["mrp.production"].create(vals) @@ -89,17 +96,28 @@ def action_next_stage(self): if self.production_ids: for line in self.production_ids: if not line.clasified_ids: - self.env["project.task"].create({ - "project_id": project.id, - "name": "Clasificado", - "production_id": line.id, - "timesheet_ids": [(0, 0, { - "production_id": line.id, - "date": self.unload_date.date(), - "name": u'{} {}'.format( - project.name, "Clasificado"), + self.env["project.task"].create( + { "project_id": project.id, - "classified": True})]}) + "name": "Clasificado", + "production_id": line.id, + "timesheet_ids": [ + ( + 0, + 0, + { + "production_id": line.id, + "date": self.unload_date.date(), + "name": "{} {}".format( + project.name, "Clasificado" + ), + "project_id": project.id, + "classified": True, + }, + ) + ], + } + ) for clas in line.clasified_ids: clas.employee_id = False clas.user_id = False @@ -111,19 +129,20 @@ def _compute_stage(self): matanza = self.env.ref("custom_descarga.stage_matanza") clasificado = self.env.ref("custom_descarga.stage_clasificado") if line.stage_id == clasificado and not line.production_ids: - line.write({ - "stage_id": matanza.id, - "is_presaca": False, - "is_saca": False, - "is_descarga": False, - "is_killing": True, - "is_classified": False}) + line.write( + { + "stage_id": matanza.id, + "is_presaca": False, + "is_saca": False, + "is_descarga": False, + "is_killing": True, + "is_classified": False, + } + ) def write(self, values): result = super(SacaLine, self).write(values) - if "gross_origin" in ( - values) or "tara_origin" in ( - values) and self.net_origin: + if "gross_origin" in (values) or "tara_origin" in (values) and self.net_origin: for line in self.production_ids: line.product_qty = self.net_origin return result diff --git a/custom_mrp_descarga/models/stock_inventory_line.py b/custom_mrp_descarga/models/stock_inventory_line.py index 1827abdb5..6d00867cb 100644 --- a/custom_mrp_descarga/models/stock_inventory_line.py +++ b/custom_mrp_descarga/models/stock_inventory_line.py @@ -19,35 +19,35 @@ def onchange_cost(self): if self.inventory_id and self.inventory_id.batch_id: if self.prod_lot_id: entry_line = self.inventory_id.batch_id.move_line_ids.filtered( - lambda c: c.lot_id == self.prod_lot_id and ( - c.location_dest_id == self.location_id - ) and c.picking_id + lambda c: c.lot_id == self.prod_lot_id + and (c.location_dest_id == self.location_id) + and c.picking_id ) dev_line = self.inventory_id.batch_id.move_line_ids.filtered( - lambda c: c.lot_id == self.prod_lot_id and ( - c.location_id == self.location_id - ) and c.picking_id + lambda c: c.lot_id == self.prod_lot_id + and (c.location_id == self.location_id) + and c.picking_id ) if entry_line: dev_line_amount = sum(dev_line.mapped("amount")) or 0 dev_line_qty = sum(dev_line.mapped("qty_done")) or 0 - self.cost = ( - sum(entry_line.mapped("amount")) - dev_line_amount - ) / (sum( entry_line.mapped("qty_done")) - dev_line_qty) + self.cost = (sum(entry_line.mapped("amount")) - dev_line_amount) / ( + sum(entry_line.mapped("qty_done")) - dev_line_qty + ) elif self.product_id: entry_line = self.inventory_id.batch_id.move_line_ids.filtered( - lambda c: c.product_id == self.product_id and ( - c.location_dest_id == self.location_id - ) and c.picking_id + lambda c: c.product_id == self.product_id + and (c.location_dest_id == self.location_id) + and c.picking_id ) dev_line = self.inventory_id.batch_id.move_line_ids.filtered( - lambda c: c.product_id == self.product_id and ( - c.location_id == self.location_id - ) and c.picking_id + lambda c: c.product_id == self.product_id + and (c.location_id == self.location_id) + and c.picking_id ) if entry_line: dev_line_amount = sum(dev_line.mapped("amount")) or 0 dev_line_qty = sum(dev_line.mapped("qty_done")) or 0 - self.cost = ( - sum(entry_line.mapped("amount")) - dev_line_amount - ) / (sum( entry_line.mapped("qty_done")) - dev_line_qty) + self.cost = (sum(entry_line.mapped("amount")) - dev_line_amount) / ( + sum(entry_line.mapped("qty_done")) - dev_line_qty + ) diff --git a/custom_mrp_descarga/models/stock_move.py b/custom_mrp_descarga/models/stock_move.py index de3badfee..448516246 100644 --- a/custom_mrp_descarga/models/stock_move.py +++ b/custom_mrp_descarga/models/stock_move.py @@ -1,13 +1,17 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import _, api, fields, models +from odoo import api, models class StockMove(models.Model): _inherit = "stock.move" - @api.depends("purchase_line_id", "sale_line_id", - "raw_material_production_id", "production_id") + @api.depends( + "purchase_line_id", + "sale_line_id", + "raw_material_production_id", + "production_id", + ) def _compute_saca_line_id(self): super(StockMove, self)._compute_saca_line_id() for move in self: diff --git a/custom_mrp_descarga/models/stock_move_line.py b/custom_mrp_descarga/models/stock_move_line.py index 90ce20955..9910924f6 100644 --- a/custom_mrp_descarga/models/stock_move_line.py +++ b/custom_mrp_descarga/models/stock_move_line.py @@ -1,32 +1,24 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from datetime import timedelta + from odoo import _, api, fields, models from odoo.exceptions import ValidationError -from _datetime import timedelta class StockMoveLine(models.Model): _inherit = "stock.move.line" performance = fields.Float( - string="Performance", - compute="_compute_performance", - store=True) + string="Performance", compute="_compute_performance", store=True + ) sequence = fields.Integer( - string="Sequence", - compute="_compute_sequence", - store=True - ) - quartering = fields.Boolean( - string="Quartering", - related="production_id.quartering", - store=True + string="Sequence", compute="_compute_sequence", store=True ) - saca_date = fields.Date( - string="Saca Date", - related="saca_line_id.date", - store=True + quartering = fields.Boolean( + string="Quartering", related="production_id.quartering", store=True ) + saca_date = fields.Date(string="Saca Date", related="saca_line_id.date", store=True) @api.depends("production_id") def _compute_sequence(self): @@ -36,8 +28,8 @@ def _compute_sequence(self): ids = [] movelines = False if line in line.production_id.move_line_ids and ( - line.location_id == ( - line.production_id.location_src_id)): + line.location_id == (line.production_id.location_src_id) + ): movelines = line.production_id.move_line_ids elif line in line.production_id.finished_move_line_ids: movelines = line.production_id.finished_move_line_ids @@ -54,8 +46,7 @@ def _compute_performance(self): for line in self: performance = 0 if line.production_id and line.production_id.consume_qty != 0: - performance = ( - line.qty_done * 100) / line.production_id.consume_qty + performance = (line.qty_done * 100) / line.production_id.consume_qty line.performance = performance @api.onchange("unit") @@ -64,72 +55,100 @@ def onchange_unit(self): if self.unit: self.download_unit = self.unit - @api.onchange("product_id", "location_id", "location_dest_id", - "production_id", "production_id", - "production_id") + @api.onchange( + "product_id", + "location_id", + "location_dest_id", + "production_id", + "production_id", + "production_id", + ) def onchange_product_id(self): self.ensure_one() - if "production_id" in self.env.context or "default_production_id" in ( - self.env.context) and self.product_id and ( - self.location_id) and self.location_dest_id: + if ( + "production_id" in self.env.context + or "default_production_id" in (self.env.context) + and self.product_id + and (self.location_id) + and self.location_dest_id + ): if "production_id" in self.env.context: - production = self.env["mrp.production"].search([ - ("id", "=", self.env.context["production_id"])]) + production = self.env["mrp.production"].search( + [("id", "=", self.env.context["production_id"])] + ) if "default_production_id" in self.env.context: - production = self.env["mrp.production"].search([ - ("id", "=", self.env.context["default_production_id"])]) + production = self.env["mrp.production"].search( + [("id", "=", self.env.context["default_production_id"])] + ) moves = production.move_raw_ids + production.move_byproduct_ids move = moves.filtered( - lambda c: c.product_id == self.product_id and ( - c.location_id == self.location_id) and ( - c.location_dest_id == self.location_dest_id)) + lambda c: c.product_id == self.product_id + and (c.location_id == self.location_id) + and (c.location_dest_id == self.location_dest_id) + ) if move: self.move_id = move[:1].id @api.onchange("lot_id") def _onchange_lot_id(self): result = super(StockMoveLine, self)._onchange_lot_id() - if self.production_id and ( - self.production_id.quartering) and ( - self.lot_id): + if self.production_id and (self.production_id.quartering) and (self.lot_id): self.standard_price = self.lot_id.average_price if self.location_dest_id == self.production_id.location_src_id: lot = self.lot_id.name - if not any([line.lot_id.name == lot for line in ( - self.production_id.move_line_ids.filtered( - lambda c: c.location_id != self.location_id))]): + if not any( + [ + line.lot_id.name == lot + for line in ( + self.production_id.move_line_ids.filtered( + lambda c: c.location_id != self.location_id + ) + ) + ] + ): raise ValidationError( - _("The outgoing lot must match the incoming one.")) + _("The outgoing lot must match the incoming one.") + ) return result @api.onchange("batch_id", "location_id", "product_id") def onchange_lot_domain(self): result = super(StockMoveLine, self).onchange_lot_domain() - if self.production_id and not ( - self.production_id.quartering) and ( - self.location_id == self.production_id.location_dest_id): + if ( + self.production_id + and not (self.production_id.quartering) + and (self.location_id == self.production_id.location_dest_id) + ): lots = [] date = fields.Datetime.now() date = date - timedelta(days=5) date = date.date() - lot = self.env["stock.production.lot"].search([ - ("product_id", "=", self.product_id.id), - ("company_id", "=", self.company_id.id), - ("create_date", ">=", date)]) + lot = self.env["stock.production.lot"].search( + [ + ("product_id", "=", self.product_id.id), + ("company_id", "=", self.company_id.id), + ("create_date", ">=", date), + ] + ) for line in lot: if line.id not in lots: lots.append(line.id) - result = {"domain": {"lot_id": [('id', 'in', lots)]}} + result = {"domain": {"lot_id": [("id", "in", lots)]}} return result - @api.onchange('lot_id', 'product_id') + @api.onchange("lot_id", "product_id") def onchange_product_lot(self): - if self.product_id and ( - self.lot_id) and ( - self.product_id != self.lot_id.product_id): + if ( + self.product_id + and (self.lot_id) + and (self.product_id != self.lot_id.product_id) + ): raise ValidationError( - _("The product of the lot does not match with the " + - "product of the line.")) + _( + "The product of the lot does not match with the " + + "product of the line." + ) + ) @api.model def create(self, values): @@ -145,15 +164,15 @@ def write(self, values): result = super(StockMoveLine, self).write(values) for line in self: if not line.location_id: - values.update({ - "location_id": line.move_id.location_id.id, - "location_dest_id": line.move_id.location_dest_id.id - }) + values.update( + { + "location_id": line.move_id.location_id.id, + "location_dest_id": line.move_id.location_dest_id.id, + } + ) if "qty_done" in values: for line in self: - if line.move_id.state == "cancel" and values.get( - "qty_done" - ) != 0: + if line.move_id.state == "cancel" and values.get("qty_done") != 0: line.move_id.state = "done" line.state = "done" return result diff --git a/custom_mrp_descarga/models/stock_production_lot.py b/custom_mrp_descarga/models/stock_production_lot.py index 579ca4cef..3deacb182 100644 --- a/custom_mrp_descarga/models/stock_production_lot.py +++ b/custom_mrp_descarga/models/stock_production_lot.py @@ -10,20 +10,22 @@ class StockProductionLot(models.Model): string="Average Price", digits="MRP Price Decimal Precision", compute="_compute_average_price", - store=True) + store=True, + ) - @api.depends("move_line_ids.amount", "move_line_ids.qty_done", - "move_line_ids.state") + @api.depends( + "move_line_ids.amount", "move_line_ids.qty_done", "move_line_ids.state" + ) def _compute_average_price(self): for line in self: average_price = 0 clasified = line.move_line_ids.filtered( - lambda c: c.state == "done" and ( - c.location_dest_id.usage == "internal")) + lambda c: c.state == "done" and (c.location_dest_id.usage == "internal") + ) quartering = line.move_line_ids.filtered( - lambda c: c.production_id and c.production_id.quartering and ( - c.location_id == c.production_id.location_src_id - ) + lambda c: c.production_id + and c.production_id.quartering + and (c.location_id == c.production_id.location_src_id) ) if clasified: amount_total = sum(clasified.mapped("amount")) @@ -43,8 +45,10 @@ def action_view_move_lines(self): "name": _("Move Lines"), "view_mode": "tree,form", "res_model": "stock.move.line", - "domain": [("product_id", "=", self.product_id.id), - ("id", "in", self.move_line_ids.ids)], + "domain": [ + ("product_id", "=", self.product_id.id), + ("id", "in", self.move_line_ids.ids), + ], "type": "ir.actions.act_window", - "context": context + "context": context, } diff --git a/custom_mrp_descarga/models/stock_quant.py b/custom_mrp_descarga/models/stock_quant.py index f1211f848..22f481610 100644 --- a/custom_mrp_descarga/models/stock_quant.py +++ b/custom_mrp_descarga/models/stock_quant.py @@ -7,17 +7,17 @@ class StockQuant(models.Model): _inherit = "stock.quant" is_incubator = fields.Boolean( - string="Incubator", - related="location_id.is_incubator", store=True) + string="Incubator", related="location_id.is_incubator", store=True + ) is_integration = fields.Boolean( - string="Integration", - related="location_id.is_integration", store=True) + string="Integration", related="location_id.is_integration", store=True + ) is_reproductor = fields.Boolean( - string="Reproductor", - related="location_id.is_reproductor", store=True) + string="Reproductor", related="location_id.is_reproductor", store=True + ) is_feed_flour = fields.Boolean( - string="Feed/Flour", - related="location_id.is_feed_flour", store=True) + string="Feed/Flour", related="location_id.is_feed_flour", store=True + ) is_medicine = fields.Boolean( - string="Medicine", - related="location_id.is_medicine", store=True) + string="Medicine", related="location_id.is_medicine", store=True + ) diff --git a/custom_mrp_descarga/report/__init__.py b/custom_mrp_descarga/report/__init__.py index d404147e6..ca43a7edf 100644 --- a/custom_mrp_descarga/report/__init__.py +++ b/custom_mrp_descarga/report/__init__.py @@ -1 +1,2 @@ from . import mrp_production_summary_xlsx +from . import mrp_production_quartering_summary_xlsx diff --git a/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py b/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py new file mode 100644 index 000000000..25ec5a478 --- /dev/null +++ b/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py @@ -0,0 +1,455 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import _, models + + +class ReportMrpProductionQuarteringSummaryXlsx(models.AbstractModel): + _name = "report.mrp_production_quartering_summary_xlsx" + _inherit = "report.report_xlsx.abstract" + _description = "MRP Production Quartering Summary Report" + + def generate_xlsx_report(self, workbook, data, objects): + table_header = workbook.add_format( + { + "bold": True, + "align": "center", + "valign": "vcenter", + "fg_color": "#D7E4BC", + } + ) + summary = workbook.add_format( + { + "bold": True, + "num_format": "#,##0.00;(#,##0.00)", + } + ) + int_format = workbook.add_format( + { + "num_format": "#,##0;(#,##0)", + } + ) + two_decimal_format = workbook.add_format( + { + "num_format": "#,##0.00;(#,##0.00)", + } + ) + three_decimal_format = workbook.add_format( + { + "num_format": "#,##0.000;(#,##0.000)", + } + ) + eight_decimal_format = workbook.add_format( + { + "num_format": "#,##0.00000000;(#,##0.00000000)", + } + ) + result_int_format = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0;(#,##0)", + } + ) + result_two_decimal = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.00;(#,##0.00)", + } + ) + result_three_decimal = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.000;(#,##0.000)", + } + ) + result_summary = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.000;(#,##0.000)", + } + ) + table_header.set_text_wrap() + summary.set_text_wrap() + int_format.set_text_wrap() + two_decimal_format.set_text_wrap() + three_decimal_format.set_text_wrap() + eight_decimal_format.set_text_wrap() + result_three_decimal.set_text_wrap() + result_two_decimal.set_text_wrap() + result_summary.set_text_wrap() + table_detail_right_num = workbook.add_format( + { + "border": 1, + "align": "right", + "valign": "vcenter", + } + ) + table_detail_right_num.set_num_format("#,##0.00") + worksheet = workbook.add_worksheet("Resumen de despiece") + worksheet.write(0, 0, _("Resumen de despiece"), result_int_format) + for i in range(0, 13): + worksheet.set_column(0, i, 15) + n = 2 + m = 0 + worksheet.write(n, m, _("Entradas"), table_header) + n += 1 + worksheet.write(n, m, _("Código"), table_header) + m += 1 + worksheet.write(n, m, _("Producto"), table_header) + m += 1 + worksheet.write(n, m, _("Palets"), table_header) + m += 1 + worksheet.write(n, m, _("Envases"), table_header) + m += 1 + worksheet.write(n, m, _("Unidades"), table_header) + m += 1 + worksheet.write(n, m, _("KG bruto"), table_header) + m += 1 + worksheet.write(n, m, _("KG palets"), table_header) + m += 1 + worksheet.write(n, m, _("KG envases"), table_header) + m += 1 + worksheet.write(n, m, _("KG neto"), table_header) + m += 1 + worksheet.write(n, m, _("Coste"), table_header) + m += 1 + worksheet.write(n, m, _("Importe"), table_header) + m += 1 + worksheet.write(n, m, _("Peso medio"), table_header) + m += 1 + worksheet.write(n, m, _("% rendimiento"), table_header) + for m in range(m + 1, 13): + worksheet.write(n, m, "", table_header) + entry_movelines = objects.mapped("move_line_ids") + categories = [] + products = [] + for line in entry_movelines: + if line.product_category_id not in categories: + categories.append(line.product_category_id) + categ_lines = entry_movelines.filtered( + lambda c: c.product_category_id == line.product_category_id + ) + categ_pallet = sum(categ_lines.mapped("pallet")) + categ_container = sum(categ_lines.mapped("container")) + categ_unit = sum(categ_lines.mapped("unit")) + categ_brut = sum(categ_lines.mapped("brut")) + categ_pallet_weight = 0 + categ_container_weight = 0 + for line in categ_lines: + if ( + line.move_id + and (line.move_id.raw_material_production_id) + and line.move_id.raw_material_production_id.pallet_id + ): + categ_pallet_weight += ( + line.move_id.raw_material_production_id.pallet_id.weight + * line.pallet + ) + if ( + line.move_id + and (line.move_id.raw_material_production_id) + and line.move_id.raw_material_production_id.packaging_id + ): + categ_container_weight += ( + line.move_id.raw_material_production_id.packaging_id.weight + * line.container + ) + categ_qty_done = sum(categ_lines.mapped("qty_done")) + categ_average_weight = ( + categ_qty_done / sum(categ_lines.mapped("download_unit")) + if sum(categ_lines.mapped("download_unit")) + else 0 + ) + categ_amount = sum(categ_lines.mapped("amount")) + categt_applied_price = round( + (categ_amount / categ_qty_done) if categ_qty_done != 0 else 0, 3 + ) + for product in categ_lines: + if product.product_id not in products: + n += 1 + m = 0 + products.append(product.product_id) + product_lines = categ_lines.filtered( + lambda c: c.product_id == product.product_id + ) + product_pallet = sum(product_lines.mapped("pallet")) + product_container = sum(product_lines.mapped("container")) + product_unit = sum(product_lines.mapped("unit")) + product_brut = sum(product_lines.mapped("brut")) + product_pallet_weight = 0 + product_container_weight = 0 + for line in product_lines: + if ( + line.move_id + and line.move_id.raw_material_production_id + and line.move_id.raw_material_production_id.pallet_id + ): + product_pallet_weight += ( + line.move_id.raw_material_production_id.pallet_id.weight + * line.pallet + ) + if ( + line.move_id + and line.move_id.raw_material_production_id + and line.move_id.raw_material_production_id.packaging_id + ): + product_container_weight += ( + line.move_id.raw_material_production_id.packaging_id.weight + * line.container + ) + product_qty_done = sum(product_lines.mapped("qty_done")) + product_average_weight = ( + product_qty_done + / sum(product_lines.mapped("download_unit")) + if sum(product_lines.mapped("download_unit")) + else 0 + ) + product_amount = sum(product_lines.mapped("amount")) + product_applied_price = ( + (product_amount / product_qty_done) + if product_qty_done + else 0 + ) + worksheet.write(n, m, product.product_id.default_code) + m += 1 + worksheet.write(n, m, product.product_id.name) + m += 1 + worksheet.write(n, m, product_pallet, int_format) + m += 1 + worksheet.write(n, m, product_container, int_format) + m += 1 + worksheet.write(n, m, product_unit, int_format) + m += 1 + worksheet.write(n, m, product_brut, two_decimal_format) + m += 1 + worksheet.write(n, m, product_pallet_weight, two_decimal_format) + m += 1 + worksheet.write( + n, m, product_container_weight, two_decimal_format + ) + m += 1 + worksheet.write(n, m, product_qty_done, two_decimal_format) + m += 1 + worksheet.write( + n, m, product_applied_price, three_decimal_format + ) + m += 1 + worksheet.write( + n, m, round(product_amount, 2), two_decimal_format + ) + m += 1 + worksheet.write( + n, m, product_average_weight, two_decimal_format + ) + m += 1 + worksheet.write( + n, + m, + product_qty_done + * 100 + / sum(entry_movelines.mapped("qty_done")), + two_decimal_format, + ) + n += 1 + m = 0 + worksheet.write( + n, m, line.product_category_id.display_name, result_int_format + ) + m += 1 + worksheet.write(n, m, "", result_int_format) + m += 1 + worksheet.write(n, m, categ_pallet, result_int_format) + m += 1 + worksheet.write(n, m, categ_container, result_int_format) + m += 1 + worksheet.write(n, m, categ_unit, result_int_format) + m += 1 + worksheet.write(n, m, categ_brut, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_pallet_weight, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_container_weight, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_qty_done, result_two_decimal) + m += 1 + worksheet.write(n, m, categt_applied_price, result_three_decimal) + m += 1 + worksheet.write(n, m, categ_amount, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_average_weight, result_two_decimal) + m += 1 + worksheet.write( + n, + m, + categ_qty_done * 100 / sum(entry_movelines.mapped("qty_done")), + result_two_decimal, + ) + n += 3 + m = 0 + worksheet.write(n, m, _("Salidas"), table_header) + categories = [] + products = [] + out_movelines = objects.mapped("finished_move_line_ids") + for line in out_movelines: + if line.product_category_id not in categories: + categories.append(line.product_category_id) + categ_lines = out_movelines.filtered( + lambda c: c.product_category_id == line.product_category_id + ) + categ_pallet = sum(categ_lines.mapped("pallet")) + categ_container = sum(categ_lines.mapped("container")) + categ_brut = sum(categ_lines.mapped("brut")) + categ_pallet_weight = 0 + categ_container_weight = 0 + for line in categ_lines: + if ( + line.move_id + and line.move_id.production_id + and line.move_id.production_id.pallet_id + ): + categ_pallet_weight += ( + line.move_id.production_id.pallet_id.weight * line.pallet + ) + if ( + line.move_id + and line.move_id.production_id + and line.move_id.production_id.packaging_id + ): + categ_container_weight += ( + line.move_id.production_id.packaging_id.weight + * line.container + ) + categ_qty_done = sum(categ_lines.mapped("qty_done")) + categ_amount = sum(categ_lines.mapped("amount")) + categt_applied_price = round( + (categ_amount / categ_qty_done) if categ_qty_done != 0 else 0, 3 + ) + for product in categ_lines: + if product.product_id not in products: + n += 1 + m = 0 + products.append(product.product_id) + product_lines = categ_lines.filtered( + lambda c: c.product_id == product.product_id + ) + product_pallet = sum(product_lines.mapped("pallet")) + product_container = sum(product_lines.mapped("container")) + product_brut = sum(product_lines.mapped("brut")) + product_pallet_weight = 0 + product_container_weight = 0 + for line in product_lines: + if ( + line.move_id + and line.move_id.production_id + and line.move_id.production_id.pallet_id + ): + product_pallet_weight += ( + line.move_id.production_id.pallet_id.weight + * line.pallet + ) + if ( + line.move_id + and line.move_id.production_id + and line.move_id.production_id.packaging_id + ): + product_container_weight += ( + line.move_id.production_id.packaging_id.weight + * line.container + ) + product_qty_done = sum(product_lines.mapped("qty_done")) + product_amount = sum(product_lines.mapped("amount")) + product_applied_price = ( + (product_amount / product_qty_done) + if product_qty_done + else 0 + ) + worksheet.write(n, m, product.product_id.default_code) + m += 1 + worksheet.write(n, m, product.product_id.name) + m += 1 + worksheet.write(n, m, product_pallet) + m += 1 + worksheet.write(n, m, product_container) + m += 2 + worksheet.write(n, m, product_brut, two_decimal_format) + m += 1 + worksheet.write(n, m, product_pallet_weight, two_decimal_format) + m += 1 + worksheet.write( + n, m, product_container_weight, two_decimal_format + ) + m += 1 + worksheet.write(n, m, product_qty_done, two_decimal_format) + m += 1 + worksheet.write( + n, m, product_applied_price, three_decimal_format + ) + m += 1 + worksheet.write( + n, m, round(product_amount, 2), two_decimal_format + ) + m += 2 + worksheet.write( + n, + m, + product_qty_done + * 100 + / sum(entry_movelines.mapped("qty_done")), + two_decimal_format, + ) + n += 1 + m = 0 + worksheet.write( + n, m, line.product_category_id.display_name, result_int_format + ) + m += 1 + worksheet.write(n, m, "", result_int_format) + m += 1 + worksheet.write(n, m, categ_pallet, result_int_format) + m += 1 + worksheet.write(n, m, categ_container, result_int_format) + m += 2 + worksheet.write(n, m, categ_brut, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_pallet_weight, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_container_weight, result_two_decimal) + m += 1 + worksheet.write(n, m, categ_qty_done, result_two_decimal) + m += 1 + worksheet.write(n, m, categt_applied_price, result_three_decimal) + m += 1 + worksheet.write(n, m, categ_amount, result_two_decimal) + m += 2 + worksheet.write( + n, + m, + categ_qty_done * 100 / sum(entry_movelines.mapped("qty_done")), + result_two_decimal, + ) + n += 2 + m = 0 + worksheet.write(n, m, _("Total Entradas"), result_summary) + m += 1 + worksheet.write( + n, m, sum(entry_movelines.mapped("qty_done")), result_two_decimal + ) + n += 1 + m = 0 + worksheet.write(n, m, _("Total Salidas"), result_summary) + m += 1 + worksheet.write(n, m, sum(out_movelines.mapped("qty_done")), result_two_decimal) + n += 1 + m = 0 + worksheet.write(n, m, _("Diferencia"), result_summary) + m += 1 + worksheet.write( + n, + m, + sum(entry_movelines.mapped("qty_done")) + - sum(out_movelines.mapped("qty_done")), + result_two_decimal, + ) diff --git a/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.xml b/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.xml new file mode 100644 index 000000000..0ae1f490f --- /dev/null +++ b/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.xml @@ -0,0 +1,12 @@ + + + + Resumen de despiece XLSX + mrp.production + xlsx + mrp_production_quartering_summary_xlsx + mrp_production_quartering_summary_xlsx + + report + + diff --git a/custom_mrp_descarga/report/mrp_production_summary_xlsx.py b/custom_mrp_descarga/report/mrp_production_summary_xlsx.py index dc35c40a1..0dcebf0cd 100644 --- a/custom_mrp_descarga/report/mrp_production_summary_xlsx.py +++ b/custom_mrp_descarga/report/mrp_production_summary_xlsx.py @@ -9,48 +9,68 @@ class ReportMrpProductionsummaryXlsx(models.AbstractModel): _description = "MRP Production Summary Report" def generate_xlsx_report(self, workbook, data, objects): - table_header = workbook.add_format({ - 'bold': True, - 'align': 'center', - 'valign': 'vcenter', - 'fg_color': '#D7E4BC', - }) - summary = workbook.add_format({ - 'bold': True, - 'num_format': '#,##0.00;(#,##0.00)', - }) - int_format = workbook.add_format({ - 'num_format': '#,##0;(#,##0)', - }) - two_decimal_format = workbook.add_format({ - 'num_format': '#,##0.00;(#,##0.00)', - }) - three_decimal_format = workbook.add_format({ - 'num_format': '#,##0.000;(#,##0.000)', - }) - eight_decimal_format = workbook.add_format({ - 'num_format': '#,##0.00000000;(#,##0.00000000)', - }) - result_int_format = workbook.add_format({ - 'bold': True, - 'fg_color': '#afd095', - 'num_format': '#,##0;(#,##0)', - }) - result_two_decimal = workbook.add_format({ - 'bold': True, - 'fg_color': '#afd095', - 'num_format': '#,##0.00;(#,##0.00)', - }) - result_three_decimal = workbook.add_format({ - 'bold': True, - 'fg_color': '#afd095', - 'num_format': '#,##0.000;(#,##0.000)', - }) - result_summary = workbook.add_format({ - 'bold': True, - 'fg_color': '#afd095', - 'num_format': '#,##0.000;(#,##0.000)', - }) + table_header = workbook.add_format( + { + "bold": True, + "align": "center", + "valign": "vcenter", + "fg_color": "#D7E4BC", + } + ) + summary = workbook.add_format( + { + "bold": True, + "num_format": "#,##0.00;(#,##0.00)", + } + ) + int_format = workbook.add_format( + { + "num_format": "#,##0;(#,##0)", + } + ) + two_decimal_format = workbook.add_format( + { + "num_format": "#,##0.00;(#,##0.00)", + } + ) + three_decimal_format = workbook.add_format( + { + "num_format": "#,##0.000;(#,##0.000)", + } + ) + eight_decimal_format = workbook.add_format( + { + "num_format": "#,##0.00000000;(#,##0.00000000)", + } + ) + result_int_format = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0;(#,##0)", + } + ) + result_two_decimal = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.00;(#,##0.00)", + } + ) + result_three_decimal = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.000;(#,##0.000)", + } + ) + result_summary = workbook.add_format( + { + "bold": True, + "fg_color": "#afd095", + "num_format": "#,##0.000;(#,##0.000)", + } + ) table_header.set_text_wrap() summary.set_text_wrap() int_format.set_text_wrap() @@ -60,12 +80,14 @@ def generate_xlsx_report(self, workbook, data, objects): result_three_decimal.set_text_wrap() result_two_decimal.set_text_wrap() result_summary.set_text_wrap() - table_detail_right_num = workbook.add_format({ - 'border': 1, - 'align': 'right', - 'valign': 'vcenter', - }) - table_detail_right_num.set_num_format('#,##0.00') + table_detail_right_num = workbook.add_format( + { + "border": 1, + "align": "right", + "valign": "vcenter", + } + ) + table_detail_right_num.set_num_format("#,##0.00") worksheet = workbook.add_worksheet("Resumen de matanza") worksheet.write(0, 0, _("Resumen de matanza"), table_header) for i in range(0, 10): @@ -108,13 +130,11 @@ def generate_xlsx_report(self, workbook, data, objects): categ_unit = sum(categ_lines.mapped("unit")) categ_qty_done = sum(categ_lines.mapped("qty_done")) categ_average_weight = ( - categ_qty_done / categ_unit - ) if categ_unit else 0 + (categ_qty_done / categ_unit) if categ_unit else 0 + ) categ_amount = sum(categ_lines.mapped("amount")) categt_applied_price = round( - ( - categ_amount / categ_qty_done - ) if categ_qty_done != 0 else 0,3 + (categ_amount / categ_qty_done) if categ_qty_done != 0 else 0, 3 ) for product in categ_lines: if product.product_id not in products: @@ -124,30 +144,26 @@ def generate_xlsx_report(self, workbook, data, objects): product_lines = categ_lines.filtered( lambda c: c.product_id == product.product_id ) - product_container = sum( - product_lines.mapped("container") - ) + product_container = sum(product_lines.mapped("container")) product_unit = sum(product_lines.mapped("unit")) - product_qty_done = sum( - product_lines.mapped("qty_done") - ) + product_qty_done = sum(product_lines.mapped("qty_done")) product_percentage = ( - ( - product_qty_done * 100 / categ_qty_done - ) if categ_qty_done else 0 + (product_qty_done * 100 / categ_qty_done) + if categ_qty_done + else 0 ) product_average_weight = ( - product_qty_done / product_unit - ) if product_unit else 0 + (product_qty_done / product_unit) if product_unit else 0 + ) product_amount = sum(product_lines.mapped("amount")) product_applied_price = ( - ( - product_amount / product_qty_done - ) if product_qty_done else 0 + (product_amount / product_qty_done) + if product_qty_done + else 0 + ) + worksheet.write( + n, m, round(product_percentage, 2), two_decimal_format ) - worksheet.write(n, m, round( - product_percentage,2 - ), two_decimal_format) m += 1 worksheet.write(n, m, product.product_id.default_code) m += 1 @@ -168,12 +184,14 @@ def generate_xlsx_report(self, workbook, data, objects): ) m += 1 worksheet.write( - n, m, round(product_amount,2), two_decimal_format + n, m, round(product_amount, 2), two_decimal_format ) m += 1 worksheet.write( - n, m, round(product_qty_done / origin_qty * 100,2), - two_decimal_format + n, + m, + round(product_qty_done / origin_qty * 100, 2), + two_decimal_format, ) n += 1 m = 0 @@ -181,9 +199,7 @@ def generate_xlsx_report(self, workbook, data, objects): m += 1 worksheet.write(n, m, "", result_int_format) m += 1 - worksheet.write( - n, m, line.product_category_id.name, result_int_format - ) + worksheet.write(n, m, line.product_category_id.name, result_int_format) m += 1 worksheet.write(n, m, categ_container, result_int_format) m += 1 @@ -191,24 +207,18 @@ def generate_xlsx_report(self, workbook, data, objects): m += 1 worksheet.write(n, m, categ_qty_done, result_two_decimal) m += 1 - worksheet.write( - n, m, categ_average_weight, result_three_decimal - ) + worksheet.write(n, m, categ_average_weight, result_three_decimal) m += 1 - worksheet.write( - n, m, categt_applied_price, result_three_decimal - ) + worksheet.write(n, m, categt_applied_price, result_three_decimal) m += 1 worksheet.write(n, m, categ_amount, result_two_decimal) m += 1 worksheet.write( n, m, categ_qty_done / origin_qty * 100, result_two_decimal ) - sum_live_percentage += (categ_qty_done / origin_qty * 100) + sum_live_percentage += categ_qty_done / origin_qty * 100 different_date_planned = objects.mapped("saca_date") - different_date_planned = list( - set([d for d in different_date_planned]) - ) + different_date_planned = list({d for d in different_date_planned}) n += 1 m = 0 worksheet.write(n, m, "Partes de matanza", result_int_format) @@ -226,9 +236,7 @@ def generate_xlsx_report(self, workbook, data, objects): total_qty_done = sum(movelines.mapped("qty_done")) worksheet.write(n, m, total_qty_done, result_two_decimal) m += 1 - worksheet.write( - n, m, total_qty_done / total_unit, result_three_decimal - ) + worksheet.write(n, m, total_qty_done / total_unit, result_three_decimal) m += 1 total_amount = sum(movelines.mapped("amount")) total_average_price = total_amount / total_qty_done @@ -236,9 +244,7 @@ def generate_xlsx_report(self, workbook, data, objects): m += 1 worksheet.write(n, m, total_amount, result_two_decimal) m += 1 - worksheet.write( - n, m, total_qty_done / origin_qty * 100, result_two_decimal - ) + worksheet.write(n, m, total_qty_done / origin_qty * 100, result_two_decimal) n += 1 m = 0 worksheet.write(n, m, "Datos de granja", result_int_format) @@ -254,9 +260,7 @@ def generate_xlsx_report(self, workbook, data, objects): m += 1 worksheet.write(n, m, origin_qty, result_two_decimal) m += 1 - real_average_weight = sum( - objects.mapped("real_average_weight") - ) / len(objects) + real_average_weight = sum(objects.mapped("real_average_weight")) / len(objects) worksheet.write(n, m, real_average_weight, result_three_decimal) m += 1 purchase_price = sum(objects.mapped("purchase_price")) @@ -291,7 +295,7 @@ def generate_xlsx_report(self, workbook, data, objects): m = 0 worksheet.write(n, m, "Media personal", result_int_format) personal = objects.saca_line_id.mapped("staff") - average_personal = sum(personal)/productions + average_personal = sum(personal) / productions m += 1 worksheet.write(n, m, average_personal, result_int_format) n += 1 @@ -308,9 +312,7 @@ def generate_xlsx_report(self, workbook, data, objects): m += 1 worksheet.write(n, m, total_qty_done / days, result_two_decimal) m += 1 - worksheet.write( - n, m, total_qty_done / total_unit / days, result_three_decimal - ) + worksheet.write(n, m, total_qty_done / total_unit / days, result_three_decimal) m += 1 worksheet.write(n, m, total_average_price / days, result_three_decimal) m += 1 diff --git a/custom_mrp_descarga/report/mrp_production_summary_xlsx.xml b/custom_mrp_descarga/report/mrp_production_summary_xlsx.xml index ccfd95a09..a0a97346f 100644 --- a/custom_mrp_descarga/report/mrp_production_summary_xlsx.xml +++ b/custom_mrp_descarga/report/mrp_production_summary_xlsx.xml @@ -1,4 +1,4 @@ - + Resumen de mantanza XLSX @@ -6,7 +6,7 @@ xlsx mrp_production_summary_xlsx mrp_production_summary_xlsx - + report diff --git a/custom_mrp_descarga/views/killing_cost_view.xml b/custom_mrp_descarga/views/killing_cost_view.xml index 272c9b6d3..36b1e0aa3 100644 --- a/custom_mrp_descarga/views/killing_cost_view.xml +++ b/custom_mrp_descarga/views/killing_cost_view.xml @@ -1,6 +1,11 @@ - + diff --git a/custom_mrp_descarga/views/mrp_bom_view.xml b/custom_mrp_descarga/views/mrp_bom_view.xml index 140271a7d..4751c2bf8 100644 --- a/custom_mrp_descarga/views/mrp_bom_view.xml +++ b/custom_mrp_descarga/views/mrp_bom_view.xml @@ -2,12 +2,12 @@ mrp.bom - + - - - + + + Inputs @@ -16,13 +16,19 @@ Outputs - {'column_invisible': [('parent.quartering', '=', True)]} + {'column_invisible': [('parent.quartering', '=', True)]} - {'column_invisible': [('parent.quartering', '=', True)]} + {'column_invisible': [('parent.quartering', '=', True)]} - {'column_invisible': [('parent.quartering', '=', True)]} + {'column_invisible': [('parent.quartering', '=', True)]} @@ -43,8 +49,20 @@ [('quartering', '=', False)] - + - + diff --git a/custom_mrp_descarga/views/mrp_production_view.xml b/custom_mrp_descarga/views/mrp_production_view.xml index 84ad90c83..21e1f29a4 100644 --- a/custom_mrp_descarga/views/mrp_production_view.xml +++ b/custom_mrp_descarga/views/mrp_production_view.xml @@ -2,223 +2,499 @@ mrp.production - + - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + + + + mrp.production + + + primary + + + + + + + mrp.production - + +
-
1 - ['&', '|', ('company_id', '=', False), ('company_id', '=', company_id), '&', '|', ('product_id','=',product_id), '&', ('product_tmpl_id.product_variant_ids','=',product_id), ('product_id','=',False), ('type', '=', 'normal'), ('quartering', '=', quartering)] + ['&', '|', ('company_id', '=', False), ('company_id', '=', company_id), '&', '|', ('product_id','=',product_id), '&', ('product_tmpl_id.product_variant_ids','=',product_id), ('product_id','=',False), ('type', '=', 'normal'), ('quartering', '=', quartering)] - + - {'readonly': [('state', 'in', ('cancel', 'done'))]} + {'readonly': [('state', 'in', ('cancel', 'done'))]} - - - + + + - {'invisible': [('saca_line_id', '!=', False)]} + {'invisible': [('saca_line_id', '!=', False)]} - {'invisible': [('saca_line_id', '!=', False)]} + {'invisible': [('saca_line_id', '!=', False)]} qty_done == 0 - {'readonly': ['|', ('saca_line_id', '!=', False), ('state', 'in', ('cancel'))]} + {'readonly': ['|', ('saca_line_id', '!=', False), ('state', 'in', ('cancel'))]} - - - - + + + + - - - - - + + + + + - {'invisible':[('tolvasa', '=', True)]} + {'invisible':[('tolvasa', '=', True)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('tolvasa', '=', True)]} + {'invisible':[('tolvasa', '=', True)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - {'invisible':[('saca_line_id', '=', False)]} + {'invisible':[('saca_line_id', '=', False)]} - + - {'readonly': [('state', 'in', ('done', 'cancel'))]} + {'readonly': [('state', 'in', ('done', 'cancel'))]}
-
- - - - - - - - - - - - + + + + + + + + + + + + -
@@ -368,17 +729,23 @@ mrp.production.tree mrp.production - - - - - - - - - - - + + + + + + + + + + + @@ -388,9 +755,12 @@ mrp.production ir.actions.act_window tree,form - + + [('quartering', '=', True), ('paasa', '=', True)] - {"search_default_todo": 1, 'default_quartering': True} + {"search_default_todo": 1, 'default_quartering': True} @@ -398,15 +768,33 @@ mrp.production ir.actions.act_window tree,form - + + [('saca_line_id', '!=', False)] {"search_default_todo": 1} - + - + - +
diff --git a/custom_mrp_descarga/views/product_template_view.xml b/custom_mrp_descarga/views/product_template_view.xml index 38da68d8d..6b022aaad 100644 --- a/custom_mrp_descarga/views/product_template_view.xml +++ b/custom_mrp_descarga/views/product_template_view.xml @@ -1,12 +1,12 @@ - + product.template - + - + diff --git a/custom_mrp_descarga/views/saca_line_view.xml b/custom_mrp_descarga/views/saca_line_view.xml index ebf59a3f3..6078f1f3f 100644 --- a/custom_mrp_descarga/views/saca_line_view.xml +++ b/custom_mrp_descarga/views/saca_line_view.xml @@ -2,24 +2,39 @@ saca.line - +
-
- - - - - - - + + + + + + + diff --git a/custom_mrp_descarga/views/stock_move_line_view.xml b/custom_mrp_descarga/views/stock_move_line_view.xml index 36be96df6..ce318af88 100644 --- a/custom_mrp_descarga/views/stock_move_line_view.xml +++ b/custom_mrp_descarga/views/stock_move_line_view.xml @@ -2,60 +2,131 @@ stock.move.line - + - + - - - - + + + + stock.move.line - + - + - + stock.move.line - + sequence desc qty_done == 0 - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -64,54 +135,92 @@ stock.move.line.tree stock.move.line - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
stock.move.line - + - - + + - + - - - + + + + + stock.move.line.search.view + stock.move.line + primary + 100 + + + + + + + + Product Movements stock.move.line ir.actions.act_window tree,form - - ['|', ('move_id.raw_material_production_id', '!=', False), ('move_id.production_id', '!=', False), '|',('move_id.raw_material_production_id.quartering', '=', False), ('move_id.production_id.quartering', '=', False), '|', ('move_id.production_id.paasa', '=', True), ('move_id.raw_material_production_id.paasa', '=', True), ('state', '=', 'done')] + + + ['|', ('move_id.raw_material_production_id', '!=', False), ('move_id.production_id', '!=', False), '|',('move_id.raw_material_production_id.quartering', '=', False), ('move_id.production_id.quartering', '=', False), '|', ('move_id.production_id.paasa', '=', True), ('move_id.raw_material_production_id.paasa', '=', True), ('state', '=', 'done')] @@ -119,14 +228,32 @@ stock.move.line ir.actions.act_window tree,form - + + [('quartering', '=', True)] - {"search_default_todo": 1, "search_default_groupby_production": 1} + {"search_default_todo": 1, "search_default_groupby_production": 1} - + - + tree,form,pivot diff --git a/custom_mrp_descarga/views/stock_production_lot_view.xml b/custom_mrp_descarga/views/stock_production_lot_view.xml index 79e8d7ca8..6d926771c 100644 --- a/custom_mrp_descarga/views/stock_production_lot_view.xml +++ b/custom_mrp_descarga/views/stock_production_lot_view.xml @@ -2,13 +2,19 @@ stock.production.lot - +
-
- +
diff --git a/custom_mrp_descarga/views/stock_quant_view.xml b/custom_mrp_descarga/views/stock_quant_view.xml index 518fde14f..ac98ade64 100644 --- a/custom_mrp_descarga/views/stock_quant_view.xml +++ b/custom_mrp_descarga/views/stock_quant_view.xml @@ -2,7 +2,7 @@ stock.quant - + Total Qty Available diff --git a/custom_mrp_import_bizerba/data/product_qty_decimal_precision.xml b/custom_mrp_import_bizerba/data/product_qty_decimal_precision.xml index c581b8305..42afcf865 100644 --- a/custom_mrp_import_bizerba/data/product_qty_decimal_precision.xml +++ b/custom_mrp_import_bizerba/data/product_qty_decimal_precision.xml @@ -1,9 +1,11 @@ - - - - Bizerba Product Qty Decimal Precision - 15 - - + + + + Bizerba Product Qty Decimal Precision + 15 + - diff --git a/custom_mrp_import_bizerba/models/bizerba_import_line.py b/custom_mrp_import_bizerba/models/bizerba_import_line.py index 03a0d478d..c01067973 100644 --- a/custom_mrp_import_bizerba/models/bizerba_import_line.py +++ b/custom_mrp_import_bizerba/models/bizerba_import_line.py @@ -9,8 +9,8 @@ class BizerbaImportLine(models.Model): _description = "Wizard lines to import Bizerba lines" production_id = fields.Many2one( - string="Production", - comodel_name="mrp.production" + string="Production", + comodel_name="mrp.production", ) action = fields.Selection( string="Action", @@ -80,13 +80,15 @@ def _action_validate(self): action = "nothing" if state != "error": action = "create" - update_values.update({ - "line_uom_id": uom and uom.id, - "line_product_id": product and product.id, - "log_info": "\n".join(log_infos), - "state": state, - "action": action, - }) + update_values.update( + { + "line_uom_id": uom and uom.id, + "line_product_id": product and product.id, + "log_info": "\n".join(log_infos), + "state": state, + "action": action, + } + ) return update_values def _action_process(self): @@ -94,37 +96,30 @@ def _action_process(self): if self.action == "create": log_info = "" move_line = self.production_id.move_line_ids.filtered( - lambda c: c.product_id == self.line_product_id - ) + lambda c: c.product_id == self.line_product_id + ) if move_line: - same_product_lines = ( - self.production_id.import_line_ids.filtered( - lambda c: c.line_product_id == self.line_product_id - ) + same_product_lines = self.production_id.import_line_ids.filtered( + lambda c: c.line_product_id == self.line_product_id ) move_line[:1].write( - { - "container": len(same_product_lines), - "qty_done": sum(same_product_lines.mapped("line_product_qty")), - "product_uom_id": self.line_uom_id.id, - } - ) + { + "container": len(same_product_lines), + "qty_done": sum(same_product_lines.mapped("line_product_qty")), + "product_uom_id": self.line_uom_id.id, + } + ) for line in same_product_lines: - line.write({ - "action": "nothing", - "state": "done" - }) + line.write({"action": "nothing", "state": "done"}) move_line[:1].onchange_container() move_line[:1].onchange_unit() else: log_info = _("Error: There is no entry line with this product.") state = "error" if log_info else "done" action = "nothing" - update_values.update({ - "log_info": log_info, - "action": action, - "state": state - }) + update_values.update( + {"log_info": log_info, "action": action, "state": state} + ) return update_values def _check_product(self): diff --git a/custom_mrp_import_bizerba/models/mrp_production.py b/custom_mrp_import_bizerba/models/mrp_production.py index 8ca0e9772..b4c8aa71a 100644 --- a/custom_mrp_import_bizerba/models/mrp_production.py +++ b/custom_mrp_import_bizerba/models/mrp_production.py @@ -1,27 +1,25 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from datetime import datetime, timedelta + +import pymssql +import pytz + from odoo import _, api, fields, models -from odoo.addons.base_import_wizard.models.base_import import IMPORT_STATUS from odoo.exceptions import ValidationError -from datetime import datetime, timedelta, time -import pytz -import pymssql + +from odoo.addons.base_import_wizard.models.base_import import IMPORT_STATUS class MrpProduction(models.Model): _name = "mrp.production" - _inherit = ["mrp.production", "base.import", "mail.thread", - "mail.activity.mixin"] + _inherit = ["mrp.production", "base.import", "mail.thread", "mail.activity.mixin"] - name = fields.Char( - compute=False - ) - data = fields.Binary( - required=False - ) + name = fields.Char(compute=False) + data = fields.Binary(required=False) import_line_ids = fields.One2many( comodel_name="bizerba.import.line", - inverse_name="production_id" + inverse_name="production_id", ) import_state = fields.Selection( selection=IMPORT_STATUS, @@ -53,25 +51,26 @@ def action_conect_with_bizerba(self): self.ensure_one() self.import_line_ids.unlink() self.action_confirm() - if not self.clasified_date or not ( - self.clasified_time_start) and not ( - self.clasified_time_stop): - raise ValidationError(_( - "This classification does not have a start/end " + - "time or date.")) + if ( + not self.clasified_date + or not self.clasified_time_start + and not self.clasified_time_stop + ): + raise ValidationError( + _("This classification does not have a start/end " + "time or date.") + ) if not self.lot_producing_id: - raise ValidationError(_( - "This classification does not have the lot.")) + raise ValidationError(_("This classification does not have the lot.")) date = self.clasified_date time_start = self.clasified_time_start if time_start == 0: date = date - timedelta(days=1) - time_start = "{0:02.0f}:{1:02.0f}".format(*divmod(time_start * 60, 60)) + time_start = "{:02.0f}:{:02.0f}".format(*divmod(time_start * 60, 60)) time_start = datetime.strptime(time_start, "%H:%M") time_start = time_start - timedelta(minutes=1) time_start = time_start.time() time_stop = self.clasified_time_stop - time_stop = "{0:02.0f}:{1:02.0f}".format(*divmod(time_stop * 60, 60)) + time_stop = "{:02.0f}:{:02.0f}".format(*divmod(time_stop * 60, 60)) time_stop = datetime.strptime(time_stop, "%H:%M").time() start_date = "{} {}".format(date, time_start) start_date = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") @@ -81,12 +80,22 @@ def action_conect_with_bizerba(self): stop_date = datetime.strptime(stop_date, "%Y-%m-%d %H:%M:%S") try: conn = pymssql.connect( - server='192.168.201.3\SQLEXPRESS', - user='integracion', - password='ew#211218', - database='BCT2DB') + server=r"192.168.201.3\SQLEXPRESS", + user="integracion", + password="ew#211218", + database="BCT2DB", + ) cursor = conn.cursor() - query = "SELECT * FROM [Pesada Individual] as p WHERE LEFT(p.GT1F,4)+'-'+SUBSTRING(p.GT1F,5,2)+'-'+SUBSTRING(p.GT1F,7,2)+' '+SUBSTRING(p.GT1F,10,2)+':'+RIGHT(p.GT1F,2)+':00' BETWEEN '" +str(start_date)+"' AND '"+str(stop_date)+"'" + query = ( + "SELECT * FROM [Pesada Individual] as p " + "WHERE LEFT(p.GT1F,4)+'-'+SUBSTRING(p.GT1F,5,2)+'-'" + "+SUBSTRING(p.GT1F,7,2)+' '+SUBSTRING(p.GT1F,10,2)+" + "':'+RIGHT(p.GT1F,2)+':00' BETWEEN '" + + str(start_date) + + "' AND '" + + str(stop_date) + + "'" + ) cursor.execute(query) row = cursor.fetchone() while row: @@ -97,16 +106,16 @@ def action_conect_with_bizerba(self): line_product_qty = line_product_qty.split(";") line_uom = line_product_qty[0] line_product_qty = float(line_product_qty[2]) * pow( - 10, float(line_product_qty[1])) + 10, float(line_product_qty[1]) + ) line_chicken_code = row[12] line_date = row[13] line_date = datetime.strptime(line_date, "%Y%m%d-%H%M") log_info = "" - timezone = pytz.timezone(self._context.get('tz') or 'UTC') - line_date = timezone.localize( - line_date).astimezone(pytz.UTC) + timezone = pytz.timezone(self._context.get("tz") or "UTC") + line_date = timezone.localize(line_date).astimezone(pytz.UTC) line_date = line_date.replace(tzinfo=None) - line_data = ({ + line_data = { "import_id": self.id, "production_id": self.id, "line_lot": line_lot, @@ -116,7 +125,7 @@ def action_conect_with_bizerba(self): "line_chicken_code": line_chicken_code, "line_date": line_date, "log_info": log_info, - }) + } self.import_line_ids = [(0, 0, line_data)] row = cursor.fetchone() conn.close() @@ -125,5 +134,4 @@ def action_conect_with_bizerba(self): if self.import_line_ids: self.action_validate() except Exception: - raise ValidationError(_( - "The connection could not be established.")) + raise ValidationError(_("The connection could not be established.")) diff --git a/custom_mrp_import_bizerba/views/bizerba_import_line_view.xml b/custom_mrp_import_bizerba/views/bizerba_import_line_view.xml index 25a8e4714..ba15a7eab 100644 --- a/custom_mrp_import_bizerba/views/bizerba_import_line_view.xml +++ b/custom_mrp_import_bizerba/views/bizerba_import_line_view.xml @@ -4,16 +4,32 @@ bizerba.import.line - - - - - - - + + + + + + + - - + + @@ -24,24 +40,39 @@
-
- - - - - + + + + + - + - +
@@ -50,19 +81,24 @@ bizerba.import.line - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/custom_mrp_import_bizerba/views/mrp_production_view.xml b/custom_mrp_import_bizerba/views/mrp_production_view.xml index a71e0f3a5..7c93713a1 100644 --- a/custom_mrp_import_bizerba/views/mrp_production_view.xml +++ b/custom_mrp_import_bizerba/views/mrp_production_view.xml @@ -2,47 +2,80 @@ mrp.production - +
-
- + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + +
diff --git a/custom_mrp_import_bizerba/views/product_template_view.xml b/custom_mrp_import_bizerba/views/product_template_view.xml index bb5de47b1..3c4a21be6 100644 --- a/custom_mrp_import_bizerba/views/product_template_view.xml +++ b/custom_mrp_import_bizerba/views/product_template_view.xml @@ -5,7 +5,7 @@ - +
diff --git a/custom_mrp_line_cost/__manifest__.py b/custom_mrp_line_cost/__manifest__.py index 68179e01e..c782fd2cf 100644 --- a/custom_mrp_line_cost/__manifest__.py +++ b/custom_mrp_line_cost/__manifest__.py @@ -7,7 +7,7 @@ "category": "MRP", "license": "AGPL-3", "author": "AvanzOSC", - "website": "http://www.avanzosc.es", + "website": "https://github.com/avanzosc/mrp-addons", "depends": [ "mrp", "mrp_bom_line_coef", diff --git a/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml b/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml index 8445b96ef..575fb9931 100644 --- a/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml +++ b/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml @@ -1,13 +1,11 @@ - - - - MRP Price Decimal Precision - 5 - - - Killing Cost Decimal Precision - 3 - - + + + + MRP Price Decimal Precision + 5 + + + Killing Cost Decimal Precision + 3 + - diff --git a/custom_mrp_line_cost/models/killing_cost.py b/custom_mrp_line_cost/models/killing_cost.py index 4add677c3..86be13755 100644 --- a/custom_mrp_line_cost/models/killing_cost.py +++ b/custom_mrp_line_cost/models/killing_cost.py @@ -9,40 +9,53 @@ class KillingCost(models.Model): workcenter_id = fields.Many2one( string="Workcenter", - comodel_name="mrp.workcenter") + comodel_name="mrp.workcenter", + ) january = fields.Float( string="January", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) february = fields.Float( string="February", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) march = fields.Float( string="March", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) april = fields.Float( string="April", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) may = fields.Float( string="May", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) june = fields.Float( string="June", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) july = fields.Float( string="July", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) august = fields.Float( string="August", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) september = fields.Float( string="September", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) october = fields.Float( string="October", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) november = fields.Float( string="November", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) december = fields.Float( string="December", - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) diff --git a/custom_mrp_line_cost/models/mrp_bom.py b/custom_mrp_line_cost/models/mrp_bom.py index 7531f8b26..9ed0cd7f3 100644 --- a/custom_mrp_line_cost/models/mrp_bom.py +++ b/custom_mrp_line_cost/models/mrp_bom.py @@ -9,10 +9,12 @@ class MrpBom(models.Model): pallet_id = fields.Many2one( string="Pallet", comodel_name="product.product", - domain="[('palet', '=', True)]") + domain="[('palet', '=', True)]", + ) packaging_id = fields.Many2one( string="Packaging", - comodel_name="product.product") + comodel_name="product.product", + ) @api.model def name_search(self, name="", args=None, operator="ilike", limit=100): @@ -22,9 +24,11 @@ def name_search(self, name="", args=None, operator="ilike", limit=100): if not name: return result my_name = "%{}%".format(name) - cond = ["|", - ("product_tmpl_id", operator, my_name), - ("code", operator, my_name)] + cond = [ + "|", + ("product_tmpl_id", operator, my_name), + ("code", operator, my_name), + ] boms = self.sudo().search(cond) for bom in boms: found = False @@ -33,9 +37,10 @@ def name_search(self, name="", args=None, operator="ilike", limit=100): found = True break if not found: - result.append(( - bom.id, "{}: {}".format( - bom.code, bom.product_tmpl_id.display_name - )) + result.append( + ( + bom.id, + "{}: {}".format(bom.code, bom.product_tmpl_id.display_name), + ) ) return result diff --git a/custom_mrp_line_cost/models/mrp_bom_byproduct.py b/custom_mrp_line_cost/models/mrp_bom_byproduct.py index 2ecadd401..4e5a4b93c 100644 --- a/custom_mrp_line_cost/models/mrp_bom_byproduct.py +++ b/custom_mrp_line_cost/models/mrp_bom_byproduct.py @@ -6,10 +6,6 @@ class MrpBomByproduct(models.Model): _inherit = "mrp.bom.byproduct" - coefficient = fields.Float( - string="Coefficient") - expense_kg = fields.Boolean( - string="Production Cost", - default=False) - cost = fields.Float( - string="Fixed Price") + coefficient = fields.Float(string="Coefficient") + expense_kg = fields.Boolean(string="Production Cost", default=False) + cost = fields.Float(string="Fixed Price") diff --git a/custom_mrp_line_cost/models/mrp_production.py b/custom_mrp_line_cost/models/mrp_production.py index d1a9f38f2..11cfa193b 100644 --- a/custom_mrp_line_cost/models/mrp_production.py +++ b/custom_mrp_line_cost/models/mrp_production.py @@ -1,89 +1,92 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import _, api, exceptions, fields, models +from odoo import _, api, fields, models class MrpProduction(models.Model): _inherit = "mrp.production" - origin_qty = fields.Float( - string="Origin Kg") - dest_qty = fields.Float( - string="Dest Kg") - purchase_price = fields.Float( - string="Purchase Amount") - purchase_unit_price = fields.Float( - string="Purchase Unit Price") + origin_qty = fields.Float(string="Origin Kg") + dest_qty = fields.Float(string="Dest Kg") + purchase_price = fields.Float(string="Purchase Amount") + purchase_unit_price = fields.Float(string="Purchase Unit Price") price_difference = fields.Float( string="Price Difference", - ) + ) canal_weight = fields.Float( string="Canal Average Weight", compute="_compute_canal_weight", store=True, - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) rto_canal = fields.Float( string="Rto. Canal", compute="_compute_rto_canal", - store=True) + store=True, + ) canal_cost = fields.Float( string="Canal Cost", digits="Killing Cost Decimal Precision", compute="_compute_canal_cost", - store=True) + store=True, + ) currency_id = fields.Many2one( string="Currency", comodel_name="res.currency", - default=lambda self: self.env.company.currency_id.id) + default=lambda self: self.env.company.currency_id.id, + ) month_cost = fields.Float( string="Expense/kg", digits="Killing Cost Decimal Precision", compute="_compute_month_cost", - store=True - ) + store=True, + ) move_to_do_ids = fields.Many2many( string="Moves To Do", comodel_name="stock.move", - compute="_compute_move_to_do_ids" - ) + compute="_compute_move_to_do_ids", + ) move_line_to_do_ids = fields.Many2many( string="Move Lines To Do", comodel_name="stock.move.line", - compute="_compute_move_line_to_do_ids" - ) + compute="_compute_move_line_to_do_ids", + ) picking_to_do_ids = fields.Many2many( string="Pickings To Do", comodel_name="stock.picking", - compute="_compute_picking_to_do_ids" - ) + compute="_compute_picking_to_do_ids", + ) pallet_id = fields.Many2one( string="Pallet", comodel_name="product.product", related="bom_id.pallet_id", - store=True) + store=True, + ) packaging_id = fields.Many2one( string="Packaging", comodel_name="product.product", related="bom_id.packaging_id", - store=True) + store=True, + ) average_cost = fields.Float( string="Averga Cost", compute="_compute_average_cost", - store=True) + store=True, + ) cost = fields.Float( string="Cost", compute="_compute_cost", - store=True) + store=True, + ) entry_total_amount = fields.Float( string="Entry Total Amount", compute="_compute_entry_total_amount", - store=True) - output_total_amount = fields.Float( - string="Output Total Amount") + store=True, + ) + output_total_amount = fields.Float(string="Output Total Amount") consume_qty = fields.Float( - string="Consumed Qty", - compute="_compute_consume_qty", - store=True) + string="Consumed Qty", compute="_compute_consume_qty", store=True + ) @api.depends("move_line_ids.qty_done") def _compute_consume_qty(self): @@ -98,15 +101,15 @@ def _compute_consume_qty(self): def _compute_cost(self): for production in self: production.cost = production.purchase_price + ( - production.month_cost * production.origin_qty) + production.month_cost * production.origin_qty + ) @api.depends("move_line_ids.amount") def _compute_entry_total_amount(self): for line in self: entry_total_amount = 0 if line.move_line_ids: - entry_total_amount = sum( - self.move_line_ids.mapped("amount")) + entry_total_amount = sum(self.move_line_ids.mapped("amount")) line.entry_total_amount = entry_total_amount @api.depends("finished_move_line_ids.amount") @@ -115,106 +118,106 @@ def _compute_output_total_amount(self): output_total_amount = 0 if production.finished_move_line_ids: output_total_amount = sum( - production.finished_move_line_ids.mapped("amount")) + production.finished_move_line_ids.mapped("amount") + ) production.output_total_amount = output_total_amount - @api.depends("move_line_ids.qty_done", - "move_line_ids.amount") + @api.depends("move_line_ids.qty_done", "move_line_ids.amount") def _compute_average_cost(self): for line in self: average_cost = 0 - if sum(line.move_line_ids.filtered( - lambda c: c.location_id == line.location_src_id).mapped( - "qty_done")) != 0: + if ( + sum( + line.move_line_ids.filtered( + lambda c: c.location_id == line.location_src_id + ).mapped("qty_done") + ) + != 0 + ): average_cost = sum( line.move_line_ids.filtered( - lambda c: c.location_id == ( - line.location_src_id)).mapped("amount")) / sum( - line.move_line_ids.filtered( - lambda c: c.location_id == ( - line.location_src_id)).mapped( - "qty_done")) + lambda c: c.location_id == line.location_src_id + ).mapped("amount") + ) / sum( + line.move_line_ids.filtered( + lambda c: c.location_id == line.location_src_id + ).mapped("qty_done") + ) line.average_cost = average_cost def _compute_move_to_do_ids(self): for production in self: - domain = [("state", "not in", ("done", "cancel")), - ("date", ">=", production.date_planned_start), - ("picking_code", "=", "outgoing")] + domain = [ + ("state", "not in", ("done", "cancel")), + ("date", ">=", production.date_planned_start), + ("picking_code", "=", "outgoing"), + ] production.move_to_do_ids = self.env["stock.move"].search(domain) def _compute_move_line_to_do_ids(self): for production in self: - domain = [("state", "not in", ("done", "cancel")), - ("date", ">=", production.date_planned_start), - ("picking_code", "=", "outgoing")] - production.move_line_to_do_ids = ( - self.env["stock.move.line"].search(domain)) + domain = [ + ("state", "not in", ("done", "cancel")), + ("date", ">=", production.date_planned_start), + ("picking_code", "=", "outgoing"), + ] + production.move_line_to_do_ids = self.env["stock.move.line"].search(domain) def _compute_picking_to_do_ids(self): for production in self: - domain = [("state", "not in", ("done", "cancel")), - ("scheduled_date", ">=", production.date_planned_start), - ("picking_type_code", "=", "outgoing")] - production.picking_to_do_ids = ( - self.env["stock.picking"].search(domain)) + domain = [ + ("state", "not in", ("done", "cancel")), + ("scheduled_date", ">=", production.date_planned_start), + ("picking_type_code", "=", "outgoing"), + ] + production.picking_to_do_ids = self.env["stock.picking"].search(domain) - @api.depends("workorder_ids", "workorder_ids.workcenter_id", - "workorder_ids.workcenter_id.cost_ids.january", - "workorder_ids.workcenter_id.cost_ids.february", - "workorder_ids.workcenter_id.cost_ids.march", - "workorder_ids.workcenter_id.cost_ids.april", - "workorder_ids.workcenter_id.cost_ids.may", - "workorder_ids.workcenter_id.cost_ids.june", - "workorder_ids.workcenter_id.cost_ids.july", - "workorder_ids.workcenter_id.cost_ids.august", - "workorder_ids.workcenter_id.cost_ids.september", - "workorder_ids.workcenter_id.cost_ids.october", - "workorder_ids.workcenter_id.cost_ids.november", - "workorder_ids.workcenter_id.cost_ids.december", - "date_planned_start") + @api.depends( + "workorder_ids", + "workorder_ids.workcenter_id", + "workorder_ids.workcenter_id.cost_ids.january", + "workorder_ids.workcenter_id.cost_ids.february", + "workorder_ids.workcenter_id.cost_ids.march", + "workorder_ids.workcenter_id.cost_ids.april", + "workorder_ids.workcenter_id.cost_ids.may", + "workorder_ids.workcenter_id.cost_ids.june", + "workorder_ids.workcenter_id.cost_ids.july", + "workorder_ids.workcenter_id.cost_ids.august", + "workorder_ids.workcenter_id.cost_ids.september", + "workorder_ids.workcenter_id.cost_ids.october", + "workorder_ids.workcenter_id.cost_ids.november", + "workorder_ids.workcenter_id.cost_ids.december", + "date_planned_start", + ) def _compute_month_cost(self): for line in self: month_cost = 0 if line.date_planned_start and line.workorder_ids: month = line.date_planned_start.month if month == 1: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.january) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.january if month == 2: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.february) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.february if month == 3: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.march) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.march if month == 4: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.april) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.april if month == 5: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.may) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.may if month == 6: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.june) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.june if month == 7: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.july) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.july if month == 8: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.august) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.august if month == 9: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.september - ) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.september if month == 10: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.october) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.october if month == 11: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.november) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.november if month == 12: - month_cost = ( - line.workorder_ids[:1].workcenter_id.cost_ids.december) + month_cost = line.workorder_ids[:1].workcenter_id.cost_ids.december line.month_cost = month_cost def button_mark_done(self): @@ -227,102 +230,106 @@ def button_calculate_costs(self): for production in self: qty = [] lots = [] - if production.is_deconstruction and ( - production.move_line_ids): + if production.is_deconstruction and (production.move_line_ids): for line in production.move_line_ids: line.onchange_applied_price() if not line.move_id: line.move_id = production.move_raw_ids.filtered( - lambda c: c.product_id == line.product_id)[:1].id + lambda c: c.product_id == line.product_id + )[:1].id if line.lot_id and line.lot_id not in lots: lots.append(line.lot_id) qty.append( - sum(production.move_line_ids.filtered( - lambda c: c.lot_id == line.lot_id).mapped( - "qty_done"))) + sum( + production.move_line_ids.filtered( + lambda c: c.lot_id == line.lot_id + ).mapped("qty_done") + ) + ) i = qty.index(max(qty)) max_lot = lots[i] max_qty = qty[i] if max_lot and max_qty: lot_lines = production.move_line_ids.filtered( - lambda c: c.lot_id == max_lot) - amount = ( - production.cost - production.entry_total_amount - ) + sum(lot_lines.mapped("amount")) + lambda c: c.lot_id == max_lot + ) + amount = (production.cost - production.entry_total_amount) + sum( + lot_lines.mapped("amount") + ) price = amount / max_qty for max_line in lot_lines: max_line.applied_price = price max_line.onchange_applied_price() production._compute_entry_total_amount() - elif not production.is_deconstruction and ( - production.average_cost) and ( - production.finished_move_line_ids): + elif ( + not production.is_deconstruction + and production.average_cost + and production.finished_move_line_ids + ): for line in production.finished_move_line_ids: line.applied_price = line.base_price line.standard_price = line.applied_price - dif = (( - production.average_cost + production.month_cost - ) * production.consume_qty) - sum( - production.finished_move_line_ids.mapped("amount") - ) + dif = ( + (production.average_cost + production.month_cost) + * production.consume_qty + ) - sum(production.finished_move_line_ids.mapped("amount")) if dif != 0: for line in production.finished_move_line_ids: if line.lot_id and line.lot_id not in lots: lots.append(line.lot_id) qty.append( - sum(production.finished_move_line_ids.filtered( - lambda c: c.lot_id == line.lot_id).mapped( - "qty_done"))) + sum( + production.finished_move_line_ids.filtered( + lambda c: c.lot_id == line.lot_id + ).mapped("qty_done") + ) + ) i = qty.index(max(qty)) if i: max_lot = lots[i] max_qty = qty[i] if max_lot and max_qty: - lot_lines = ( - production.finished_move_line_ids.filtered( - lambda c: c.lot_id == max_lot)) + lot_lines = production.finished_move_line_ids.filtered( + lambda c: c.lot_id == max_lot + ) amount = dif + sum(lot_lines.mapped("amount")) price = amount / max_qty for max_line in lot_lines: max_line.applied_price = price max_line.onchange_applied_price() - @api.depends("move_line_ids.canal", - "move_line_ids.qty_done") + @api.depends("move_line_ids.canal", "move_line_ids.qty_done") def _compute_canal_weight(self): for line in self: canal_weight = 0 - canal_lines = line.move_line_ids.filtered( - lambda c: c.canal is True) + canal_lines = line.move_line_ids.filtered(lambda c: c.canal is True) canal_weight = sum(canal_lines.mapped("qty_done")) canal_unit = sum(canal_lines.mapped("unit")) if canal_unit != 0: canal_weight = canal_weight / canal_unit line.canal_weight = canal_weight - @api.depends("move_line_ids.canal", - "move_line_ids.percentage") + @api.depends("move_line_ids.canal", "move_line_ids.percentage") def _compute_rto_canal(self): for line in self: rto_canal = 0 - canal_lines = line.move_line_ids.filtered( - lambda c: c.canal is True) + canal_lines = line.move_line_ids.filtered(lambda c: c.canal is True) if canal_lines: rto_canal = sum(canal_lines.mapped("percentage")) line.rto_canal = rto_canal - @api.depends("move_line_ids.canal", - "move_line_ids.qty_done", "move_line_ids.amount") + @api.depends( + "move_line_ids.canal", "move_line_ids.qty_done", "move_line_ids.amount" + ) def _compute_canal_cost(self): for line in self: canal_cost = 0 if line.move_line_ids: - canal_lines = line.move_line_ids.filtered( - lambda c: c.canal is True) + canal_lines = line.move_line_ids.filtered(lambda c: c.canal is True) if canal_lines and sum(canal_lines.mapped("weight")) != 0: - canal_cost = sum( - canal_lines.mapped("amount"))/sum( - canal_lines.mapped("qty_done")) + canal_cost = sum(canal_lines.mapped("amount")) / sum( + canal_lines.mapped("qty_done") + ) line.canal_cost = canal_cost def action_view_move_to_do(self): @@ -333,7 +340,7 @@ def action_view_move_to_do(self): "res_model": "stock.move", "domain": [("id", "in", self.move_to_do_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } def action_view_move_line_to_do(self): @@ -344,7 +351,7 @@ def action_view_move_line_to_do(self): "res_model": "stock.move.line", "domain": [("id", "in", self.move_line_to_do_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } def action_view_picking_to_do(self): @@ -355,18 +362,20 @@ def action_view_picking_to_do(self): "res_model": "stock.picking", "domain": [("id", "in", self.picking_to_do_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } def action_view_finished_move_line_ids(self): context = self.env.context.copy() - context.update({ - "default_production_id": self.id, - "default_location_id": self.production_location_id.id, - "default_location_dest_id": self.location_dest_id.id, - "default_company_id": self.company_id.id, - "company_id": self.company_id.id, - }) + context.update( + { + "default_production_id": self.id, + "default_location_id": self.production_location_id.id, + "default_location_dest_id": self.location_dest_id.id, + "default_company_id": self.company_id.id, + "company_id": self.company_id.id, + } + ) return { "name": _("Outputs"), "view_mode": "tree", @@ -376,19 +385,21 @@ def action_view_finished_move_line_ids(self): "res_model": "stock.move.line", "domain": [("id", "in", self.finished_move_line_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } def action_view_move_line_ids(self): context = self.env.context.copy() - context.update({ - "production_id": self.id, - "default_production_id": self.id, - "location_id": self.location_src_id.id, - "location_dest_id": self.production_location_id.id, - "company_id": self.company_id.id, - "default_company_id": self.company_id.id, - }) + context.update( + { + "production_id": self.id, + "default_production_id": self.id, + "location_id": self.location_src_id.id, + "location_dest_id": self.production_location_id.id, + "company_id": self.company_id.id, + "default_company_id": self.company_id.id, + } + ) return { "name": _("Entries"), "view_mode": "tree", @@ -398,5 +409,5 @@ def action_view_move_line_ids(self): "res_model": "stock.move.line", "domain": [("id", "in", self.move_line_ids.ids)], "type": "ir.actions.act_window", - "context": context + "context": context, } diff --git a/custom_mrp_line_cost/models/mrp_workcenter.py b/custom_mrp_line_cost/models/mrp_workcenter.py index 0bace4bd1..a0012755a 100644 --- a/custom_mrp_line_cost/models/mrp_workcenter.py +++ b/custom_mrp_line_cost/models/mrp_workcenter.py @@ -9,4 +9,5 @@ class MrpWorkcenter(models.Model): cost_ids = fields.One2many( string="Workcenter Costs", comodel_name="killing.cost", - inverse_name="workcenter_id") + inverse_name="workcenter_id", + ) diff --git a/custom_mrp_line_cost/models/product_template.py b/custom_mrp_line_cost/models/product_template.py index 814f87d90..7f84e3f7e 100644 --- a/custom_mrp_line_cost/models/product_template.py +++ b/custom_mrp_line_cost/models/product_template.py @@ -8,6 +8,4 @@ class ProductTemplate(models.Model): canal = fields.Boolean(string="Canal", default=False) unit_container = fields.Integer(string="Unit/Container") - palet = fields.Boolean( - string="Is Palet", - default=False) + palet = fields.Boolean(string="Is Palet", default=False) diff --git a/custom_mrp_line_cost/models/stock_move_line.py b/custom_mrp_line_cost/models/stock_move_line.py index 594eed5bd..a54ab0b4a 100644 --- a/custom_mrp_line_cost/models/stock_move_line.py +++ b/custom_mrp_line_cost/models/stock_move_line.py @@ -9,8 +9,11 @@ class StockMoveLine(models.Model): def _default_pallet_id(self): if "default_production_id" in self.env.context: - result = self.env["mrp.production"].browse( - self.env.context.get("default_production_id")).pallet_id.id + result = ( + self.env["mrp.production"] + .browse(self.env.context.get("default_production_id")) + .pallet_id.id + ) else: result = False return result @@ -20,103 +23,149 @@ def _default_pallet_id(self): product_unit_container = fields.Integer( string="Product Unit/Container", related="product_id.unit_container", - store=True) + store=True, + ) unit_container = fields.Float( - string="Unit/Container") + string="Unit/Container", + ) weight = fields.Float( string="Weight", compute="_compute_weight", store=True, - digits="Killing Cost Decimal Precision") + digits="Killing Cost Decimal Precision", + ) percentage = fields.Float( string="%", compute="_compute_percentage", store=True, - digits="MRP Price Decimal Precision") + digits="MRP Price Decimal Precision", + ) base_price = fields.Float( string="Base Price", digits="MRP Price Decimal Precision", compute="_compute_base_price", - store=True) + store=True, + ) applied_price = fields.Float( string="Applied Price", - digits="MRP Price Decimal Precision") + digits="MRP Price Decimal Precision", + ) expense_kg = fields.Boolean( string="Cost/Kgm", compute="_compute_expense_kg", - store=True) + store=True, + ) canal = fields.Boolean( string="Canal", related="product_id.canal", - store=True) + store=True, + ) brut = fields.Float( - string="Brut") + string="Brut", + ) pallet = fields.Integer( - string="Pallet Qty") + string="Pallet Qty", + ) month_cost = fields.Float( string="Month Cost", compute="_compute_month_cost", - store=True) + store=True, + ) pallet_id = fields.Many2one( string="Pallet", comodel_name="product.product", default=_default_pallet_id, - domain="[('palet', '=', True)]") + domain="[('palet', '=', True)]", + ) - @api.depends("production_id", "production_id.date_planned_start", - "move_id", "move_id.bom_line_id", - "move_id.bom_line_id.operation_id", - "move_id.bom_line_id.operation_id.workcenter_id", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.january", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.february", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.march", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.april", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.may", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.june", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.july", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.august", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.september", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.october", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.november", - "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.december" - ) + @api.depends( + "production_id", + "production_id.date_planned_start", + "move_id", + "move_id.bom_line_id", + "move_id.bom_line_id.operation_id", + "move_id.bom_line_id.operation_id.workcenter_id", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.january", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.february", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.march", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.april", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.may", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.june", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.july", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.august", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.september", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.october", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.november", + "move_id.bom_line_id.operation_id.workcenter_id.cost_ids.december", + ) def _compute_month_cost(self): for line in self: month_cost = 0 - if line.production_id.date_planned_start and line.move_id and ( - line.move_id.byproduct_id) and ( - line.move_id.byproduct_id.operation_id): + if ( + line.production_id.date_planned_start + and line.move_id + and line.move_id.byproduct_id + and line.move_id.byproduct_id.operation_id + ): month = line.production_id.date_planned_start.month if month == 1: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.january + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.january + ) if month == 2: - month_cost= line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.february + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.february + ) if month == 3: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.march + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.march + ) if month == 4: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.april + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.april + ) if month == 5: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.may + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.may + ) if month == 6: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.june + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.june + ) if month == 7: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.july + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.july + ) if month == 8: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.august + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.august + ) if month == 9: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.september + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.september + ) if month == 10: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.october + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.october + ) if month == 11: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.november + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.november + ) if month == 12: - month_cost = line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.december + month_cost = ( + line.move_id.byproduct_id.operation_id.workcenter_id.cost_ids.december + ) line.month_cost = month_cost - @api.depends("move_id", "move_id.bom_line_id", "move_id.byproduct_id", - "move_id.bom_line_id.expense_kg", - "move_id.byproduct_id.expense_kg") + @api.depends( + "move_id", + "move_id.bom_line_id", + "move_id.byproduct_id", + "move_id.bom_line_id.expense_kg", + "move_id.byproduct_id.expense_kg", + ) def _compute_expense_kg(self): for line in self: expense_kg = 0 @@ -126,43 +175,48 @@ def _compute_expense_kg(self): expense_kg = line.move_id.byproduct_id.expense_kg line.expense_kg = expense_kg - @api.depends("production_id.purchase_unit_price", - "production_id.average_cost", - "production_id.month_cost", - "production_id.is_deconstruction") + @api.depends( + "production_id.purchase_unit_price", + "production_id.average_cost", + "production_id.month_cost", + "production_id.is_deconstruction", + ) def _compute_base_price(self): for line in self: cost = 0 if line.production_id and not line.production_id.date_planned_start: - raise ValidationError( - _("You must introduce the planned date.")) + raise ValidationError(_("You must introduce the planned date.")) else: - if line.production_id and ( - line.move_id.bom_line_id) and ( - line.production_id.is_deconstruction): + if ( + line.production_id + and line.move_id.bom_line_id + and line.production_id.is_deconstruction + ): cost = line.move_id.bom_line_id.cost if line.expense_kg: cost = ( - line.production_id.month_cost + ( - line.production_id.purchase_unit_price)) * ( - line.move_id.bom_line_id.coefficient) + line.production_id.month_cost + + line.production_id.purchase_unit_price + ) * line.move_id.bom_line_id.coefficient elif line.production_id and line.move_id.byproduct_id: cost = line.move_id.byproduct_id.cost if line.expense_kg: - entry_same_lots = ( - line.production_id.move_line_ids.filtered( - lambda c: c.lot_id.name == line.lot_id.name - ) - ) - if not entry_same_lots or sum(entry_same_lots.mapped("qty_done")) == 0: + entry_same_lots = line.production_id.move_line_ids.filtered( + lambda c: c.lot_id.name == line.lot_id.name + ) + if ( + not entry_same_lots + or sum(entry_same_lots.mapped("qty_done")) == 0 + ): cost = 0 else: - entry_cost = sum( - entry_same_lots.mapped("amount") - )/sum(entry_same_lots.mapped("qty_done")) + entry_cost = sum(entry_same_lots.mapped("amount")) / sum( + entry_same_lots.mapped("qty_done") + ) cost = ( - line.month_cost + entry_cost - ) * (line.move_id.byproduct_id.coefficient) + line.month_cost + + entry_cost * line.move_id.byproduct_id.coefficient + ) line.base_price = cost if not line.applied_price: line.applied_price = cost @@ -182,16 +236,17 @@ def _compute_percentage(self): for line in self: percentage = 0 if line.production_id.origin_qty != 0: - percentage = ( - line.qty_done * 100 / line.production_id.origin_qty) + percentage = line.qty_done * 100 / line.production_id.origin_qty line.percentage = percentage @api.onchange("brut", "pallet", "container", "pallet_id") def onchange_brut(self): if self.brut: - self.qty_done = self.brut - ( - self.pallet * self.pallet_id.weight) - ( - self.container * self.production_id.packaging_id.weight) + self.qty_done = ( + self.brut + - (self.pallet * self.pallet_id.weight) + - (self.container * self.production_id.packaging_id.weight) + ) @api.onchange("container") def onchange_container(self): diff --git a/custom_mrp_line_cost/views/killing_cost_view.xml b/custom_mrp_line_cost/views/killing_cost_view.xml index 107c25c45..cf9c4b06e 100644 --- a/custom_mrp_line_cost/views/killing_cost_view.xml +++ b/custom_mrp_line_cost/views/killing_cost_view.xml @@ -1,24 +1,23 @@ - - + killing.cost.tree killing.cost - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -30,9 +29,18 @@ tree
- + - +
diff --git a/custom_mrp_line_cost/views/mrp_bom_view.xml b/custom_mrp_line_cost/views/mrp_bom_view.xml index 0934f652a..7b088977e 100644 --- a/custom_mrp_line_cost/views/mrp_bom_view.xml +++ b/custom_mrp_line_cost/views/mrp_bom_view.xml @@ -2,16 +2,19 @@ mrp.bom - + - - + + - - - - + + + + diff --git a/custom_mrp_line_cost/views/mrp_production_view.xml b/custom_mrp_line_cost/views/mrp_production_view.xml index 1540c6828..3b6d78534 100644 --- a/custom_mrp_line_cost/views/mrp_production_view.xml +++ b/custom_mrp_line_cost/views/mrp_production_view.xml @@ -2,60 +2,159 @@ mrp.production - +
-
-
-
diff --git a/custom_mrp_line_cost/views/mrp_routing_workcenter_view.xml b/custom_mrp_line_cost/views/mrp_routing_workcenter_view.xml index 1f1f91836..e01ac0ed7 100644 --- a/custom_mrp_line_cost/views/mrp_routing_workcenter_view.xml +++ b/custom_mrp_line_cost/views/mrp_routing_workcenter_view.xml @@ -2,7 +2,7 @@ mrp.routing.workcenter - + hide diff --git a/custom_mrp_line_cost/views/mrp_workcenter_view.xml b/custom_mrp_line_cost/views/mrp_workcenter_view.xml index 84b9b8b75..066f5c471 100644 --- a/custom_mrp_line_cost/views/mrp_workcenter_view.xml +++ b/custom_mrp_line_cost/views/mrp_workcenter_view.xml @@ -2,25 +2,25 @@ mrp.workcenter - + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/custom_mrp_line_cost/views/mrp_workorder_view.xml b/custom_mrp_line_cost/views/mrp_workorder_view.xml index 387125791..9352ffa3d 100644 --- a/custom_mrp_line_cost/views/mrp_workorder_view.xml +++ b/custom_mrp_line_cost/views/mrp_workorder_view.xml @@ -2,7 +2,10 @@ mrp.workorder - + hide diff --git a/custom_mrp_line_cost/views/product_template_view.xml b/custom_mrp_line_cost/views/product_template_view.xml index afff214da..cb19a7d9d 100644 --- a/custom_mrp_line_cost/views/product_template_view.xml +++ b/custom_mrp_line_cost/views/product_template_view.xml @@ -2,12 +2,12 @@ product.template - + - - - + + + diff --git a/custom_mrp_line_cost/views/stock_move_line_view.xml b/custom_mrp_line_cost/views/stock_move_line_view.xml index 3160db9fc..e1138e941 100644 --- a/custom_mrp_line_cost/views/stock_move_line_view.xml +++ b/custom_mrp_line_cost/views/stock_move_line_view.xml @@ -2,10 +2,10 @@ stock.move.line - + - + @@ -14,22 +14,67 @@ stock.move.line.tree.view stock.move.line - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -38,27 +83,68 @@ stock.move.line.tree.view stock.move.line - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/mrp_bom_category/models/mrp_bom_category.py b/mrp_bom_category/models/mrp_bom_category.py index 63a0d8f15..cd5241f40 100644 --- a/mrp_bom_category/models/mrp_bom_category.py +++ b/mrp_bom_category/models/mrp_bom_category.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import fields, models - + class MrpBomCategory(models.Model): _name = "mrp.bom.category" @@ -15,7 +15,8 @@ class MrpBomCategory(models.Model): ) sequence_id = fields.Many2one( string="Sequence", - comodel_name="ir.sequence") + comodel_name="ir.sequence", + ) _sql_constraints = [ ("name_unique", "unique(name)", "Category name already exists"), diff --git a/mrp_bom_category/models/mrp_production.py b/mrp_bom_category/models/mrp_production.py index 420c14b09..4dbcf969b 100644 --- a/mrp_bom_category/models/mrp_production.py +++ b/mrp_bom_category/models/mrp_production.py @@ -10,9 +10,8 @@ class MrpProduction(models.Model): @api.model def create(self, values): if "bom_id" in values: - bom = self.env["mrp.bom"].search( - [('id', '=', values["bom_id"])], limit=1) + bom = self.env["mrp.bom"].search([("id", "=", values["bom_id"])], limit=1) if bom and bom.category_id and bom.category_id.sequence_id: - values['name'] = bom.category_id.sequence_id.next_by_id() + values["name"] = bom.category_id.sequence_id.next_by_id() production = super(MrpProduction, self).create(values) return production diff --git a/mrp_bom_category/views/mrp_bom_category_views.xml b/mrp_bom_category/views/mrp_bom_category_views.xml index 3c3458b56..838af4694 100644 --- a/mrp_bom_category/views/mrp_bom_category_views.xml +++ b/mrp_bom_category/views/mrp_bom_category_views.xml @@ -1,11 +1,11 @@ - + mrp.bom.category - - + + @@ -16,8 +16,8 @@
- - + +
@@ -40,9 +40,11 @@ mrp.bom.category
- +
diff --git a/mrp_bom_category/views/mrp_bom_views.xml b/mrp_bom_category/views/mrp_bom_views.xml index 9fb2e76a2..f7d641596 100644 --- a/mrp_bom_category/views/mrp_bom_views.xml +++ b/mrp_bom_category/views/mrp_bom_views.xml @@ -31,10 +31,18 @@ - - + +
diff --git a/mrp_bom_import/models/mrp_bom_import.py b/mrp_bom_import/models/mrp_bom_import.py index 2a19d4943..da65cf621 100644 --- a/mrp_bom_import/models/mrp_bom_import.py +++ b/mrp_bom_import/models/mrp_bom_import.py @@ -31,6 +31,7 @@ def check_number(number): except ValueError: return False + def convert2str(value): if isinstance(value, float) or isinstance(value, int): new_value = str(value).strip() @@ -98,7 +99,8 @@ class MrpBomImport(models.Model): ) product_found_by_code = fields.Boolean( string="Product Found By Code", - default=False) + default=False, + ) def _get_import_lines(self): return self.mapped("bom_line_import_ids") @@ -221,13 +223,11 @@ def _get_line_values(self, row_values): return values def action_validate_lines(self): - lines = (self._get_import_lines()).filtered( - lambda x: x.state not in ("done")) + lines = self._get_import_lines().filtered(lambda x: x.state not in ("done")) lines.action_validate_lines() def action_process_lines(self): - lines = (self._get_import_lines()).filtered( - lambda x: x.state == "pass") + lines = self._get_import_lines().filtered(lambda x: x.state == "pass") lines.action_process_lines() def button_open_bom_component_import_line(self): @@ -269,14 +269,16 @@ class MrpBomLineImport(models.Model): bom_name = fields.Char(string="BoM Name") bom_product_id = fields.Many2one( string="Parent Product", - comodel_name="product.product") + comodel_name="product.product", + ) bom_id = fields.Many2one( comodel_name="mrp.bom", string="BoM", ) bom_line_id = fields.Many2one( string="BoM Line", - comodel_name="mrp.bom.line") + comodel_name="mrp.bom.line", + ) log_info = fields.Text(string="Log Info") state = fields.Selection( selection=IMPORT_STATUS, @@ -286,7 +288,8 @@ class MrpBomLineImport(models.Model): parent_product_bom_count = fields.Integer( string="Parent Bom Qty", related="bom_product_id.bom_count", - store=True) + store=True, + ) parent_qty = fields.Float(string="Parent Quantity") def _check_product(self): @@ -360,11 +363,14 @@ def action_validate_lines(self): def _create_bom(self): self.ensure_one() - bom = self.env["mrp.bom"].create({ - "product_tmpl_id": self.bom_product_id.product_tmpl_id.id, - "code": self.bom_ref, - "product_qty": self.parent_qty, - "product_uom_id": self.bom_product_id.uom_id.id}) + bom = self.env["mrp.bom"].create( + { + "product_tmpl_id": self.bom_product_id.product_tmpl_id.id, + "code": self.bom_ref, + "product_qty": self.parent_qty, + "product_uom_id": self.bom_product_id.uom_id.id, + } + ) return bom def generate_bom_line_values(self): @@ -372,7 +378,8 @@ def generate_bom_line_values(self): bom_line = { "product_id": self.product_id.id, "product_qty": self.quantity, - "product_uom_id": self.product_id.uom_id.id} + "product_uom_id": self.product_id.uom_id.id, + } return bom_line def action_process_lines(self): @@ -380,25 +387,34 @@ def action_process_lines(self): for line in self.filtered(lambda x: x.state == "pass"): log_info = "" bom = False - if not line.bom_id and line.bom_product_id and line.bom_product_id not in bom_product: + if ( + not line.bom_id + and line.bom_product_id + and line.bom_product_id not in bom_product + ): state = "2validate" same_parent = line.bom_import_id.bom_line_import_ids.filtered( - lambda c: c.bom_product_id == line.bom_product_id) + lambda c: c.bom_product_id == line.bom_product_id + ) if any([state.state == "error" for state in same_parent]): - log_info = _("Error: There is another line with the " + - "same parent product errors.") + log_info = _( + "Error: There is another line with the same parent product" + " errors." + ) state = "error" else: bom = line._create_bom() - for l in same_parent: - bom_line_values = l.generate_bom_line_values() + for ln in same_parent: + bom_line_values = ln.generate_bom_line_values() bom_line_values.update({"bom_id": bom.id}) - bom_line = self.env["mrp.bom.line"].create( - bom_line_values) - l.write({ - "bom_id": bom.id, - "bom_line_id": bom_line.id, - "state": "done"}) + bom_line = self.env["mrp.bom.line"].create(bom_line_values) + ln.write( + { + "bom_id": bom.id, + "bom_line_id": bom_line.id, + "state": "done", + } + ) state = "done" line.write( { diff --git a/mrp_bom_import/views/mrp_bom_import_line_view.xml b/mrp_bom_import/views/mrp_bom_import_line_view.xml index 0edbab6d2..05b98f553 100644 --- a/mrp_bom_import/views/mrp_bom_import_line_view.xml +++ b/mrp_bom_import/views/mrp_bom_import_line_view.xml @@ -4,43 +4,43 @@ mrp.bom.line.import - - + + + name="pending" + string="Pending" + domain="[('state', '!=', 'done')]" + /> + name="finished" + string="Done" + domain="[('state', '=', 'done')]" + /> + name="errored" + string="Error" + domain="[('state', '=', 'error')]" + /> + string="Status" + name="state_group" + domain="[]" + context="{'group_by':'state'}" + /> - + string="Log Info" + name="log_info_group" + domain="[]" + context="{'group_by':'log_info'}" + /> + + string="BoM Product" + name="bom_product" + domain="[]" + context="{'group_by':'bom_product_id'}" + /> diff --git a/mrp_bom_import/views/mrp_bom_import_view.xml b/mrp_bom_import/views/mrp_bom_import_view.xml index 47f5a6a0a..b2b6c9010 100644 --- a/mrp_bom_import/views/mrp_bom_import_view.xml +++ b/mrp_bom_import/views/mrp_bom_import_view.xml @@ -84,12 +84,12 @@ - + - + @@ -134,7 +134,6 @@ mrp.bom.line.import - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/mrp_bom_import/views/mrp_bom_line_view.xml b/mrp_bom_import/views/mrp_bom_line_view.xml index 6748197a9..11bde0593 100644 --- a/mrp_bom_import/views/mrp_bom_line_view.xml +++ b/mrp_bom_import/views/mrp_bom_line_view.xml @@ -6,10 +6,10 @@ mrp.bom.line - - - - + + + + @@ -19,7 +19,7 @@ ir.actions.act_window mrp.bom.line tree,form - +
diff --git a/mrp_bom_import_position/models/mrp_bom_import.py b/mrp_bom_import_position/models/mrp_bom_import.py index 96b421566..3ae63de7f 100644 --- a/mrp_bom_import_position/models/mrp_bom_import.py +++ b/mrp_bom_import_position/models/mrp_bom_import.py @@ -14,8 +14,7 @@ def _get_line_values(self, row_values): if values: values.update( { - "line_position": convert2str( - row_values.get("Position", "")), + "line_position": convert2str(row_values.get("Position", "")), } ) return values diff --git a/mrp_bom_import_position/views/mrp_bom_import_view.xml b/mrp_bom_import_position/views/mrp_bom_import_view.xml index d0d178cd1..8e20f2953 100644 --- a/mrp_bom_import_position/views/mrp_bom_import_view.xml +++ b/mrp_bom_import_position/views/mrp_bom_import_view.xml @@ -18,7 +18,7 @@ /> - + diff --git a/mrp_bom_line_coef/__manifest__.py b/mrp_bom_line_coef/__manifest__.py index 25348931b..42ef2ef9d 100644 --- a/mrp_bom_line_coef/__manifest__.py +++ b/mrp_bom_line_coef/__manifest__.py @@ -2,8 +2,9 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "MRP BOM Line Coef", - 'version': '14.0.1.0.0', + "version": "14.0.1.0.0", "author": "Avanzosc", + "website": "https://github.com/avanzosc/mrp-addons", "category": "MRP", "depends": [ "mrp", @@ -13,5 +14,5 @@ "views/mrp_bom_view.xml", ], "license": "AGPL-3", - 'installable': True, + "installable": True, } diff --git a/mrp_bom_line_coef/data/coef_decimal_precision.xml b/mrp_bom_line_coef/data/coef_decimal_precision.xml index cc640dc58..a1e9766eb 100644 --- a/mrp_bom_line_coef/data/coef_decimal_precision.xml +++ b/mrp_bom_line_coef/data/coef_decimal_precision.xml @@ -1,9 +1,7 @@ - - - - Coef Decimal Precision - 4 - - + + + + Coef Decimal Precision + 4 + - diff --git a/mrp_bom_line_coef/models/mrp_bom_line.py b/mrp_bom_line_coef/models/mrp_bom_line.py index 48cd4f2ff..aa101b081 100644 --- a/mrp_bom_line_coef/models/mrp_bom_line.py +++ b/mrp_bom_line_coef/models/mrp_bom_line.py @@ -1,22 +1,28 @@ # Copyright 2022 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models, fields, api +from odoo import api, fields, models class MrpBomLine(models.Model): - _inherit = 'mrp.bom.line' + _inherit = "mrp.bom.line" coefficient = fields.Float( - string='Coefficient', - digits="Coef Decimal Precision") - expense_kg = fields.Boolean(string='Production Cost', default=False) + string="Coefficient", + digits="Coef Decimal Precision", + ) + expense_kg = fields.Boolean( + string="Production Cost", + default=False, + ) cost = fields.Float( - string='Fixed Cost', - digits="Coef Decimal Precision") + string="Fixed Cost", + digits="Coef Decimal Precision", + ) currency_id = fields.Many2one( - string='Currency', - comodel_name='res.currency', - default=lambda self: self.env.company.currency_id.id) + string="Currency", + comodel_name="res.currency", + default=lambda self: self.env.company.currency_id.id, + ) @api.onchange("product_id") def onchange_cost(self): diff --git a/mrp_bom_line_coef/views/mrp_bom_view.xml b/mrp_bom_line_coef/views/mrp_bom_view.xml index 6a45d3c53..cf2b435e5 100644 --- a/mrp_bom_line_coef/views/mrp_bom_view.xml +++ b/mrp_bom_line_coef/views/mrp_bom_view.xml @@ -1,15 +1,23 @@ - + mrp.bom - + - - - - - + + + + + diff --git a/mrp_bom_line_note/__manifest__.py b/mrp_bom_line_note/__manifest__.py index 8765b52dd..328bb1fad 100644 --- a/mrp_bom_line_note/__manifest__.py +++ b/mrp_bom_line_note/__manifest__.py @@ -2,16 +2,16 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "MRP BOM Line Note", - 'version': '14.0.1.0.0', + "version": "14.0.1.0.0", "author": "Avanzosc", - "website": "http://www.avanzosc.es", + "website": "https://github.com/avanzosc/mrp-addons", "category": "Product", "depends": [ - "mrp" + "mrp", ], "data": [ "views/mrp_bom_views.xml", ], "license": "AGPL-3", - 'installable': True, + "installable": True, } diff --git a/mrp_bom_line_note/models/mrp_bom_line.py b/mrp_bom_line_note/models/mrp_bom_line.py index 9a61d1489..100c36f68 100644 --- a/mrp_bom_line_note/models/mrp_bom_line.py +++ b/mrp_bom_line_note/models/mrp_bom_line.py @@ -1,9 +1,9 @@ # Copyright 2021 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import fields, models class MrpBomLine(models.Model): _inherit = "mrp.bom.line" - note = fields.Text(string='Note') + note = fields.Text(string="Note") diff --git a/mrp_bom_line_note/views/mrp_bom_views.xml b/mrp_bom_line_note/views/mrp_bom_views.xml index f91d803ac..9e1392808 100644 --- a/mrp_bom_line_note/views/mrp_bom_views.xml +++ b/mrp_bom_line_note/views/mrp_bom_views.xml @@ -1,12 +1,14 @@ - - + mrp.bom - + - - + + diff --git a/mrp_bom_reference/__manifest__.py b/mrp_bom_reference/__manifest__.py index dc6fabf6a..6d569cb58 100644 --- a/mrp_bom_reference/__manifest__.py +++ b/mrp_bom_reference/__manifest__.py @@ -2,15 +2,14 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "MRP BOM Reference", - 'version': '14.0.1.0.0', + "version": "14.0.1.0.0", "author": "Avanzosc", - "website": "http://www.avanzosc.es", + "website": "https://github.com/avanzosc/mrp-addons", "category": "MRP", "depends": [ "product_bom_revision", ], - "data": [ - ], + "data": [], "license": "AGPL-3", - 'installable': True, + "installable": True, } diff --git a/mrp_bom_reference/models/mrp_bom.py b/mrp_bom_reference/models/mrp_bom.py index 6749348f9..eb8f27a96 100644 --- a/mrp_bom_reference/models/mrp_bom.py +++ b/mrp_bom_reference/models/mrp_bom.py @@ -1,15 +1,17 @@ # Copyright 2021 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models, api +from odoo import api, models class MrpBom(models.Model): _inherit = "mrp.bom" - @api.onchange('bom_revision', 'product_tmpl_id', 'product_id') + @api.onchange("bom_revision", "product_tmpl_id", "product_id") def onchange_reference(self): - tmpl = self.product_tmpl_id.default_code if ( - self.product_tmpl_id.default_code) else '' - va = self.product_id.default_code if ( - self.product_id.default_code) else '' - self.code = u'{} {} {}'.format(va, tmpl, self.bom_revision) + tmpl = ( + self.product_tmpl_id.default_code + if self.product_tmpl_id.default_code + else "" + ) + va = self.product_id.default_code if (self.product_id.default_code) else "" + self.code = "{} {} {}".format(va, tmpl, self.bom_revision) diff --git a/mrp_bom_report_group/__manifest__.py b/mrp_bom_report_group/__manifest__.py index d699bc60d..6680210b8 100644 --- a/mrp_bom_report_group/__manifest__.py +++ b/mrp_bom_report_group/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "MRP BoM Report Group", - 'version': '14.0.1.0.0', + "version": "14.0.1.0.0", "category": "Manufacturing", "license": "AGPL-3", "author": "AvanzOSC", @@ -13,7 +13,7 @@ "data": [ "data/mrp_bom_report_group.xml", "report/mrp_bom_report.xml", - "views/mrp_bom_views.xml" + "views/mrp_bom_views.xml", ], - 'installable': True, + "installable": True, } diff --git a/mrp_bom_report_group/data/mrp_bom_report_group.xml b/mrp_bom_report_group/data/mrp_bom_report_group.xml index 457856bfb..b1a82a64a 100644 --- a/mrp_bom_report_group/data/mrp_bom_report_group.xml +++ b/mrp_bom_report_group/data/mrp_bom_report_group.xml @@ -1,9 +1,10 @@ - - - - - See costs in BoM - - - + + + + See costs in BoM + + diff --git a/mrp_bom_report_group/report/mrp_bom_report.xml b/mrp_bom_report_group/report/mrp_bom_report.xml index 767c745dd..dacfbbf2d 100644 --- a/mrp_bom_report_group/report/mrp_bom_report.xml +++ b/mrp_bom_report_group/report/mrp_bom_report.xml @@ -1,45 +1,73 @@ - + -