I'm using odoo 9 and i want to print products labels using zebra printer that's why i have installed a custom module named "printer_zpl2" but i don't know how to use it to print labels with it . is there anyone who used it before who can help me ??
Be sure the printer is connected to your server
Go to Settings > Printing > Labels > ZPL II to create a new label (define model and add elements(design + fields ex:"object.default_code" in data field))
To call the action to execute the label printer you MUST update the module and add the ir.record value(ex for product template, will show you in the "More")
<record model="ir.values" id="wizard_wizard_print_product_label">
<field name="name">Print Product Label</field>
<field name="key">action</field>
<field name="key2">client_action_multi</field>
<field name="model">product.template</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('printer_zpl2.action_wizard_print_record_label_view'))"/>
</record>
Open a product, select More and check for "Print Product Label", select the printer and the label you will use
Related
How to show/hide menu item based on system parameter?
I've this code to create menu item, and it working fine, but i need to hide it depends on system parameter.
<!-- this is for test, remove this after testing -->
<record id="check_qty_and_move_from_internal_customer_to_customer" model="ir.actions.server">
<field name="name">Cron Run Directly 2</field>
<field name="model_id" ref="model_kiotviet_cron"/>
<field name="binding_model_id" ref="onnet_kiotviet.model_kiotviet_cron"/>
<field name="state">code</field>
<!-- function called -->
<field name="code">model.check_qty_and_move_from_internal_customer_to_customer()</field>
</record>
<!-- this is for test, remove this after testing -->
<menuitem id="check_qty_and_move_from_internal_customer_to_customer" name="Cron Run Directly 2" parent="kiotviet_menu_root"
action="check_qty_and_move_from_internal_customer_to_customer" sequence="6"/>
Does anyone know how to do that? Thanks.
I've found the answer, here is it:
from odoo import models, api, tools, _
class Menu(models.Model):
_inherit = 'ir.ui.menu'
#api.model
#tools.ormcache('frozenset(self.env.user.groups_id.ids)', 'debug')
def _visible_menu_ids(self, debug=False):
menus = super(Menu, self)._visible_menu_ids(debug)
# get system parameter
if not self.env['ir.config_parameter'].sudo().get_param('your_module.your_config_name'):
# get menu item id
menu_item_id = self.env.ref('your_module.menu_item_id').id
# remove it from menus
menus.dis
card(menu_item_id)
return menus
In Plone 5 you can make use of html templates in the TinyMCE editor by registering the template plugin. The templates are html snippets living in the file system which are also registered in the plone ressource registry. Here is an example:
<?xml version="1.0"?>
<registry>
<record name="plone.templates" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="templates">
<field type="plone.registry.field.Text">
<default></default>
<description xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="help_tinymce_templates">
Enter the list of templates in json format http://www.tinymce.com/wiki.php/Plugin:template
</description>
<required>False</required>
<title xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="label_tinymce_templates">Templates</title>
</field>
<value>[
{"title": "Template 1", "url": "++theme++mytheme/tinymce-templates/tmpl1.html"},
{"title": "Template 2", "url": "++theme++mytheme/tinymce-templates/tmpl2.html"}
]</value>
</record>
<record name="plone.custom_plugins" interface="Products.CMFPlone.interfaces.controlpanel.ITinyMCESchema" field="custom_plugins">
<field type="plone.registry.field.List">
<default/>
<description xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="">
Enter a list of custom plugins which will be loaded in the editor. Format is pluginname|location, one per line.
</description>
<required>False</required>
<title xmlns:ns0="http://xml.zope.org/namespaces/i18n" ns0:domain="plone" ns0:translate="">Custom plugins</title>
<value_type type="plone.registry.field.TextLine"/>
</field>
<value>
<element>template|+plone+static/components/tinymce-builded/js/tinymce/plugins/template</element>
</value>
</record>
</registry>
My question is: How can the templates be accessed from python code or from TAL? First possibility is to read the file from the filesystem. But then the security layer will be passed by. The second is to request the templates by http. In this case safety is taken into account. But it is rather expensive. Is there a way to access the templates (plone resources) direct without bypassing security?
You can access the templates direcly by the url.
Something like:
portal.restrictedTraverse('++theme++mytheme/tinymce-templates/tmpl2.html')
The same applies to page templates.
So I've been looking around the web, on a mission to find a way to create my own sequence for the new API for Odoo 9 that I am using. However, I wasn't able to find a satisfactory answer. As far as I've seen, sequences aren't very well documented in the Odoo Docs.
Here's what I know so far.
From this I know:
<openerp>
<data noupdate="1">
<record model="ir.sequence.type" id="seq_type_obj_id">
<field name="name">obj_id_seq</field>
<field name="code">seq.obj.name</field>
</record>
<record model="ir.sequence" id="seq_obj_id">
<field name="name">obj_id_seq</field>
<field name="code">seq.obj.name</field>
<field name="prefix">prefix</field>
<field name="padding">3</field>
</record>
</data>
</openerp>
But apparently ir.sequence.type is NOT a model that exists and I cannot use, so I removed that record and it compiles/updates without errors.
From previous source, I also know:
my_sequence = self.pool['ir.sequence'].get(cr, uid, seq_obj_name)
self.write(cr, uid, [picking.id], {'ur_emp_no_field': my_sequence})
But this is the old API, so I've changed it to:
# Correct me if I'm wrong here
my_sequence = self.env['ir.sequence'].get('seq.obj.name')
And have added it to the create function, which then writes to an arbitrary field to be stored.
So I've done all this without getting any error messages.
My problem is: The field I'm storing the sequence instance to is not changing. I checked in the sequence settings and the sequence is not being incremented when I create a new record either.
For the sake of clarity:
#api.model
def create(self, vals):
for rec in self:
rec.seq_id = self.env['ir.sequence'].get('seq.obj.name')
return super(PurchaseOrder, self).create(vals)
If someone could give me a thorough explanation of where Odoo does the auto increment, maybe direct me to a proper source, or point out what is wrong with my code and how to fix it, I would much appreciate the effort.
You code didn't update the directory variable. That's the reason of it.
Try with this code.
#api.model
def create(self, vals):
if vals:
vals.update({
'seq_id': self.env['ir.sequence'].get('seq.obj.name')
})
return super(PurchaseOrder, self).create(vals)
How can I select/get a pre created record/value in many2one field
for example: the holidays_status_id in hr_holidays module is a many2one field and it has already 4 values of
Legal Leaves
Sick Leaves
Compensatory Days
Unpaid
what I need to do is dynamically select the legal leaves and customize it in another module.
How can I do it?
Basically the data is coming after once you are installing the module of your hr_holidays.It means the part of first time of module installation.
It is basically a part of the data file which is named as hr_holidays_data.xml file in hr_holidays module.
It must need to add that file location on 'data' key attribute of value in __openerp__.py file
'data': ['hr_holidays_data.xml']
which is part of added into our module menifiest file of each module in Odoo (Formally OpenERP).
<!-- Casual leave -->
<record model="hr.holidays.status" id="holiday_status_cl">
<field name="name" eval="'Legal Leaves '+time.strftime('%Y')"/>
<field name="color_name">black</field>
</record>
<!-- Sick leave -->
<record model="hr.holidays.status" id="holiday_status_sl">
<field name="name">Sick Leaves</field>
<field name="limit">True</field>
<field name="color_name">red</field>
</record>
<!-- Compensatory Days -->
<record model="hr.holidays.status" id="holiday_status_comp">
<field name="name">Compensatory Days</field>
<field name="limit">True</field>
<field name="color_name">lavender</field>
</record>
<!--Unpaid Leave -->
<record model="hr.holidays.status" id="holiday_status_unpaid">
<field name="name">Unpaid</field>
<field name="limit">True</field>
<field name="color_name">brown</field>
</record>
Need to understand the following attribute for more clarification.
1. model :-
which is part of the your own model (class name) or use the existing Odoo Model class.which is basically mentioned on each class of _name attribute in your class.
2. id :
unique id of each record
2.field name:
what ever field you want to add a new record (insert a new record) which is part of the model class fields name.
Each record contain the number of child field name so you can add as per your requirement and do to check after install or upgrade the module.
You may also add our own custom leave with our module with our own separate .xml file and add it as per your need.
I hope my answer may helpful for you :)
I create a WSO2 Governance artifact and i tried to add it an input to display a list of the existing lifecycles:
<field type="options">
<name label="Lifecycle Name">Lifecycle Name</name>
<values
class="org.wso2.carbon.governance.services.ui.utils.LifecycleListPopulator">
</values>
</field>
i also tried whit the class:"org.wso2.carbon.governance.generic.ui.LifecycleListPopulator"
The system logs show:
ERROR {org.wso2.carbon.governance.generic.ui.utils.GenericUIGenerator} - Unable to
load populator class
Does the class who populate the lifecycles list has changed ??
Thanks
Yes there have been some changes in the locations please try to use the following
"org.wso2.carbon.governance.generic.ui.utils.LifecycleListPopulator"
Regards