Hello everyone,
I need your help on inheriting and extending a code on a js file for the account module.
For your reference I am using Odoo 12.
PS: I am sorry but I am unable to post images and code since some weeks ago on the forum.
The code I want to extend is from the account module and is located on the file "static/src/js/reconciliation/\reconciliation_renderer\.js\\"\ for\ the\ function\ \"_renderCreate\"\ on\ line\ \531\\.\
\
On\ this\ function\,\ starting\ from\ the\ line\ \569 we have:
account_id: {
string: _t("Account"),
domain: [['deprecated', '=', false]],
},
Here, I just need to change the domain to something else.
What I have done:
1. Defined a template in my module to add the js asset that is located under mymodule/static/src/js/custom_asset.js:
<template id="mymodule_asset_backend" name="custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/mymodule/static/src/js/custom_asset.js"></script>
</xpath>
</template>
2. Added the "xml" do the manifest file.
Now I need to add the required code to the js file but I do not know how to do it.
I know I have to do something like:
odoo.define('mymodule.ReconciliationRenderer', function (require) {
"use strict";
var FieldManagerMixin = require('web.FieldManagerMixin');
var LineRenderer = Widget.extend(FieldManagerMixin, {
_renderCreate: function () {
/* Custom code goes here */
}, });
return { LineRenderer: LineRenderer, };
});
Can you please help me write this js file?
Thank you all in advance
Best regards
PM
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hello Paulo Matos,
It's not easily Overridable. The best way to do this is to replace whole method with changed domain.
Something like:
odoo.define('mymodule.ReconciliationRenderer', function (require) {
"use strict";
var FieldManagerMixin = require('web.FieldManagerMixin');
var LineRenderer = Widget.extend(FieldManagerMixin, {
_renderCreate: function () {
// Copy whole code of _renderCreate method and Paste here. Just change your domain for account_id.
// Note: Don't call super
},
});
return { LineRenderer: LineRenderer, };
});
It will be risky to do such kind of messy code but it will works and fit to your needs.
Dear @Jigar Patel,
Thank you very much.
It worked as expected.
I had to "paste" the full content of "LineRenderer" because pasting just the "_renderCreate" function did not worked for me (when refreshing Odoo, just see a blank page on browser).
As you stated, perhaps it is not the best solution but for this specific case will do the job.
If I find any additional solution for solving this just by replacing the exact part the code I need, I will post it here.
Thank you once again
Best regards
PM
In this, what about a Widget?
@Jiral Patel hi, i'm trying to extend _onSwitchCompanyClick in switch_company_menu.js but i cant get it, Could you help me please?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Oct 24
|
670 | ||
|
0
Dec 23
|
686 | ||
|
0
Sep 23
|
1568 | ||
|
2
Mar 15
|
6668 | ||
|
1
Apr 25
|
2477 |