Reload a new BoM in a manufacturing order - odoo

In odoo V13, we need to "update" the BoM in a manufacturing order. We use the PLM application to make changes to BoMs, and a change was made after the manufacturing order was created. We would prefer to not delete and re-create the manufacturing order.
I came across this post but there are no instructions for Odoo V13. I tried to figure it out by trial and error but I don't know odoo enough to be certain the result is correct.
This is the code for V14 with functions unavailable in V13 identified:
for record in records:
record._compute_allowed_product_ids() <- Not in V13
record._onchange_bom_id()
record._onchange_move_raw()
record._onchange_move_finished() <- Not in V13
record._onchange_location
I planned on adapting it to work with a wizard to allow selecting a specific BoM version.
How can I create a server action to "update/change" the BoM of a manufacturing order?

I haven't tested it fully but played around with it on an odoo 13 runbot instance.
# only change draft manufacturing orders
for record in records.filtered(lambda r: r.state == 'draft'):
# trigger changing to the same product
record.onchange_product_id()
# trigger bom change from product onchange
record._onchange_bom_id()
# trigger raw materials moves change after bom change
record._onchange_move_raw()
# trigger some other changes which usually are done anyways
record.onchange_picking_type()
record._onchange_date_planned_start()
record._onchange_location()
# finally set procurement group again, which is usually done in create()
record.move_raw_ids.write({
'group_id': record.procurement_group_id.id,
'reference': record.name,
})
It will be much more difficult to change BoMs on confirmed manufacturing orders, so this solution only works for draft orders.

Related

Adding new product with category tree - specific price problems

I installed an add-on for bulk action (called ba_importer v 1.1.24), I upload an Excel file with my data and create a group of products.
I can set the categories' tree or manually add ID of main categories and associated. I tried with no luck to use the tree features (like Home/Products/etc) and so I use all the ID of main category and all the associated. The result is a product with the correct categories set, but with no specific price from the customer group linked to a category.
I tried to edit a single product, remove all categories and set it one by one (set one, save, set one, save etc.) and then the specific price from the group linked to a category appears to the product.
Is there a better solution? I'm thinking about make a personal PHP page that reads an Excel file and sets all the information about the product, but I'm scared to face the same problem with the specific price. 
There is no such thing as "category-related specific price",
if you have specific prices tied to customer groups , these are created as a result of the add/update product action with ps_specific_price DB entries having id_group with your restricted ID.
It is likely that the bulk module acts directly with DB queries to speed up things and bypasses this operation, I've seen this behaviour with those kind of modules in the past.
Since you are talking of a paid add-on, I would definitely seek help from the developer.

Changes in quants in Odoo 11 , 12

Up to Odoo 10, I used Quants fields inventory_value, cost in some of my reports to calculate purchase cost, etc.... and also I used quants relation to moves in some cases.
Now as I started working with Odoo 12 I see that there are no relations from stock.quant to stock.move and stock_quant_move_rel table is gone.
As I can see, now I can not even check inventory value in Odoo 12?
So maybe can someone explain these changes that were made, and how is workflow is changed, because I'm a little bit lost now.
In inventory there is inventory valuation menu under reporting you can check inventory value product wise or In product template you can check quantity on hand to check stock quant.

SQL mass updates on Volusion

Right now I am trying to update a field for a lot of products using SQL on Volusion but I can't seem to get it right.
I am trying to update the Package Type to UPS Package for every product but when I update it this way, it just adds another option on the drop down list titled the exact same thing
https://i.imgur.com/MhPmRIJ.png
I imagine what I should be doing is changing things around so that instead of updating every product I'm making every product choose UPS Package from the existing menu? If I manually change a product to UPS Package (correctly) then export all product data the field is displayed as just a '2' on the spreadsheet, but I also can't just put a '2' in on the mass update.
Thanks in advance
1:
Its the space before the SET value that is causing this, which you would need in order to keep this on the same line (otherwise this becomes products_joinedSET). This was a correction made to any SQL that can be run in a store that was made back in mid November. So any queries with a SET value will need a line break in order to remove that space between the table name and the SET.
UPDATE Products_Joined
SET Package_Type = 'UPS Package' WHERE ProductPrice = '0'
Of course, if you want to change ALL your products to UPS Package and have products that are more than $0.00 then you'll need to remove WHERE ProductPrice = '0'

Automate sale order to invoice creation in odoo

Is there an easy way to automate the sale order process ?
I have customer whose salesman will create Sale orders for every sim he creates.
Once Sale order is closed both DC and Invoice should be created and validated automatically, there is no need for stock picking/packing concepts.
Could someone have any idea on doing it without affecting the default flow ?
Or should I call every function related to that process in my module ?
I tried calling the functions in stock picking and then tried validating DC. I got the odoo Warning as
'You have a difference between quantity on the operation and the quantities specified for the lots'
Could you please suggest me which particular function picks the product from stock in stock.picking ?
Hi Nirmalraj Rethinasabapathi,
Yes, I think I have done it for my project.
I can map What I have done to achieve that:
Added two boolean fields in Warehouse form.
One for "Auto Validate Invoice" and another one is for "Automation In Delivery"
Override sales confirmation button action and bypass all the function you want.
It is working perfectly for me.

How can I delete Stock Move in 'Done' state, from command line in Odoo/ OpenERP?

I want to delete All Quotation, Sales Orders and Invoices from my database for this i have to delete all stock moves which are 'validated' and in 'done' state, how can i delete stock moves from command line ? OR How can I change status from 'Done' to 'Draft' ?
ODOO was designed so that all non-draft documents should be stored in database (as I understand, in some countries ERP should do this by law restrictions).
Nevertheless, in some cases one should completely remove already existing documents: for example, I created test invoice and confirmed it, but I don't want to preserve it in my actual system.
All next steps can be done ONLY by your own risk! You can spoil something or even break your database if you're not completely sure of what you're doing! I STRONGLY recommend to make backup of your database before doing something like this!
Generally odoo database structure is very clean and simple. You can connect to your database (I prefer some GUI tool like pgadmin3) and manually adjust necessary tables.
Here's small description of related tables (just remove unnecessary items):
sale_order: all your quotations;
sale_order_line: items in quotations;
account_invoice: all your invoices;
account_invoice_line: items in all your invoices;
account_move: journal entries;
account_move_line: items in journal entries.
I don't recommend using this method if you have alternative solution made from odoo interface!
Note: I wouldn't recommend this method unless your absolutely sure of what you are doing.
You can do this using SQL statements directly.
If you want to delete all stock moves in done state:
DELETE FROM stock_move WHERE state='done'
If you want to change stock moves from done (or any other state) to draft state:
UPDATE stock_move SET state='draft' WHERE state='done'
There are two way
1) GUI Editor(Pgadmin3 is widely using...)
Help: https://doc.odoo.com/install/linux/postgres/
2) Via Terminal , fire these commands one by one,
sudo su postgres THEN
psql database_name THEN
fire_your_query
Note : i agree with César if you sure then and then only go with it.
Thanks
Tidyway Team