odoo_partner_scrapper: get rid of broken static components, to be replaced by an action later

This commit is contained in:
Marc Durepos 2025-03-26 11:59:58 -04:00
parent 5390b6308e
commit dec2e44c09
3 changed files with 11 additions and 102 deletions

View file

@ -1,68 +0,0 @@
/** @odoo-module **/
import ListController from 'web.ListController';
import ListView from 'web.ListView';
import KanbanController from 'web.KanbanController';
import KanbanView from 'web.KanbanView';
const viewRegistry = require('web.view_registry');
const OdooScrapperListController = ListController.extend({
// buttons_template must match the t-name on the template for the button (static xml)
buttons_template: 'odoo_scrapper.list_view_buttons',
events: _.extend({}, ListController.prototype.events, {
'click .o_button_get_partner': '_onGetPartnerClick',
}),
// This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
_onGetPartnerClick: function () {
this._rpc({
model: 'res.partner',
method: 'get_odoo_partner',
args: [],
}).then(() => {
this.reload();
});
// Couldn't test this for real, but it runs the action. May need a this.reload()
},
});
export const OdooScrapperListView = ListView.extend({
config: _.extend({}, ListView.prototype.config, {
Controller: OdooScrapperListController,
}),
});
// key must match with the js_class attribute of the tree view you want to modify
viewRegistry.add('res_partner_odoo_scrapper_tree', OdooScrapperListView);
const OdooScrapperKanbanController = KanbanController.extend({
// buttons_template must match the t-name on the template for the button (static xml)
buttons_template: 'odoo_scrapper.kanban_view_buttons',
events: _.extend({}, KanbanController.prototype.events, {
'click .o_button_get_partner': '_onGetPartnerClick',
}),
// This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
_onGetPartnerClick: function () {
this._rpc({
model: 'res.partner',
method: 'get_odoo_partner',
args: [],
}).then(() => {
this.reload();
});
// Couldn't test this for real, but it runs the action. May need a this.reload()
},
});
export const OdooScrapperKanbanView = KanbanView.extend({
config: _.extend({}, KanbanView.prototype.config, {
Controller: OdooScrapperKanbanController,
}),
});
// key must match with the js_class attribute of the tree view you want to modify
viewRegistry.add('res_partner_odoo_scrapper_kanban', OdooScrapperKanbanView);

View file

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons" t-name="odoo_scrapper.list_view_buttons"> <!-- t-name must match with js controller button template -->
<t t-jquery="button.o_list_button_add" t-operation="after">
<button type="button"
class="btn btn-primary ml4 o_button_get_partner"
title="Get Odoo Partner"> Get Odoo Partner </button>
</t>
</t>
<t t-extend="KanbanView.buttons" t-name="odoo_scrapper.kanban_view_buttons">
<t t-jquery="button" t-operation="after">
<button type="button"
class="btn btn-primary ml4 o_button_get_partner"
title="Get Odoo Partner"> Get Odoo Partner </button>
</t>
</t>
</templates>

View file

@ -8,19 +8,22 @@
<field name="arch" type="xml">
<field name="company_type" position="after">
<br/>
<field name="is_odoo_user"/>Odoo User
<field name="is_odoo_partner"/>Odoo Partner
<field name="is_odoo_user"/>
Odoo User
<field name="is_odoo_partner"/>
Odoo Partner
<br/>
<div invisible="is_odoo_partner == False">
<h3><field name="odoo_partner_type"/> Partner</h3>
<h3>
<field name="odoo_partner_type"/>
Partner</h3>
</div>
</field>
<group name="container_row_2" position="after">
<group name="container_row_3">
<field name="relation_all_ids">
<list>
<field name="other_partner_id" required="True" options="{'no_create': True}"
string="Customer" domain="[['relation_all_ids.type_selection_id.id', '=', 1]]"/>
<field name="other_partner_id" required="True" options="{'no_create': True}" string="Customer" domain="[['relation_all_ids.type_selection_id.id', '=', 1]]"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="active" invisible="1"/>
@ -38,9 +41,6 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<xpath expr="//list" position="attributes">
<attribute name="js_class">res_partner_odoo_scrapper_tree</attribute>
</xpath>
<xpath expr="//list" position="inside">
<field name="is_odoo_user"/>
<field name="is_odoo_partner"/>
@ -54,20 +54,17 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="//kanban" position="attributes">
<attribute name="js_class">res_partner_odoo_scrapper_kanban</attribute>
</xpath>
<xpath expr="//kanban" position="inside">
<field name="odoo_partner_type"/>
</xpath>
<xpath expr="//div[hasclass('oe_kanban_global_click') and hasclass('o_kanban_record_has_image_fill') and hasclass('o_res_partner_kanban')]" position="attributes">
<xpath expr="//div[hasclass('o_kanban_image_fill')]" position="attributes">
<attribute name="t-attf-class">oe_kanban_global_click o_kanban_record_has_image_fill o_res_partner_kanban oe_kanban_color_#{record.color}</attribute>
</xpath>
<xpath expr="//strong[hasclass('o_kanban_record_title') and hasclass('oe_partner_heading')]" position="before">
<field name="display_name" position="before">
<strong t-if="record.odoo_partner_type.raw_value" class="o_kanban_record_subtitle oe_partner_heading">
<field name="odoo_partner_type"/>
</strong>
</xpath>
</field>
</field>
</record>