From c8ad695d5bc0e3f478ee31c84765ebb23c141349 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sat, 10 Aug 2019 15:27:45 +0200 Subject: [PATCH] account_bank_statement_product_dimension --- .../README.rst | 7 +++ .../__init__.py | 0 .../__manifest__.py | 23 ++++++++ .../static/src/js/abs.js | 59 +++++++++++++++++++ .../static/src/xml/account_reconciliation.xml | 15 +++++ .../views/account_move_line_views.xml | 15 +++++ .../views/account_move_views.xml | 15 +++++ .../views/assets_backend.xml | 10 ++++ 8 files changed, 144 insertions(+) create mode 100644 account_bank_statement_product_dimension/README.rst create mode 100644 account_bank_statement_product_dimension/__init__.py create mode 100644 account_bank_statement_product_dimension/__manifest__.py create mode 100644 account_bank_statement_product_dimension/static/src/js/abs.js create mode 100644 account_bank_statement_product_dimension/static/src/xml/account_reconciliation.xml create mode 100644 account_bank_statement_product_dimension/views/account_move_line_views.xml create mode 100644 account_bank_statement_product_dimension/views/account_move_views.xml create mode 100644 account_bank_statement_product_dimension/views/assets_backend.xml diff --git a/account_bank_statement_product_dimension/README.rst b/account_bank_statement_product_dimension/README.rst new file mode 100644 index 00000000..e58d8a7e --- /dev/null +++ b/account_bank_statement_product_dimension/README.rst @@ -0,0 +1,7 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +====================================================== +Add product field to the Bank Statement reconciliation +====================================================== diff --git a/account_bank_statement_product_dimension/__init__.py b/account_bank_statement_product_dimension/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/account_bank_statement_product_dimension/__manifest__.py b/account_bank_statement_product_dimension/__manifest__.py new file mode 100644 index 00000000..0dbb44fd --- /dev/null +++ b/account_bank_statement_product_dimension/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2009-2019 Noviat. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Add product field to the Bank Statement reconciliation', + 'version': '11.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Noviat', + 'website': 'http://www.noviat.com', + 'category': 'Accounting & Finance', + 'depends': [ + 'account', + ], + 'data': [ + 'views/assets_backend.xml', + 'views/account_move_views.xml', + 'views/account_move_line_views.xml', + ], + 'qweb': [ + 'static/src/xml/account_reconciliation.xml', + ], + 'installable': True, +} diff --git a/account_bank_statement_product_dimension/static/src/js/abs.js b/account_bank_statement_product_dimension/static/src/js/abs.js new file mode 100644 index 00000000..b05cf44d --- /dev/null +++ b/account_bank_statement_product_dimension/static/src/js/abs.js @@ -0,0 +1,59 @@ +/* +Copyright 2009-2019 Noviat. +License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +*/ +odoo.define('account_bank_statement_product_dimension.abs', function (require) { + "use strict"; + + var core = require('web.core'); + var relational_fields = require('web.relational_fields'); + var ReconciliationRenderer = require('account.ReconciliationRenderer'); + var ReconciliationModel = require('account.ReconciliationModel'); + var _t = core._t; + + ReconciliationModel.StatementModel.include({ + + init: function (parent, options) { + this._super.apply(this, arguments); + this.extra_field_names = ['product_id']; + this.extra_fields = [{ + relation: 'product.product', + type: 'many2one', + name: 'product_id', + }]; + this.extra_fieldInfo = { + product_id: { string: _t("Product") }, + }; + this.quickCreateFields = this.quickCreateFields.concat(this.extra_field_names); + }, + + makeRecord: function (model, fields, fieldInfo) { + var self = this; + if (model === 'account.bank.statement.line' && fields.length === 6) { + fields = fields.concat(this.extra_fields); + _.extend(fieldInfo, this.extra_fieldInfo); + }; + return this._super(model, fields, fieldInfo); + }, + + _formatToProcessReconciliation: function (line, prop) { + var result = this._super(line, prop); + if (prop.product_id) result.product_id = prop.product_id.id; + return result; + }, + + }); + + ReconciliationRenderer.LineRenderer.include({ + + _renderCreate: function (state) { + this._super(state); + var record = this.model.get(this.handleCreateRecord); + this.fields.product_id = new relational_fields.FieldMany2One(this, + 'product_id', record, { mode: 'edit' }); + this.fields.product_id.appendTo(this.$el.find('.create_product_id .o_td_field')); + }, + + }); + +}); diff --git a/account_bank_statement_product_dimension/static/src/xml/account_reconciliation.xml b/account_bank_statement_product_dimension/static/src/xml/account_reconciliation.xml new file mode 100644 index 00000000..d298f330 --- /dev/null +++ b/account_bank_statement_product_dimension/static/src/xml/account_reconciliation.xml @@ -0,0 +1,15 @@ + + + + + + + + Product + + + + + + + diff --git a/account_bank_statement_product_dimension/views/account_move_line_views.xml b/account_bank_statement_product_dimension/views/account_move_line_views.xml new file mode 100644 index 00000000..6a16b5bf --- /dev/null +++ b/account_bank_statement_product_dimension/views/account_move_line_views.xml @@ -0,0 +1,15 @@ + + + + + account.move.line.form + account.move.line + + + + + + + + + diff --git a/account_bank_statement_product_dimension/views/account_move_views.xml b/account_bank_statement_product_dimension/views/account_move_views.xml new file mode 100644 index 00000000..6ff1c5c3 --- /dev/null +++ b/account_bank_statement_product_dimension/views/account_move_views.xml @@ -0,0 +1,15 @@ + + + + + account.move.form + account.move + + + + + + + + + diff --git a/account_bank_statement_product_dimension/views/assets_backend.xml b/account_bank_statement_product_dimension/views/assets_backend.xml new file mode 100644 index 00000000..812a4f76 --- /dev/null +++ b/account_bank_statement_product_dimension/views/assets_backend.xml @@ -0,0 +1,10 @@ + + + + + +