Add new field to POS ticket of the restaurant module - odoo-9

I want to add a new field that contains the name of the table that had that order in the pos receip of the resaturant module, I already have searched for similar examples but couldn't solve this
I first added the variable that containes the name of the table in the models fields (this variable is in the restaurant_table class so I have done an inheritance to the restaurant_printer class) :
pos_restaurant\static\src\js\multiprint.js
model: 'restaurant.printer',
fields: ['name','proxy_ip','product_categories_ids','name_table'],
seconde I have added this line in the pos_restaurant\static\src\xml\printbill.xml
<div id="name_table" style="text-align:center;"></div>
but nothing had changed in the ticket any ideas please?

for all poeple who has interest in this I figured out how to add that field so first I thought that only the pos restaurant module files that needs to be modified so I was wrong and it's what it was all about,so the main file that should be modified is the addons\point_of_sale\static\src\xml\pos.xml ,to specifiy it's the PosTicket template,so the modification showed up right away because after all that restaurant module depends on the main point of sale
I added my code just after the shop widget like :
Table: <t t-esc="widget.pos.table.name"/><br />
and name of the table was added in the printed ticket
hope this helps you

To add fields in POS ticket you also need to add fields in 2 place
i) Need to add models.js file of Point of Sale. In that file there is method name "export_for_printing" under that method need to add your custom field. I added under "var receipt" name variable.
ii) After addded there to view in UI you need to add in PosTicket template located in pos.xml templates.
<t t-name="PosTicket">
Under this template your customized field needs to be added.

Related

Drupal 7 Views Multiple Contextual Filters

I'm running Drupal 7 with Organic Groups. I cloned the "OG all user group content" view added an Entity Reference to it to be used as a field in one of my content types. My question is:
How can I use an additional contextual filter (Content Type) so that I can add an Argument to the Entity Reference field?
Entering the content type name isn't working: 1/article for example.
So I got the answer from:
https://drupal.stackexchange.com/questions/53861/how-to-show-nodes-of-a-content-type-using-contextual-filters-as-filters
Adding "Content Type" contextually typically requires a Node ID however; using PHP Code you can simply add:
return TRUE;
and this will allow you to enter the content type name (the physical name; i.e. OpenLayers Location field is named Location but the physical path is ol_locator_location).
When you edit the view in the Advanced link, you can see "Contextual Filter"; there you can add the field you added to the content type.

Magento - Displaying custom attribute in accounts area (front-end)

I have used this module creator to get an custom attribute (which takes the type 'file').
http://www.silksoftware.com/magento-module-creator/
This works and can be seen in the admin area. I also have other custom attributes for customers which I have used this tutorial to create:
http://www.fontis.com.au/blog/magento/know-more-about-your-customers-adding-custom-signup-attributes
This also works. The reason I used the module creator was because I was unsure of how to make the input type as 'file'.
The attributes created through the fontis tutorial can be displayed as needed on the front end (which was only needed in the registration form).
The problem I'm having is in the custom area in the logged in accounts area on the front end. What I need is to retrieve the value of the 'file' attributes which was created in the module creator. Could anyone point me in the right direction of how to display these please? I have tried getAttributeName but this is not working.
Thank you.
If you post the code from your custom module we could help you more.
Meanwhile, here is some info that could help you:
Whenever you store something in the DB using a module, there is a Model class (that allows you to access the necessary data)
You can find the class name by looking in your modules etc/config.xml file
In the file look for section named <models>
The sub nodes of <models> is the name of the namespace (see below)
The sub node of your 'namespace' called <class> contains the rest of the info you will need
Next you need to call the Model with Mage::getModel('namespace/class_name')->load($id); to get a collection of all the custom attribute records that are in the system
To break this down in to manageable pieces:
Let's assume this is what your config.xml contains:
<models>
<customattribute> // this is your namespace
<class>Mycompany_Customattribute_Model</class> //this tells you wher to find your model files
<resourceModel>customattribute_resource</resourceModel>
</customattribute>
...
</models>
This means that your 'namespace' is 'customattribute'.
Next you need to find the file that contains your Model.
In this case we look at the <class> node to give us the file location (in this case app/code/local/Mycompany/Customattrbute/Model), now we need to go there and see the file that is there (let's say it's called 'File.php')
To get all the data we call the follwoing function:
Mage::getModel('customattribute/file')->load();
This will give us all the data.
If we want to narrow it down we can use the following function:
Mage::getResourceModel('customattribute/file')->addFieldToFilter('name_of_filed_in_db', 'value_we_want');

django rest frame work tutorial 4 serializer concept

