← Back to team overview

openerp-connector-community team mailing list archive

Re: Import sales orders ONLY if created after a given date

 

On Wed, Sep 16, 2015 at 10:55 AM, Ahmad Ababneh <ababneh.a1@xxxxxxxxx> wrote:
> Hello,
>
> We would like to import sales orders created after a given date, ignoring
> all other orders created before that date.
>
> We have implemented a solution to exclude those sales orders. We simply
> raise a "NothingToDo" exception in the "check" method of the
> "SaleImportRule" class, if the sales order is too old.
>
> However, this solution seems too resource and time consuming. Since, each
> time we import sales orders, the import process will fetch all the old sales
> orders, create a job for each sale order, check the "created_at" value for
> each record, then decide to exclude that sales order.
>
> We will perform "Import sales orders" frequently. It seems so expensive and
> time-consuming for each time we import the sales orders, as we have a lot of
> old sales orders.
>
> Here is my code;
> @magento_myversion
> class MySaleImportRule(SaleImportRule):
>     def check(self, record):
>         if record['created_at'] > '2015/9/15' :
>             super(MySaleImportRule, self).check(record)
>         else:
>             raise NothingToDoJob('Order too old')
>
> What are the other "faster" solutions, to exclude the old sales orders when
> importing?
>
> Thank you a lot :) :)
> Ahmed Ababneh
>
>

Hi,

It seems that you could simply set your date in the
'import_orders_from_date field' on the storeviews.
See https://github.com/OCA/connector-magento/blob/8.0/magentoerpconnect/magento_model.py#L470-L474


References