Odoo - Can't Change Default Currency Company - odoo

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.

Related

How to reflect product price and quantity changes on journal entries of an invoice

I create a wizard that change price and quantity for each product but the amount_untaxed, tax_amount and total amount unchanged and journal entries are unbalanced. how to resolve that?
You should call _onchange_price_subtotal() on every changed invoice line (model account.move.line) to trigger the recomputation. The recomputation is only implemented for changes in the view, that's why it's isn't triggered when using a wizard. But the implementation can be used in the wizard, too, without any problems.
strong text_onchange_price_subtotal doesn't work. But
current_invoice_lines = rec.order_id.line_ids.filtered(lambda line: not line.exclude_from_invoice_tab)
others_lines = rec.order_id.line_ids - current_invoice_lines
if others_lines and current_invoice_lines - rec.order_id.invoice_line_ids:
others_lines[0].recompute_tax_line = True
rec.order_id.line_ids = others_lines + rec.order_id.invoice_line_ids
rec.order_id._onchange_recompute_dynamic_lines()
After adding the above code on account.move ... journal entries are balanced but tax_amount still unchanged?

CO currency for settlement process in CJ88

We have an issue with settlement in SAP.
If we post 1000CAD in settlement rule (cj02) for an asset #123456 to a project then it get settled 1000USD after settlement run.
But my question is why the CAD allocation is settling as USD? How can we solve this issue?
All transactions (incl. settlements) in CO-PA are done in Controlling Area currency that couldn't be changed. It seems that your CA currency is USD.
Check if flag All currencies is set in tcode OKKP, node Activate component indicators
If this is the case then your company uses different currencies for documents which are:
controlling area currency
object currency (=company code currency)
transaction currency (specified for each transaction).
By default all settlements are reconciled in company code currency so check if it is USD and change to desired value.
By and large, currency determination in CO-PA is very complex, check SAP note 1320586 for more details.

Odoo Invoice number - validating an invoice isn't re-using the internal_number if exists

Dears,
Usually, Upon Validating an invoice, it takes a new sequence from sequence (e.g. SAJ/%(year)s/), and in case that invoice has an internal_number (case of canceled invoice set to draft), it should use its internal_number. But the unwanted behavior now is when validating a draft invoice - previously canceled - the system generates new sequence number. I need to re-use the existing internal number.
Thank you,
Odoo 8
The problem was from a configuration in the Journal (account.journal) . Every time I validate an invoice it will create new Journal entry with new Sequence number (e.g. SAJ/2017/55545), so I unchecked the Autopost Created Move. Now. when I attemp to validate an invoice already canceled it will use it's existing internal_number as invoice number.
========================
Accounting-> Invoice -> Sales Journal (account.journal) -> untick Autopost Created Move
Scenario:
-create invoice, INV number N1 is assigned to inv
-state goes to OPEN
-cancel the invoice then set to draft: the number disappear from the interface
-validate the invoice -> new number became the same existing N1

How can I set the pricelist discount to a product when I create a sale order line? In Odoo 9

I have a function who retrieves sale orders from an external server.
Then, I insert each sale order with order lines in the odoo database.
Everything is inserted fine, except the discount.
I have the pricelist in the sale order, with a discount (for example, a discount of 10% in every product), but in all the sale order lines the discount is 0%.
If I add a sale order line manually, the discount appears correctly (10%).
This is my code:
vals = {}
vals['order_id'] = downloaded_sale_order_id
vals['product_id'] = downloaded_product_id
vals['product_uom'] = downloaded_product_uom
new_line_id = self.env['sale.order.line'].create(vals)
I have entered in debug mode and realized that if I call some of these functions after the creation, the discount is applied
Option 1:
new_line_id.product_id_change()
Option 2:
new_line_id.product_uom_change()
But... why they are not called when I launch the create order?
Am I missing something in the code?
You have following options for set discount inside the sale order line while creating it from external server source.
1) Just set discount as like other parameter like uom, product, price etc from the source data of external server if you got discount value from their.
2) You have to call product or uom onchange method to set the discount based on the onchange calling and this is the default and safe method to set most of the data according to the onchange. It will not miss any special fields which are inside any customization with onchange method. I specially recommend this method to use if any discount data is not coming from external server source.
3) You can manage manually calculation of discount based on the external server source like price and qty etc. And set it inside sale order line.
I hope this is very helpful to you. Do not hesitate to ask any thing if not clear.

Prestashop Tax Off When VAT Number Inserted

In my shop, when a user inserts a VAT number, the tax value desapears. I understand its comon practice abroad. But here in Portugal, the tax value is allways present.
I tried with Vat module and normal "NIF" field, but neither appears with tax value, or in the final invoice.
Im running, prestashop 1.6.0.8.
Someone with the same problem as me, another portuguese, says it got it workgin doing the folloying instrutions from a spanish tutorial:
In controllers/AuthController.php
Change
If ($country->need_identification_number && (!Tools::getValue(‘dni’) || !Validate::isDniLite(Tools::getValue(‘dni’))))
To
//if ($country->need_identification_number && (!Tools::getValue(‘dni’) || !Validate::isDniLite(Tools::getValue(‘dni’))))
if (!Validate::isDniLite(Tools::getValue(‘dni’)))
And in “controllers/”AddressController.php,
Change
if ($country->isNeedDni() && (!Tools::getValue(‘dni’) || !Validate::isDniLite(Tools::getValue(‘dni’))))
To
//if ($country->isNeedDni() && (!Tools::getValue(‘dni’) || !Validate::isDniLite(Tools::getValue(‘dni’))))
if (!Validate::isDniLite(Tools::getValue(‘dni’)))
But this code is for 1.5.x presta and mine is 1.6.0.8 and i guess dni is ther tax name.
Heres the source: http://postly.elnostreraco.com/como-hacer-el-dni-opcional-en-prestashop-y-por-que-desconfiar-si-te-hacen-tocar-codigo-base/
When using the VAT Module you can select a country. For users from that country (the one you selected in the module config), VAT will be added. For users from other countries, VAT will not be calculated, which, i believe, is in accordance with EU Law.
From here:
Your PrestaShop is misconfigured. When no "Your country" set in module "vatnumber" and your customer fill in the vat_number field, presta shop will force tax-free price.
I've selected country in this module (but not vat number validation) and it worked - user enter vat code or not, VAT is applied.