Odoo 10: How to create project tasks from sale orders? - odoo

I have set my odoo system according to the "User Doc" of How to create tasks from sales orders? and want to generate project tasks automating when a sale order containing "Service" type product was created.
However, it wasn't working even after I have tried severals times.
I didn't find the the "Track Service" item when I set up a "Service" product.
screen shot
Is this the reason which odoo system can't generate task automating? Or there some thing else cause the issue?
Anyone can give me some advice?
Thanks.

this answer will help to do your task in odoo version 10.
In order to get the track the **Create Tasks From Sales Orders** you follow the following steps.
Step : 1 Install the required applications / Configuration
Install the 3 following app
1. Sales Management
2. Project management
3. Time-sheet management
Step : 2 Create and set up a product
Note :
Now in case to of the service product unit of the measurement is used in hours. to configure that go to
Go to Configuration -> Settings -> Unit of measures -> check the
Some products may be sold/purchased in different unit of measures
(advanced) radio button)
Now , create the product with following details
To create the product Go to the Sales -> Product -> Create
- Name: Service Contract
- Product Type: Service
- Unit of Measure: Hours
as this all are the general setup shown on Image below
Next configure Track Service:
You will found this under Sales -> Sales -> Product -> Invoice ->
Select Create a task and track hours.
Note :
Link your task to an existing project or create a new one on the fly if the product is specific to one project. Otherwise, you can
leave it blank, odoo will then create a project per SO.
as your product is a service invocable by hours you have to set the units of measures of the product to hours as well.
Step : 3 Create the Sales Order
Once the product is set up, you can create a quotation or a sale order
with the related product. Once the quotation is confirmed and
transformed into a sale order, the task will be created.
Step : 4 Access the task generated from the sale order
On the Project module, your new task will appear :
either on a related project if you have selected one in the product form
either on a new project with the name of related the sale order as title
(you can easily change the name of the project by clicking on More ->
Settings)
as shown in below image.

The doc screenshot of the product form seems just wrong for Odoo 10. The track service option should be found in the page "Accounting" of a product. Maybe the module sale_timesheet has to be installed before.

If the system configuration is not working, then try creating tasks as follows manually in your code by inheriting sale.order model
Iterate over your order_line one2many field of sale.order and check any products are of type service, if the condition is satisfied then invoke the create function of the model project.task and pass the field(of project.task model) values as arguments

Related

Prestashop add custom radio button on shipping carriers on front end checkout

I have created one custom module in Prestashop 1.7.8.7 which will add multiple shipping methods (Carrier) and will show shipping cost based on product dimensions and delivery address. So shipping carrier will look something like this on front-end checkout page. https://prnt.sc/E1avDASyJYYW
Now if someone select SameDay Courier Shipping then i need to show two radio button to select which service they want.
It will have two radio options like
Delivery pickup (by default this option will be selected)
Locker pickup
So if someone select Delivery pickup then it will have different shipping cost and if someone select Locker pickup then it will have different shipping cost.
Can anybody help me how can i achieve this functionality.
While digging, i found that we have file called DeliveryOptionsFinder.php and in that file we have one public function called getDeliveryOptions() where we have this line of code
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', ['carrier' => $carrier], $moduleId);
}
}
So if i set is_module to 1 to all my carriers directly from DB then on frontend checkout page, no carriers is being displayed.
Thanks in advance.
I've already done something like this in the last 2 year as prestashop developer.
The truth is that you can't achieve what you want by "respecting" prestashop processes.
Maybe you can hook using a module the hookDisplayCarrierExtraContent($data) and then return the 2 radios if carrier is certain one (use $data).
But you can't handle a form submit or something else, or include it to prestashop checkout data.
But what you can do as workaround, for example, is the following.
In your module, as I said, hook the extra content, render a template with the 2 radios. Hook displayHeader too and use $this->context->controller->addJS() to add your own js if the current controller is the checkout one.
Then in this JS code you can handle the "change" event of the radios and send an ajax request to your module.
You can create inside {your_module}/controllers/front/ a controller called, for example, radio-choose and handle the js ajax request by saving inside your own table the choosen one.
Obviously you can disable the "next" button in checkout untill one of the two radios are selected, or maybe you can just set a radio button as default one to simplify.
For example your table "ps_cart_choosen_radio" could look like this |id_cart|choosen_radio|.
Then you have all the data you needed. When a cart is converted into an order you will have inside Order object (and ps_orders table as well) the id_cart.
Just select / join choosen radio from your own table by using order's id_cart.
"SELECT choosen_radio FROM ps_cart_choosen_radio WHERE id_cart = {$order.id_cart}"
If you need to show data depending on choosen_radio in frontend you can hook everywhere an order is present and select these data. Or maybe you can edit carrier name in ps_orders table by adding a piece of string. Let' say carrier is "express" and customer choosed "24h". You can update that column with carrier name by changing it to "express-24h" so around the whole prestashop ecosystem everybody will see that's a 24h choice.
Remember that the carrier name related to an order is not the carrier name inside the carriers table. So you can edit it without having trouble.
All these problems comes from the "need" to show some nested choices instead of listing all these in the main selections. In that case it would be easy (just create carrier in the prestashop backoffice)

