Integrity error where try to save a supplier invoices - odoo

I build a module who increase stock on supplier invoices. Work fine on devel server but when I pun on work server I have this error. How can I corret this error?
Integrity Error
The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set
[object with reference: Purchase Order Line - purchase.order.line]

Integrity Error on OpenERP occur because of two possibility (mentioned on the description of error):
When you create or update a record, a mandatory field is not correctly set or is not filled. What field? One of field in your object (mentioned). In your case: purchase.order.line.
When you delete a record, the record you want to delete is used by another record and set as a mandatory field (required) from the python code.
My guess, if you get the error when you create/update a record (Purchase Order), maybe you create/update the order lines, but one of mandatory field in order lines is empty.

Related

Ondelete cascade odoo 8

I need to delete partner who have login in res.users table. when i try to delete that partner i getting an error:
except_orm: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: Res users - res.users]').
So i have changed attribute value of ondelete from restrict to cascadeof field partner_id in res.users table. Similarly in change_password. Now its works fine. But is there will be any problem occur due to this change in odoo behavior, like invoice?.

The line has been modified, your changes will be discarded issue in odoo 9

The products list is dynamically generated while running purchase request. While change the cost or qty it shows the following error, What need to do to modify the record?
Finally I fond the answer for it. I made one of the required field(UOM) in order line. So that only this happens.

How to implement a key lookup for generated keys table in pentaho Kettle

I just started to use Pentaho Kettle for integration. Seems great so far, quite intuitive compared to Talend, which I was also investigating.
I am trying to migrate some customers without their keys. So I have their email addresses.
The customer may already exist in the database, so what I need to do is:
If the customer exists, add it's id to the imported field and continue.
But if the customer doesn't exist I need to get the next Hibernate key from the table Hibernate_Sequences and set it as the id.
But I don't want to always allocate a key, so I want to conditionally execute a step to allocate the next key.
So what I want to do, is in the flow execute the db procedure, which allocates the next key and returns it, only if there's no value in id from the "lookup id" step.
Is this possible?
Just posting my updated flow - so the answer was to use a filter rows component which splits the data on true/false. I really had trouble getting the id out of the database stored proc because of a bug, so I had to use decimal and then convert back to integer (which I also couldn't figure out how to do, so used a javascript component).
Yes it is. As per official documentation (i left only valuable information) "Lookup values are added as new fields onto the stream". So u need just to put step "Filter row" in Flow section and check for "id" which suppose to be added in "Existing Id Lookup" step.

Magento update customer group prices for products

I'm trying to update the customer group prices in Magento using Mage (as I cannot find a way to do so in the SOAP V2 API). I've found a StackOverflow example, however it doesn't work for me. The code I'm using is as follows:
<?php
include_once '../App/Mage.php';
Mage::app();
$productID = $_GET["id"];
$product = Mage::getModel('catalog/product')->load($productID);
$groupPricingData = array(array('price_id'=>1,'website_id'=>0,
'cust_group'=>3, 'price'=>666));
$product->setData('group_price',$groupPricingData);
$product->save();
echo "true";
?>
I get the following error if I use a product that has any customer prices already set. If I try a product with no existing prices, it doesnt error, but the customer group price is not created.
SCREAM: Error suppression ignored for
( ! ) Fatal error: Uncaught exception 'Mage_Eav_Model_Entity_Attribute_Exception' with
message 'SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '24-0-3-0' for key 'CC12C83765B562314470A24F2BDD0F36'' in
C:\wamp\www\magento\app\code\core\Mage\Core\Model\Config.php on line 1348
( ! ) Mage_Eav_Model_Entity_Attribute_Exception: SQLSTATE[23000]:
Integrity constraint violation: 1062 Duplicate entry '24-0-3-0' for
key 'CC12C83765B562314470A24F2BDD0F36' in
C:\wamp\www\magento\app\code\core\Mage\Core\Model\Config.php on line 1348
I have been scouring the web for an answer to how to properly "update" group price on Magento Product records and have been unsuccessful. Pouring over Magento's source code hasn't gotten me anywhere either. I have however, discovered two solutions on how to clear out the existing group price, so that you do not receive this error.
1 - Direct SQL query to remove the existing group price data
$coreResource = Mage::getSingleton('core/resource');
$conn = $coreResource->getConnection('core_write');
$table_name = $coreResource->getTableName('catalog_product_entity_group_price');
$conn->delete($table_name, array('entity_id = '.$product->getId()));
2- Set the group price for the product to be empty, and save the product.
$product->setData('group_price', array())->save();
Performing either of these (no need to do both) PRIOR to setting your group price data and saving the product, will avoid the Integrity constraint violation, since they effectively remove the existing group price for the product. Approach 1 feels sketchy because we usually do not make direct sql queries and instead rely on model classes to have methods already built in place for us to encapsulate this logic, but in my test environment (Magento 1.9) it works. Approach 2 may seem safer, however it is more resource intensive since it is saving the entire product record, when all we really need to do is update/delete the existing group price. Plus it requires a redundant save since we're "saving to remove" the existing group price.
I recommend re-indexing Product Prices afterwards, as group price data is also stored in 'catalog_product_index_group_price'.
Try to use this extension for magmi group prices:
https://github.com/tim-bezhashvyly/magmi-grouped-price-plugin

how does upsert with external id work?

How does upsert work in the Salesforce API?
I believe that it checks it checks if there is a record with unique id. In the case that it is available, then it updates the record otherwise the record is created.
Is this correct?
I am receiving the following error
Upsert failed. First exception on row 1; first error: DUPLICATE_EXTERNAL_ID, Asset Tag: more than one record found for external id field: [a11M0000000CwJqIAK, a11M0000000CwJvIAK]: [Asset_Tag__c]
I have a list with items, and there are no duplicate Asset_Tag values.
system.debug('LstItem Asset_Tag__c'+LstItem );
upsert LstItem Asset_Tag__c;
From the debug log
LstItem Asset_Tag__c(Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=12149, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 06:08:47}, Item_c__c:{Scanned_By__c=005M0000000IlxyIAC, Asset_Tag__c=23157, Status__c=Active, Scan_Location__c=001M0000008GzJXIA0, Last_Scan_Date__c=2011-12-17 08:26:14})
What can I do to resolve this issue?
The error message indicates that, based on the External Id value you provided, there were two matching records. In this case, the system does not know which one it should update, so it fails.
If you take a look at /a11M0000000CwJqIAK and /a11M0000000CwJvIAK, they will have the same value in the external ID field. You may want to consider de-duplicating the records for this object.