Skip to content

Commit

Permalink
account_bank_statement_product_dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-demeyer committed Aug 10, 2019
1 parent 7e661de commit c8ad695
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
7 changes: 7 additions & 0 deletions account_bank_statement_product_dimension/README.rst
Original file line number Diff line number Diff line change
@@ -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
======================================================
Empty file.
23 changes: 23 additions & 0 deletions account_bank_statement_product_dimension/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
59 changes: 59 additions & 0 deletions account_bank_statement_product_dimension/static/src/js/abs.js
Original file line number Diff line number Diff line change
@@ -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'));
},

});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>

<t t-extend="reconciliation.line.create">

<t t-jquery="tr[class='create_amount']" t-operation="append">
<tr class="create_product_id">
<td class="o_td_label">Product</td>
<td class="o_td_field"></td>
</tr>
</t>

</t>

</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_move_line_form" model="ir.ui.view">
<field name="name">account.move.line.form</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form"/>
<field name="arch" type="xml">
<field name="quantity" position="before">
<field name="product_id"/>
</field>
</field>
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook//field[@name='line_ids']/tree/field[@name='account_id']" position="before">
<field name="product_id"/>
</xpath>
</field>
</record>

</odoo>
10 changes: 10 additions & 0 deletions account_bank_statement_product_dimension/views/assets_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="assets_backend" name="account assets" inherit_id="account.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/account_bank_statement_product_dimension/static/src/js/abs.js"></script>
</xpath>
</template>

</odoo>

0 comments on commit c8ad695

Please sign in to comment.