Magento 2 , how to get the data from page_image_form and change the frontend imagelink? - magento

adminhtml/ui_component/page_image_form.xml :
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="advanced">
<field name="custeom-one" sortOrder="70" formElement="input">
<settings>
<dataType>text</dataType>
<label translate="true">Custom One</label>
</settings>
</field>
<field name="custom-two" sortOrder="70" formElement="input">
<settings>
<dataType>text</dataType>
<label translate="true">Custom Two</label>
</settings>
</field>
</fieldset>
</form>
how to get the data from page_image_form and change the frontend imagelink?
i expect the html result as below:
<img class="pagebuilder-mobile-hidden" src="https://u001.ugg.com.hk/media/wysiwyg/1.jpg" alt="" title="" data-element="desktop_image" data-pb-style="A123456"><img class="pagebuilder-mobile-only" src="https://example.com/media/wysiwyg/1.jpg" alt="" title="" data-element="mobile_image" data-pb-style="A123456">

Related

Joomla4 : how to set parameters in an extension?

I have developed a Joomla3 extension and I try to run in in Joomla4.1
In my XML file:
<extension version="3.1" type="plugin" group="content" method="upgrade">
<config>
<fields name="params">
<fieldset name="basic">
<field name="webmasterid" type="text" default="" label="Enter webmasterid"/>
<field name="password" type="password" default="" label="Enter Password"/>
</fieldset>
</fields>
</config>
But I don't see any way from my /administrator/ panel where I can set these 2 params:
webmasterid, password
What is the correct way to have them displayed in /administrator/ panel ?
(the plugin still works correctly, but I have to set these values directly in my plugin code)

odoo inheritance of view element without name or id

In odoo I try to change the recruitement form, but some of the stuctural elements dont have a name or id. When I change those elements it works fine initially, but when I upgrade the database then the rendering of the xml is stricter for some reason and gives an ParseError.
The recruitement form:
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name" placeholder="e.g. Sales Manager"/></h1>
</div>
<notebook>
<page string="Job Description">
<div attrs="{'invisible': [('state', '!=', 'recruit')]}">
<label for="description"/>
<field name="description" type="html"/>
</div>
</page>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="department_id"/>
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</sheet>
As you can see; the sheet, notebook, pages and groups mostly dont have a name. The string attribute is also not sufficient to modify with a expression in xpath. So it feels like I'm just stuck with this framework.
What I try:
<xpath expr="//sheet/notebook" position="replace">
<notebook>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="branch_concept" />
<field name="branch" />
<field name="department_id" />
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</xpath>
And this works until I do a db upgrade, then I get a parseError.
Does anybody know I can use my own structure?
In the xpath expression you use //<some_node> to 'Selects nodes in the document from the current node that match the selection no matter where they are'. You can also use /<some_node>/<some_other_node> to locate a specific element.
for example /form/sheet/notebook/page[1]

odoo wizard cant inherit the model

I created a model like this
class FoundCheque(models.TransientModel):
_name = "found.cheque"
date_Found = fields.Date(string='Found Date', default=fields.Date.context_today, required=True, translate=True)
and its view
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>
but when I try to update the module after restarting the service
it just says:
Field `date_found` does not exist
Error context:
View `found.cheque.wizard`
[view_id: 4100, xml_id: n/a, model: found.cheque, parent_id: n/a]
None" while parsing /opt/odoo/odoo11-custom-addons/cheque_management/views/found_cheque.xml:4, near
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight" confirm="آیا مطمئن هستید؟"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
and just to add I restarted the service several times
more information will be added on request
Your field name in python file is date_Found and date_found in xml. Both are different. so change field name in xml file
the defined field in model was "date_Found" and the defined field in wizard was "date_found"
F

Button not displaying report in odoo

