diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c26baa..0c46d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ All notable changes to pyCOREPOS will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.5.1 (2025-02-20) - -### Fix - -- add `Product.default_vendor_item` convenience property - ## v0.5.0 (2025-02-01) ### Feat diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 60ad478..e374d37 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -583,32 +583,6 @@ class Product(common.ProductBase, Base): creator=lambda lc: ProductLikeCode(like_code=lc), ) - vendor_items = orm.relationship( - 'VendorItem', - back_populates='product', - primaryjoin='VendorItem.upc == Product.upc', - foreign_keys='VendorItem.upc', - order_by='VendorItem.vendor_item_id', - doc=""" - List of :class:`VendorItem` records for this product. - """) - - @property - def default_vendor_item(self): - """ - Returns the "default" vendor item record. This will - correspond to the :attr:`default_vendor` if possible. - - :rtype: :class:`VendorItem` or ``None`` - """ - if self.default_vendor: - for item in self.vendor_items: - if item.vendor_id == self.default_vendor.id: - return item - - if self.vendor_items: - return self.vendor_items[0] - @property def full_description(self): fields = ['brand', 'description', 'size'] @@ -758,12 +732,17 @@ class VendorItem(Base): upc = sa.Column(sa.String(length=13), nullable=False) product = orm.relationship( Product, - back_populates='vendor_items', primaryjoin=Product.upc == upc, foreign_keys=[upc], doc=""" Reference to the :class:`Product` to which this record applies. - """) + """, + backref=orm.backref( + 'vendor_items', + order_by=vendor_item_id, + doc=""" + List of :class:`VendorItem` records for this product. + """)) brand = sa.Column(sa.String(length=50), nullable=True) diff --git a/pyproject.toml b/pyproject.toml index cf50f41..35eb3a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "pyCOREPOS" -version = "0.5.1" +version = "0.5.0" description = "Python Interface to CORE POS" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]