In Strapi i can get a specific product but how do I get ALL products?

I set up a product collection type, added three records and in the browser type
localhost:1337/api/products/2 and it correctly displays record 2:
{"data":{"id":2,"attributes":{"title":"Gillette Razor","price":9.99,"description":"/assets/product-images/product-2.png","featured":true,"createdAt":"2022-08-20T12:23:10.685Z","updatedAt":"2022-08-20T12:29:45.062Z","publishedAt":null}},"meta":{}}
(also works for /1 and /3, showing those products).
But, when I try to see ALL products by typing:
localhost:1337/api/products I get:
{"data":[],"meta":{"pagination":{"page":1,"pageSize":25,"pageCount":0,"total":0}}}
I have given "public" access to "find" and "findOne". Server is running. Why is it not producing a list of the three products entered?
The solution was the data has to be "published" (default is "draft") for the /api/products to show all records, even though the /api/products/x had no issue revealing product x details without being published.
After marking the data as published localhost:1337/api/products now gives me ALL of my products:
{"data":[{"id":1,"attributes":{"title":"razor blade","price":1.99,"description":"/assets/product-images/product-1.png","featured":false,"createdAt":"2022-08-20T12:22:12.498Z","updatedAt":"2022-08-20T15:37:08.598Z","publishedAt":"2022-08-20T15:37:08.597Z"}},{"id":2,"attributes":{"title":"Gillette Razor","price":9.99,"description":"/assets/product-images/product-2.png","featured":true,"createdAt":"2022-08-20T12:23:10.685Z","updatedAt":"2022-08-20T15:37:01.649Z","publishedAt":"2022-08-20T15:37:01.648Z"}},{"id":3,"attributes":{"title":"Barber Razor","price":7.99,"description":"/assets/product-images/product-3.png","featured":null,"createdAt":"2022-08-20T12:23:52.749Z","updatedAt":"2022-08-20T15:36:52.579Z","publishedAt":"2022-08-20T15:36:52.577Z"}}],"meta":{"pagination":{"page":1,"pageSize":25,"pageCount":1,"total":3}}}

odoo auto publish product

I'm trying to build an automation rule in Odoo 11 (enterprise) so my products can publish and unpublish on the website automatically.
We sell seasonal products, roughly 17.000, and we do a lot preparation in advance.
So with "scheduling" (un)publish a product, we can save a lot work and automate this job.
So far with all my attempts, it's not working.
I have created 2 custom fields for model product.template:
x_publish_start and x_publish_end
I have created an automated action with trigger condition "based on timed condition" and apply it to products where x_publish_start is SET (not empty).
Trigger date = x_publish_start
In the data to write, I have set the default field visible on website = TRUE
Basically, this should work?? But it's doing nothing in my end.
The condition is quite basic:
if today() >= x_publish_start -> publish product
if today() >= x_publish_end -> unpublish product
screenshot
http://sharing.codeagency.be/0c0d7512e9f9
Anybody who knows what is wrong with my concept and automation, or can provide a working code example?
Thanks!
Those actions get triggered when editing a record (see action to do: update the record). What you need is more a cron that runs every day (or hour, minute...) and publishes/unpublishes products that match (or not) current date. The model you're looking for is ir.cron.