I finished tutorial 1-4 at http://django-rest-framework.org/tutorial/4-authentication-and-permissions.html and got the code run.
However, I am not fully understand the explanation around:
owner = serializers.Field(source='owner.username')
I am confused by which field refering to which field.
1.For example, there is an owner field defined in Snippet class in models.py. After looking it up at https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey, it says ForeignKey() returns a class. Does it return the auth.User class?
2.If it does, what "owner" does the
owner = serializers.Field(source='owner.username')
refer to? I do not found owner in the import part of serializers.py.
3.What does serializers.Field(source='owner.username') returns? Does it return the username in the auth.User?
4.Should we add the corresponding field in a serializer class if the corresponding model has a field reference to another table?
source = 'owner.username' will translate to 'user.username' since owner is nothing but FK-User.
Please note that 'owner' on the left side of field is not important here, in your case. i.e, you can still add custom fields like,
xyz = serializers.Field(source='owner.username')

Extend a Varien Form Element for a Custom Module

Improving on this question:
Is it good practice to add own file in lib/Varien/Data/Form/Element folder
The accepted answer shows how to extend a Varien form element, but this will not work if you want to package it into a custom module.
What would be the proper method of extending the Varien form element in a module? A simple XML setting I'm hoping?
Update:
Thanks Vinai for the response. Although that does work, I was hoping to extend the form element somehow. My extension is using the base File form element to allow administrators to upload files to categories. So, I'm not directly adding the form elements to the fieldset myself.
I suppose it's possible to to check for the file input on my category block on the backend: Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes , and then change the form element if it is 'file' to 'mycompany_file' -- but this seems like a workaround.
Is there an easier way? Thanks again Vinai.
On the Varien_Data_Form instance you can specify custom element types like this:
$fieldset->addType('custom', 'Your_Module_Model_Form_Element_Custom');
Then, add your element with
$fieldset->addField('the_name', 'custom', $optionsArray);
If you are using a form without fieldsets you can do the same on the Varien_Data_Forminstance, too.
EDIT: Expand answer because of new additional details in the question.
In the class Mage_Adminhtml_Block_Widget_Form::_setFieldset() there is the following code:
$rendererClass = $attribute->getFrontend()->getInputRendererClass();
if (!empty($rendererClass)) {
$fieldType = $inputType . '_' . $attribute->getAttributeCode();
$fieldset->addType($fieldType, $rendererClass);
}
Because of this the attribute frontend_input_renderer on the attributes can be used to specify custom element classes.
This property can be found in the table catalog_eav_attribute, and luckily enough it isn't set for any of the category image attributes.
Given this, there are several ways to apply customizaton.
One option is to simply set the element class in the table using an upgrade script.
Another would be using an observer for the eav_entity_attribute_load_after event and setting the input renderer on the fly if the entity_type_id and the input type matches.
So it is a little more involved then just regular class rewrites in Magento, but it is quite possible.
You don't necessarily need to have a file in the lib/Varien/ directory in order to extend it. If you needed to add an element to that collection, you should be able to extend one of the Elements in your app/code/local module. The answer to the question you referenced seems to also indicate this is the case. I would create your custom field, extending its highest-level function set (i.e., lib/Varien/Data/Form/Element/File.php).
If you want to override the Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes block, then you should extend that block in your module and then reference the new one. You may wish to extend the block using an event observer rather than an XML rewrite, for compatibility purposes.

get magento module config data in Observer

I created a module with an observer for the sales module with event hook ‘sales_order_shipment_save_after’ ,
My module has the following files
Company/Modulename/etc/config.xml
Company/Modulename/etc/system.xml
Company/Modulename/Model/Observer.php
there are four fields in the modules admin configuration fields
I want to get those saved data in the Observer class.
using $this->getConfigData(’password’); gives a
Call to undefined method
error
Any suggestions?
Magento uses a static method on the global Mage application object to get configuration values
$config = Mage::getStoreConfig('section_name/group/field'); //value
$config = Mage::getStoreConfig('section_name/group'); //array
An amendment to Alan's completely correct answer.
Along with path as first parameter, getStoreConfig also accepts storeid as second parameter(optional).
Well, this is useful when you want to retrieve store-wise values.
Alan has mentioned this point in his own tutorial. I guess, he has not mentioned here just because OP has not mentioned this requirement in his question.
Please refer this
In a shipment module I can use $this->getConfigData for fields in system.xml, but in another kind of modules sometimes not, e.g. extends Mage_Core_Model_Abstract, than I must use getStoreConfig. So the answer is you don't have to use always getStoreConfig. But I don't know why ...
Answer: getConfigData is just defined in a shipment class and uses getStoreConfig too. A little confusing that some functions are extra defined and unneeded in fact ...

Resources