Override translation from original module - odoo

How can I override translation of default_code field?
in inherited Product Template and Product Product, I added fields
default_code = fields.Char(
string='Articul',
related='product_variant_ids.default_code')
and
default_code = fields.Char(
'Articul', select=True)
string changes in the English version but if I change to my language then I get an original translation.
So i tried to copy a part from original modules translation and add it to my po file like this.
#. module: product
#: model:ir.model.fields,field_description:product.field_product_product_default_code
#: model:ir.model.fields,field_description:product.field_product_template_default_code
msgid "Articul"
msgstr "Articulas"
it works but when I want to update my file with Poedit I getting an error
2018 m. liepos 30 d. 15:43:37: /tmp/poedituUNIro/1input.po:1023: duplicate message definition...
2018 m. liepos 30 d. 15:43:37: /tmp/poedituUNIro/1input.po:169: ...this is the location of the first definition
2018 m. liepos 30 d. 15:43:37: msgmerge: found 1 fatal error
2018 m. liepos 30 d. 15:43:37: Entries in the catalog are probably incorrect.
2018 m. liepos 30 d. 15:43:37: Updating the catalog failed. Click on 'Details >>' for details.

No need to redeclare the field string!
Export the translation file from the add-ons you want to override.
Translate it using POEeit or similar.
Drop the translation file inside a i18n_extra folder in the addon. E.g.: addon/i18n_extra/fr.pot
Update the addon.
With that system, a submodule is able to override translations from parent modules.

Related

Odoo - Can't Change Default Currency Company

I want to change the company currency by opening Setting->Companies->Currency. But when I already change the currency and hit save button, I get this warning dialog
You cannot change the currency of the company since some journal items already exist
How to solve this problem?
You cannot change the currency of the company since some journal items already exist
Some data are already created with the same currency, if you do not need that entry then simply delete it and then change the currency.
reference code - Source Code
#forbid the change of currency_id if there are already some accounting entries existing
if 'currency_id' in values and values['currency_id'] != company.currency_id.id:
if self.env['account.move.line'].search([('company_id', '=', company.id)]):
raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
The error occurs because there was journal entries exist. You have at least 2 options if you must change the company currency:
Delete all journal entries.
Update all currency ID in all journal entries with new currency id directly via PostgreSQL.
Once option 1 or 2 done, then try again to change the company currency.

Cannot create unbalanced journal entry. Ids: Differences debit - credit Error when trying to create an invoice line

I'm trying to create an invoice line using the Web APIs and XML-RPC (python). I receive this error while creating it.
xmlrpc.client.Fault: <Fault 2: 'Cannot create unbalanced journal entry. Ids: [12083]\nDifferences debit - credit: [-2629.33]'>
I'm creating the invoice line as follows:
inv_line_id = models.execute_kw(
db, uid, password,
'account.move.line',
'create'[
{'move_id':invoice_id,
'product_id':product_id[0]['id'],
'price_unit':product_id[0]['list_price'],
'quantity':sale_line_id[0]['product_uom_qty'],
'account_id':account_id[0]['property_account_income_categ_id'][0]
}
]
)
If i dont add the 'price_unit' the invoice line is being created normally but without a price.
Anyone knows how to fix this ? Thanks in advance
If you are in the same version of me (V13) or if the code is the same in your version. You could pass a value in the context to don't check the balanced.
'check_move_validity' = False
Find in the file account/models/account_move.py . Line 1721 in method write
# Ensure the move is still well balanced.
if 'line_ids' in vals:
if self._context.get('check_move_validity', True):
self._check_balanced()
self.update_lines_tax_exigibility()
During the create or write of an account.move with only invoice_line_ids set and not line_ids, the _move_autocomplete_invoice_lines_create or _move_autocomplete_invoice_lines_write method is called to auto compute accounting lines of the invoice. In that case, accounts will be retrieved and taxes, cash rounding, and payment terms will be computed. In the end, the values will contain all accounting lines in line_ids and the moves should be balanced.
Latest version of Odoo 13 dated December 10, 2021.
Edit file: /path_of_odoo/addons/account/models/account_move.py
Example:
vim /odoo/addons/account/models/account_move.py
Modify function named _check_balanced and comment line 1582 and add new line whit return
Example:
############################### Before ##################################
############################### A F T E R ###############################

Table name is too long odoo 13

I am getting this error after adding a binary filed I remover the filed but getting the same error
Table name 'n_hesaby_subscription_manager_subscription_manager_res_users_rel' is too long
odoo.exceptions.ValidationError: ("Table name 'n_hesaby_subscription_manager_subscription_manager_res_users_rel' is too long", None) - - -
does anyone know what it means, I can't find it
From the look of the table name it's created from a many2many field between n_hesaby_subscription_manager_subscription_manager and res.users when you don't provide a name for the relation table Odoo will generate it for you model_1_name_model_2_name_rel.
So in your many2many definition specify a shorter name
m2m_field_name = fields.Many2many(comodel_name='res.users',
relation='put_nice_table_name_here',
column1='put_nice_and_short_field_name_here_to',
column2='user_id',
string='You field label')
I'm using my phone sorry for my short answer I hope you get the idea, you can check Odoo standard modules you will find planty of examples.
Always specify the name of the relation in your many2many field is a good practice prevent unexpected behavior.

Odoo 12. Missing required value for the field 'Object' (model_id) when I change the permission file ir.model.access.csv and upgrade the module