Purchase Requisition for asset services

I have a task to modify a purchase requisition (tcode:me51n) with item category (service) and account assignment (asset services) for filling automatically the asset field (ESKN-ANLN1) based on specific service-activity number (ESLL-SRVPOS). These fields are at items details screen and asset number at account assignment tab.
Until now I have achieved to link an asset with specific service in service master through classification. This information is stored at AUSP. Also, I am taking the activity number using a field symbol and asset number with select from AUSP. The problem is that the asset value doesn’t have an export at screen. I have tried user exits EXIT_SAPLMLSK_001 from enhancement SRVESLL, exits from enhancement mereq001 and the exit EXIT_SAPLKACB_002 from ACCOBL01 and also the badi ME_PROCESS_REQ_CUST, but I couldn’t achieve to pass the asset number as export to screen.
Could any expert help me?
Thanks

How to access Customizable Text Fields From Prestashop Module?

I'm creating a new module for Prestashop where users can design their own product from a third party service. When the user later adds the product to their cart, I would like to save a ID that I get from this Third Party Service where the user designed their product.
I guess the best way to do this is to create a Customization Textfield within Prestashop called "designID". Now I want to know how I save data to this field from module development in Prestashop instead of letting the users manually fill in the data.
So basically... How do I add data to these customizable fields from within a Prestashop module, when the user adds the product to their cart?
These customization fields are used if you are simple user and you are not designing a module. Using it to save the designID will be just a hack.
Since you're creating a new module my advice is to keep the 3rd party ID in a newly created database table, which will match the id_product, id_design, id_cart, id_order, etc...
You can hook to "actionCartSave" and add the record with the matching ids, and all the other required data at your table.
If you want to stick to that Customization feature, add a sample field and review the following database tables:
ps_customization
ps_customization_field
ps_customization_field_lang
ps_customized_data
and replicate the changes when you receive the 3rd party ID.
If all your products will be customized, consider adding the required data in ps_customization_field & ps_customization_field_lang (the table for the field structure) during the module installation, so after it's installed you can just fill
ps_customization & ps_customized_data (the tables for the field data)
PrestaShop does not have proper API for adding customizations, only for retrieving data, so you'll have to write the SQL queries yourself. Just review the ProductController for the ps_customization & ps_customized_data changes and the AdminProductsController for ps_customization_field & ps_customization_field_lang.
Do not forget to remove the Customization markup code from your product & cart templates.
I was able to find this out by myself by first trying to use Customization for a couple of hours without any success.
So basically how my module work is that the customer can open a popup iframe to a third party design tool, the customer then save the design in the iframe, which then sends the data to the parent window (The Prestashop Window).
So to store this I did the following:
Add a new column to the database table ps_cart_product
Hook into any display-hook on the product page and check if any post data is send containing the data from the third party module. If so, then:
if(isset($_POST['thirdparty'])){
$id_product = (int)Tools::getValue('id_product');
if (!$this->context->cart->id){
$this->context->cart->add();
if ($this->context->cart->id)
$this->context->cookie->id_cart = (int)$this->context->cart->id;
}
$this->context->cart->updateQty(1, $id_product);
if(!Db::getInstance()->update('cart_product', array('id_design'=> pSQL(trim($_POST['thirdparty']))) ,'id_cart = '.$this->context->cart->id.' AND id_product = '.(int)Tools::getValue('id_product') ))
$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
}
So basically first I check if POST is set, then I check if any cart exist, if cart does not exist then add a new cart with ->add() (This function took hours to find, 0 documentation). updateQty() is used to update the cart with the new product.
The last part is the SQL query that updates the value of id_design column with the data that is send from the third party.