Pricing cron
This commit is contained in:
@@ -1270,20 +1270,39 @@ class Pricing(ModelSQL,ModelView):
|
||||
"Pricing component must belong to the related line.")
|
||||
|
||||
@classmethod
|
||||
def _sync_eod_price(cls, records):
|
||||
if not records:
|
||||
return
|
||||
with Transaction().set_context(skip_pricing_eod_sync=True):
|
||||
for record in records:
|
||||
def _sync_eod_price(cls, records):
|
||||
if not records:
|
||||
return
|
||||
with Transaction().set_context(skip_pricing_eod_sync=True):
|
||||
for record in records:
|
||||
eod_price = record.compute_eod_price()
|
||||
if Decimal(str(record.eod_price or 0)) == Decimal(str(eod_price or 0)):
|
||||
continue
|
||||
super(Pricing, cls).write([record], {
|
||||
'eod_price': eod_price,
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def _is_manual_pricing_record(cls, record):
|
||||
super(Pricing, cls).write([record], {
|
||||
'eod_price': eod_price,
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def update_daily_pricing(cls):
|
||||
PurchaseLine = Pool().get('purchase.line')
|
||||
SaleLine = Pool().get('sale.line')
|
||||
|
||||
purchase_lines = PurchaseLine.search([])
|
||||
sale_lines = SaleLine.search([])
|
||||
|
||||
for line in purchase_lines:
|
||||
line.check_pricing()
|
||||
|
||||
for sale_line in sale_lines:
|
||||
sale_line.check_pricing()
|
||||
|
||||
logger.info(
|
||||
"Updated pricing for %s purchase line(s) and %s sale line(s)",
|
||||
len(purchase_lines),
|
||||
len(sale_lines))
|
||||
|
||||
@classmethod
|
||||
def _is_manual_pricing_record(cls, record):
|
||||
component = getattr(record, 'price_component', None)
|
||||
if component is None:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user