Mercurial > hgweb > health
changeset 3453:226d4f2fc702
Fix bug task #15470: Crash when listing the medicaments
It is now better to use the standard functionality to
check the product quantity per location / warehouse.
That will also improve performance.
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Tue, 19 Nov 2019 08:02:47 +0000 |
| parents | 5ca9a99474fa |
| children | 4b50e27fd11a |
| files | tryton/health_stock/__init__.py tryton/health_stock/health_stock.py tryton/health_stock/health_stock_view.xml |
| diffstat | 3 files changed, 8 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_stock/__init__.py +++ b/tryton/health_stock/__init__.py @@ -28,7 +28,6 @@ def register(): Pool.register( - Medicament, Party, Lot, Move,
--- a/tryton/health_stock/health_stock.py +++ b/tryton/health_stock/health_stock.py @@ -30,7 +30,7 @@ from trytond.pool import Pool, PoolMeta from functools import reduce -__all__ = ['Medicament', 'Party', 'Lot', 'Move', +__all__ = ['Party', 'Lot', 'Move', 'PatientAmbulatoryCare', 'PatientAmbulatoryCareMedicament', 'PatientAmbulatoryCareMedicalSupply', 'PatientRounding', 'PatientRoundingMedicament', @@ -43,30 +43,15 @@ _DEPENDS = ['state'] +""" +Deprecated : Using now the quantity related to the product class Medicament(metaclass=PoolMeta): __name__ = 'gnuhealth.medicament' quantity = fields.Function(fields.Float('Quantity'), 'get_quantity') - def get_quantity(self, name): - pool = Pool() - Date = pool.get('ir.date') - Location = pool.get('stock.location') - Product = pool.get('product.product') - - locations = Location.search([('type', '=', 'storage')]) - Transaction().set_context({'locations': [l.id for l in locations]}) - context = {} - context['stock_date_end'] = Date.today() - Transaction().set_context(context) - - pbl = Product.products_by_location( - location_ids=Transaction().context['locations'], - product_ids=[self.name.id], with_childs=True) - quantity = 0.00 - if list(pbl.values()): - quantity = reduce(lambda x, y: x + y, list(pbl.values())) - return quantity - + def get_quantity(self,name): + return self.name.quantity +""" class Party(metaclass=PoolMeta): __name__ = 'party.party'
--- a/tryton/health_stock/health_stock_view.xml +++ b/tryton/health_stock/health_stock_view.xml @@ -15,11 +15,13 @@ <!-- Main views --> +<!-- Deprecated. Use now relate functionality at the product level <record model="ir.ui.view" id="gnuhealth_medicament_tree_stock"> <field name="model">gnuhealth.medicament</field> <field name="inherit" ref="health.gnuhealth_medicament_tree"/> <field name="name">gnuhealth_medicament_tree_stock</field> </record> +--> <record model="ir.ui.view" id="view_party_form"> <field name="model">party.party</field>
