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?.
Related
I want to add a constraint but I don't have the idea of how to do it. I created a custom export which auto-generates external ids for each record I export. The export contains a list of students which the lecturer has to update their marks.. and re-imports the same excel sheet which also updates the marks of the students.
However much there is some information which I don't want the lecturers to update but I have failed to restrict the lecturer from importing the data in case those field values have been updated.
Any Ideas, Thank you.
If a student is a res.partner and you're a bit technical (eg: you know how to code in Odoo), you can migrate this module partner_changeset to version 12. It's only available for v10 now.
This module allows an administrator to setup rules on some fields of res.partner object. With this rule, you can discard changes made by a user or send the change to validation to an "admin".
I want to put a control check on a field (TIN) so that everytime I create a new customer, the TIN should be unique. If another customer has that TIN, an error message must show up.
I tried this syntax:
_sql_constraints=[('uniq_vat', 'UNIQUE(self.env.vat)',
'It already exists another company with the same TIN!')]
I'm using odoo 10.
Constrains can be of two types.
Application Constraints
Database Constraints
Database Constraints
Database constraints will add validation at database level while you upgrade that module. Database constraints is list of tuples, in which tuple contains three arguments.
_sql_constraints = [
('constrain name', 'unique(field1, field2)', 'error message which you want to raise on constrains violation'),
('constrain name', 'constrains defination', 'error message which you want to raise on constrains violation'),
]
Constraints name
Constraints, like unique, check
unique constraints can be applied to many columns.
Error message
Example:
_sql_constraints = [
('uniq_vat', 'unique(vat)', 'It already exists another company with the same TIN!'),
]
Multiple database constraints can be added together.
Application Constraints
Application constraints is used to fire custom validation at the time of record add, update and delete. In short your custom method will be called if any changes happen with record.
How to define constrains in code.
#api.constrains('field1','field2'....)
Constrains can be applied to multiple fields together, you can also define it separately.
#api.constrains('vat')
def check_vatnumber(self):
for record in self:
obj = self.search([('vat','=',record.vat),('id','!=',record.id)])
if obj:
raise Warning("Warning", "It already exists another company with the same TIN!")
_sql_constraints = [('unique_tin_no', 'unique(field_name)', 'It already exists another company with the same TIN!')]
Small change is in your line and your constrain work correctly
_sql_constraints=[('uniq_vat', 'unique(vat)', 'It already exists another company with the same TIN!')]
you just need to put "vat" in place of "self.env.vat" sql_constrains just needs field name which is going to apply on DB table underneath.
In invoice when i'm trying to register a payment this error message shows up :
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: name - name]
I cheked the access rights but nothing, the error message still appears.
Note1: I am able to register payment if I use admin user.
Note2: Not sure if it could be releated with having multicompany enabled.
EDIT1:
Checking Odoo server logs I found this:
bad query: INSERT INTO "account_full_reconcile" ("id", "name", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('account_full_reconcile_id_seq'), NULL, 7, 7, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
EDIT2:
In the previous bad query error can be seen that problem is that "name" field is Null.Label for this field is "Number".
So checking "account_full_reconcile" table in Odoo database, in the column "name" I have two non-consecutive values: "A1" and "A4".
Also in column "id" there are non-consecutive id: "19" and "30". Not sure if It's related with the error.
In odoo 9 the screen at "From Technical -- sequences -- Account reconcile sequence" doesn't have option to set company, so odoo9 users can do just duplicate it and create a new record and from backend in the database update that new record company_id value with your compant id
I think I found out...I had to manually create an "account Reconcile Sequence" record for the 2nd company...just duplicated and cahnge Company. From Technical -- sequences -- Account reconcile sequence.
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.
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.