I have been battling with an issue for a while now....Kindly help me. Below is the issue:
I created a button on the header of a form, the idea of this button is to show a report of an image file on click. But anytime i click this button, nothing happens. And when i edited the form view from developer's mode, i realized that the button is picking a different name. i.e
<header>
<button name="reports/bh_customcustom.report_formdownload_view" type="report" string="Form Download" class="oe_highlight"/>
</header>
instead of this which is in the code:
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
Below are my code snippet:
The form view:
<record model="ir.ui.view" id="form_download_form_view">
<field name="name">form_download.form</field>
<field name="model">formdownload</field>
<field name="arch" type="xml">
<form string="Form Download Form">
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
<sheet>
<group string="Company Name">
<!--<field name="company_name_id"/>-->
<field name="name"/>
<!--<field name="form_serial_no" />-->
</group>
</sheet>
</form>
</field>
</record>
The model:
class FormDownload(models.Model):
_name = 'formdownload'
_rec_name = 'form_serial_no'
# #api.multi
def action_formdownloader(self):
return self.env['report'].get('bh_customcustom.report_formdownload_view')
name = fields.Many2one('companyname', string="Company Name", ondelete='cascade',
required=True)
form_serial_no = fields.Char(string="Form Serial No", readonly=True)
status = fields.Boolean(string="Status", default=False)
Part of the openerp.py file related to it
'depends': ['base', 'construction_plot_4devnet', 'bh_custom', 'report'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/bh_customcustom.xml',
'sequences.xml',
'report/form_download_report.xml',
'security/security_groups.xml',
'templates.xml',
],
'images': [
'img/firstpage.png',
],
The report file:
<openerp>
<data>
<report
id="report_form_download"
model="formdownload"
string="Form Download Report"
name="bh_customcustom.report_formdownload_view"
file="bh_customcustom.report_formdownload_view"
report_type="qweb-pdf"/>
<record id="paperformat_formdownloadcheck" model="report.paperformat">
<field name="name">Form Download Check</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">80</field>
<field name="page_width">175</field>
<field name="orientation">Portrait</field>
<field name="margin_top">3</field>
<field name="margin_bottom">3</field>
<field name="margin_left">3</field>
<field name="margin_right">3</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">3</field>
<field name="dpi">80</field>
</record>
<template id="report_formdownload_view">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<!--<img class="img img-responsive" src="/bh_customcustom/static/src/img/firstpage.png"-->
<!--style="max-height: 45px"/>-->
<img src="/static/src/img/firstpage.png"
style="max-height: 45px"/>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
The problem was from my path on the view xml file cos i edited the form view now and it's picking the exact method that it suppose to pick after i reviewed the path. Moreso, the method that would pull the report should be like this:
#api.multi
def action_formdownloader(self):
return self.env['report'].get_action(self, 'bh_customcustom.report_formdownload_view')

add css style into module's xml file in joomla

I have hello world module in joomla. I would like to add css style in my xml file in admin section. e.g.
Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="2.5.0" method="upgrade">
<name>MOD_HELLOWORLD</name>
<!-- Следующие элементы не обязательны и могут содержать все, что вы считаете нужным -->
<creationDate>05.05.2012</creationDate>
<author>Dev Joomla</author>
<authorEmail>info#dev-joomla.ru</authorEmail>
<authorUrl>http://www.dev-joomla.ru</authorUrl>
<copyright>Copyright Info</copyright>
<license>License Info</license>
<!-- Версия модуля – эта строка сохраняется в таблице расширений -->
<version>0.0.1</version>
<!-- Описание модуля также не обязательно и если оно не указано, то берется из тэга name -->
<description>MOD_HELLOWORLD_XML_DESCRIPTION</description>
<!-- Обратите внимание на тэг files: в нем содержится информация, о том какие файлу нужно копировать в каталог модуля -->
<files>
<filename module="mod_helloworld">mod_helloworld.php</filename>
<filename>mod_helloworld.xml</filename>
<folder>tmpl</folder>
<folder>language</folder>
<filename>helper.php</filename>
<folder>css</folder>
<folder>js</folder>
</files>
<!-- Описание параметров модуля -->
<config>
<fields name="params">
<fieldset name="basic">
<field
name="greeting"
/*CODE HERE*/
type="text"
default="MOD_HELLOWORLD_GREETING_DEFAULT"
label="LABEL"
/>
</fieldset>
</fields>
</config>
</extension>
Now I would like that my label LABEL becomes red. How can I do this?
If I understand your question correctly, I think you could do this with straight CSS. For example, say I wanted to color the second label of the protostar template in the Joomla template manager, use your web insptector to figure out the classes and divs.
HTML is
<div id="attrib-advanced" class="tab-pane active">
<div class="control-group ">
<div class="control-label"><label>Template Colour</label></div>
<div class="controls"> ....</div>
</div>
<div class="control-group "> <------ target this control-group
<div class="control-label"><label>Background Colour</label></div>
<div class="controls"> ....</div>
</div>
....
</div>
In this case I could do it with the following in the template CSS:
#attrib-advanced .control-group:nth-of-type(2){
color:red;
}
Good luck!

Resources