Skip to content

Commit

Permalink
super
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasProgrammer committed Dec 20, 2023
1 parent ec21ad3 commit ad792b3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pos_disable_pricelist_selection/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ def onchange_hide_pricelist_button(self):
)

def write(self, vals):
if vals.get("available_pricelist_ids"):
if self and not vals.get("selectable_pricelist_ids"):
selectable = set(self.selectable_pricelist_ids.ids)
else:
selectable = set(vals["selectable_pricelist_ids"][0][2])
# leave only ids from available_pricelist_ids
intersection = list(
selectable.intersection(set(vals["available_pricelist_ids"][0][2]))
)
if intersection:
vals["selectable_pricelist_ids"] = [(6, 0, intersection)]
else:
vals["selectable_pricelist_ids"] = vals["available_pricelist_ids"]
for rec in self:
if vals.get("available_pricelist_ids"):
if rec and not vals.get("selectable_pricelist_ids"):
selectable = set(rec.selectable_pricelist_ids.ids)
else:
selectable = set(vals["selectable_pricelist_ids"][0][2])
# leave only ids from available_pricelist_ids
intersection = list(
selectable.intersection(set(vals["available_pricelist_ids"][0][2]))
)
if intersection:
vals["selectable_pricelist_ids"] = [(6, 0, intersection)]
else:
vals["selectable_pricelist_ids"] = vals["available_pricelist_ids"]
return super(PosConfig, self).write(vals)

0 comments on commit ad792b3

Please sign in to comment.