Skip to content

Commit

Permalink
[FIX] connector_pms_wubook: error exporting records older than 2 days…
Browse files Browse the repository at this point in the history
… ago
  • Loading branch information
eantones committed Jul 20, 2021
1 parent 1233928 commit 8b7a41c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields

from odoo.addons.component.core import Component

Expand Down Expand Up @@ -31,9 +32,14 @@ class ChannelWubookPmsAvailabilityPlanChildBinderMapperExport(Component):
_apply_on = "channel.wubook.pms.availability.plan.rule"

def skip_item(self, map_record):
return (
map_record.source.pms_property_id != self.backend_record.pms_property_id
or map_record.source.synced_export
return any(
[
map_record.source.pms_property_id
!= self.backend_record.pms_property_id,
map_record.source.synced_export,
# Wubook does not allow to update records older than 2 days ago
(fields.Date.today() - map_record.source.date).days > 2,
]
)

def get_all_items(self, mapper, items, parent, to_attr, options):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields

from odoo.addons.component.core import Component

Expand Down Expand Up @@ -28,7 +29,13 @@ class ChannelWubookPmsPropertyAvailabilityChildBinderMapperExport(Component):
def skip_item(self, map_record):
# TODO: filter this on get_all_items, creating a hook on the mapper
# to allow filtering them overriding the hook
return map_record.source.synced_export
return any(
[
map_record.source.synced_export,
# Wubook does not allow to update records older than 2 days ago
(fields.Date.today() - map_record.source.date).days > 2,
]
)

def get_all_items(self, mapper, items, parent, to_attr, options):
# TODO: this is always the same on every child binder mapper
Expand Down
25 changes: 16 additions & 9 deletions connector_pms_wubook/models/product_pricelist/mapper_export.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _
from odoo import _, fields
from odoo.exceptions import ValidationError

from odoo.addons.component.core import Component
Expand Down Expand Up @@ -41,18 +41,25 @@ class ChannelWubookProductPricelistChildBinderMapperExport(Component):
_apply_on = "channel.wubook.product.pricelist.item"

def skip_item(self, map_record):
return (
(
if (
map_record.source.date_start_consumption
!= map_record.source.date_end_consumption
):
raise ValidationError(
_("Consumption dates must be the same on daily pricelists")
)
return any(
[
not map_record.source.wubook_item_type
or map_record.parent.source.wubook_plan_type
!= map_record.source.wubook_item_type
)
or (
!= map_record.source.wubook_item_type,
map_record.source.pms_property_ids
and self.backend_record.pms_property_id
not in map_record.source.pms_property_ids
)
or map_record.source.synced_export
not in map_record.source.pms_property_ids,
map_record.source.synced_export,
(fields.Date.today() - map_record.source.date_start_consumption).days
> 2,
]
)

def get_all_items(self, mapper, items, parent, to_attr, options):
Expand Down

0 comments on commit 8b7a41c

Please sign in to comment.