From 468a089533fd3c6d659db36e30793cf57116b199 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 6 May 2015 10:37:35 +0200 Subject: [PATCH] Use prescription required field from product --- CHANGELOG | 2 ++ feed_production.py | 12 +++--------- feed_production.xml | 15 --------------- locale/ca_ES.po | 4 ---- locale/es_ES.po | 4 ---- tests/scenario_farm_feed_production.rst | 10 +++------- view/supply_request_line_form.xml | 9 --------- view/supply_request_line_list.xml | 8 -------- 8 files changed, 8 insertions(+), 56 deletions(-) delete mode 100644 view/supply_request_line_form.xml delete mode 100644 view/supply_request_line_list.xml diff --git a/CHANGELOG b/CHANGELOG index ae81dbb..481f59d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,2 +1,4 @@ +* Use prescription required field from product + Version 3.4.0 - 2015-01-22 * Initial release diff --git a/feed_production.py b/feed_production.py index 7cf026a..a9fc846 100644 --- a/feed_production.py +++ b/feed_production.py @@ -21,8 +21,6 @@ PRESCRIPTION_CHANGES = BOM_CHANGES[:] + ['prescription'] class SupplyRequestLine: __name__ = 'stock.supply_request.line' - prescription_required = fields.Boolean('Prescription Required') - @classmethod def __setup__(cls): super(SupplyRequestLine, cls).__setup__() @@ -32,17 +30,12 @@ class SupplyRequestLine: 'configured as a farm for none specie.'), }) - @fields.depends('product') - def on_change_with_prescription_required(self): - return (True if self.product and self.product.prescription_template - else False) - def get_move(self): pool = Pool() Prescription = pool.get('farm.prescription') move = super(SupplyRequestLine, self).get_move() - if self.prescription_required: + if self.product.prescription_required: with Transaction().set_user(0, set_context=True): prescription = self.get_prescription() prescription.save() @@ -163,7 +156,8 @@ class Production: return if self.from_supply_request and ( - self.origin.prescription_required and not self.prescription or + self.origin.product.prescription_required and + not self.prescription or self.prescription != self.origin.move.prescription): self.raise_user_error('from_supply_request_invalid_prescription', { 'production': self.rec_name, diff --git a/feed_production.xml b/feed_production.xml index 3305af0..6e6b84b 100644 --- a/feed_production.xml +++ b/feed_production.xml @@ -3,21 +3,6 @@ copyright notices and license terms. --> - - - stock.supply_request.line - - supply_request_line_form - - - - stock.supply_request.line - - supply_request_line_list - - production diff --git a/locale/ca_ES.po b/locale/ca_ES.po index 7710c73..d7a5d0c 100644 --- a/locale/ca_ES.po +++ b/locale/ca_ES.po @@ -55,7 +55,3 @@ msgstr "" msgctxt "field:production,prescription:" msgid "Prescription" msgstr "Recepta" - -msgctxt "field:stock.supply_request.line,prescription_required:" -msgid "Prescription Required" -msgstr "" diff --git a/locale/es_ES.po b/locale/es_ES.po index 02825b2..ad49b03 100644 --- a/locale/es_ES.po +++ b/locale/es_ES.po @@ -72,7 +72,3 @@ msgstr "Producción origen" msgctxt "field:production,prescription:" msgid "Prescription" msgstr "Receta" - -msgctxt "field:stock.supply_request.line,prescription_required:" -msgid "Prescription Required" -msgstr "Requiere receta" diff --git a/tests/scenario_farm_feed_production.rst b/tests/scenario_farm_feed_production.rst index a277683..7632878 100644 --- a/tests/scenario_farm_feed_production.rst +++ b/tests/scenario_farm_feed_production.rst @@ -346,24 +346,20 @@ Create a supply request of 100 Kg of feed for individuals in location L1 and ... from_warehouse=warehouse, ... to_warehouse=farm, ... lines=[]) - >>> line1 = SupplyRequestLine() - >>> supply_request.lines.append(line1) + >>> line1 = supply_request.lines.new() >>> line1.product = feed_product >>> line1.quantity = 100 >>> line1.to_location = location1 - >>> line2 = SupplyRequestLine() - >>> supply_request.lines.append(line2) + >>> line2 = supply_request.lines.new() >>> line2.product = feed_product >>> line2.quantity = 100 >>> line2.to_location = location2 - >>> line2.prescription_required = True >>> supply_request.save() Confirm supply request and check that moves, productions and prescriptions has been created:: - >>> SupplyRequest.confirm([supply_request.id], config.context) - >>> supply_request.reload() + >>> supply_request.click('confirm') >>> supply_request.state u'confirmed' >>> for line in supply_request.lines: diff --git a/view/supply_request_line_form.xml b/view/supply_request_line_form.xml deleted file mode 100644 index d1ff87f..0000000 --- a/view/supply_request_line_form.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/view/supply_request_line_list.xml b/view/supply_request_line_list.xml deleted file mode 100644 index 2cbc180..0000000 --- a/view/supply_request_line_list.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - -