Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions product_replenishment_cost_currency_update/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions product_replenishment_cost_currency_update/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Replenishment Cost Currency Update",
"version": "16.0.1.0.0",
"author": "ADHOC SA",
"license": "AGPL-3",
"category": "Products",
"depends": [
"product_replenishment_cost",
"product_planned_price",
"l10n_ar_currency_update",
],
"data": [],
'installable': True,
'auto_install': False,
'application': False,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_company
31 changes: 31 additions & 0 deletions product_replenishment_cost_currency_update/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from odoo import api, models
from odoo.fields import Datetime
from datetime import timedelta


class ResCompany(models.Model):

_inherit = 'res.company'


@api.model
def update_currency_rates(self):
currency_changes = False
last_updates = {x.id: x.l10n_ar_last_currency_sync_date for x in self.search([('currency_provider', '=', 'afip'),
('currency_interval_unit', '!=', False)])}

super().update_currency_rates()
for company in last_updates.keys():
company_id = self.browse(company)
if company_id.l10n_ar_last_currency_sync_date != last_updates[company]:
currency_changes = True

if currency_changes:
self.env.ref(
"product_replenishment_cost.ir_cron_update_cost_from_replenishment_cost"
)._trigger(at=Datetime.now())
# Este parametro lo agregamos para que sea modificable el tiempo entre crons
time_difference = self.env['ir.config_parameter'].sudo().get_param("time_between_replenishment_costs","60")
self.env.ref(
"product_planned_price.ir_cron_update_price_from_planned"
)._trigger(at=Datetime.now() + timedelta(minutes=int(time_difference)))