I have created my own module in odoo 12. And I have change the permission file- ir.model.access.csv. All the code is as below.
ir.model.access.csv :
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_student_student,access.student.student,model_student_student,,1,1,1,0
./models/models :
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class StudentStudent(models.Model):
_name = "student.student"
_description = "description"
name = fields.Char(string="Name", required=True)
age = fields.Integer(string="Age")
photo = fields.Binary(string="Image")
gender = fields.Selection(
[("male", "Male"), ("female", "Female"), ("others", "Others")], string="Gender"
)
student_dob = fields.Date(string="Date of Birth")
student_blood_group = fields.Selection(
[
("A+", "A+ve"),
("B+", "B+ve"),
("O+", "O+ve"),
("AB+", "AB+ve"),
("A-", "A-ve"),
("B-", "B-ve"),
("O-", "O-ve"),
("AB-", "AB-ve"),
],
string="Blood Group",
)
nationality = fields.Many2one("res.country", string="Nationality")
error message occur when I try to upgrade my module :
Exception: Module loading assettracking failed: file assettracking\security/ir.model.access.csv could not be processed:
No matching record found for external id 'model_student_student' in field 'Object'
Missing required value for the field 'Object' (model_id)
Check if your model is loaded into the database, if not restart your server before upgrading to load it. If you already did that try using: module_name.model_student_student in your CSV file.
Please check whether you have written init.py file for student.student model.
If yes then please try below code in .csv fileaccess_student_student,access_student_student,model_student_student,,1,1,1,0
A trick i usually do is I add a model and then start the server process, the system will give me a warning that this model does not have permissions and gives u an example of the line to add to ir.model.access.csv. I copy that from the shell window and paste it into ir.model.access.csv and edit accordingly.
With Odoo 12 i have found that you need to specify a user group and in the ir.model.access.csv file. If i do not specify the user group, the menu item would not appear for my users.
I have set custom user groups with differing permissions, but the usual default is to specify permissions for base.erp_user & base.erp_manager. An example of the entries would be
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_student_student_user,access_student_student_user,model_student_student,base.group_user,1,1,1,0
access_student_student_admin,access_student_student_admin,model_student_student,base.group_erp_manager,1,1,1,1
With the above example, ordinary users will be able to create, read and edit a student record but they cannot delete records, while an administrator can delete records. If u specify custom users groups the menu option for Students will only appear if the logged on user is in those groups.

Error: Not found: Dataset my-project-name:domain_public was not found in location US

I need to make a query for a dataset provided by a public project. I created my own project and added their dataset to my project. There is a table named: domain_public. When I make query to this table I get this error:
Query Failed
Error: Not found: Dataset my-project-name:domain_public was not found in location US
Job ID: my-project-name:US.bquijob_xxxx
I am from non-US country. What is the issue and how to fix it please?
EDIT 1:
I change the processing location to asia-northeast1 (I am based in Singapore) but the same error:
Error: Not found: Dataset censys-my-projectname:domain_public was not found in location asia-northeast1
Here is a view of my project and the public project censys-io:
Please advise.
EDIT 2:
The query I used to type is based on censys tutorial is:
#standardsql
SELECT domain, alexa_rank
FROM domain_public.current
WHERE p443.https.tls.cipher_suite = 'some_cipher_suite_goes_here';
When I changed the FROM clause to:
FROM `censys-io.domain_public.current`
And the last line to:
WHERE p443.https.tls.cipher_suite.name = 'some_cipher_suite_goes_here';
It worked. Shall I understand that I should always include the projectname.dataset.table (if I'm using the correct terms) and point the typo the Censys? Or is this special case to this project for some reason?
BigQuery can't find your data
How to fix it
Make sure your FROM location contains 3 parts
A project (e.g. bigquery-public-data)
A database (e.g. hacker_news)
A table (e.g. stories)
Like so
`bigquery-public-data.hacker_news.stories`
*note the backticks
Examples
Wrong
SELECT *
FROM `stories`
Wrong
SELECT *
FROM `hacker_news.stories`
Correct
SELECT *
FROM `bigquery-public-data.hacker_news.stories`
In Web UI - click Show Options button and than select your location for "Processing Location"!
Specify the location in which the query will execute. Queries that run in a specific location may only reference data in that location. For data in US/EU, you may choose Unspecified to run the query in the location where the data resides. For data in other locations, you must specify the query location explicitly.
Update
As it stated above - Queries that run in a specific location may only reference data in that location
Assuming that censys-io.domain_public dataset has its data in US - you need to specify US for Processing Location
The problem turned out to be due to wrong table name in the FROM clause.
The right FROM clause should be:
FROM `censys-io.domain_public.current`
While I was typing:
FROM domain_public.current
So the project name is required in the FROM and `` are required because of - in the project name.
Make sure your FROM location contains 3 parts as #stevec mentioned
A project (e.g. bigquery-public-data)
A database (e.g. hacker_news)
A table (e.g. stories)
But in my case, I was using the LegacySql within the Google script editor, so in that case you need to state that to false, for example:
var projectId = 'xxxxxxx';
var request = {
query: 'select * from project.database.table',
useLegacySql: false
};
var queryResults = BigQuery.Jobs.query(request, projectId);
check exact case [upper or lower] and spelling of table or view name.
copy it from table definition and your problem will be solved.
i was using FPL009_Year_Categorization instead of FPL009_Year_categorization
using c as C and getting the error "not found in location asia-south1"
I copied with exact case and problem is resolved.
On your Big Query console, go to the Data Explorer on the left pane, click the small three dots, then select query option from the list. This step confirms you choose the correct project and dataset. Then you can edit the query on the query pane on the right.
may be dataset name changed in create dataset option. it should be US or default location
enter image description here