Skip to content

Commit

Permalink
[IMP] connector_oxigesti: allow delete items if the user is not a man…
Browse files Browse the repository at this point in the history
…ager & avoid problems if you delete the pricelist
  • Loading branch information
FrankC013 committed Jan 17, 2024
1 parent 0965df8 commit 953f37d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions connector_oxigesti/models/product_pricelist_item/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
from odoo.exceptions import ValidationError


class Pricelist(models.Model):
_inherit = "product.pricelist"

# TODO: Review use deleter to mark items as deprecated
def unlink(self):
for rec in self:
if rec.item_ids.oxigesti_bind_ids:
raise ValidationError(

Check warning on line 17 in connector_oxigesti/models/product_pricelist_item/binding.py

View check run for this annotation

Codecov / codecov/patch

connector_oxigesti/models/product_pricelist_item/binding.py#L17

Added line #L17 was not covered by tests
_(
"You can't delete a pricelist that has been exported "
"the product prices by customer to Oxigesti. If you "
"want to delete it, you must first delete the items "
"of the pricelist."
)
)
return super().unlink()

Check warning on line 25 in connector_oxigesti/models/product_pricelist_item/binding.py

View check run for this annotation

Codecov / codecov/patch

connector_oxigesti/models/product_pricelist_item/binding.py#L25

Added line #L25 was not covered by tests


class ProductPricelistItem(models.Model):
_inherit = "product.pricelist.item"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ProductPricelistItemListener(Component):
_apply_on = "product.pricelist.item"

def on_record_unlink(self, relation):
bindings = relation.oxigesti_bind_ids
bindings = relation.sudo().oxigesti_bind_ids

Check warning on line 14 in connector_oxigesti/models/product_pricelist_item/listener.py

View check run for this annotation

Codecov / codecov/patch

connector_oxigesti/models/product_pricelist_item/listener.py#L14

Added line #L14 was not covered by tests
for backend in bindings.with_context(
pricelist_item_unlink=relation.id
).backend_id:
Expand Down

0 comments on commit 953f37d

Please sign in to comment.