mirror of
https://github.com/NaN-tic/trytond-farm_feed_production.git
synced 2023-12-14 05:52:53 +01:00
Use prescription required field from product
This commit is contained in:
parent
f364ce3133
commit
468a089533
8 changed files with 8 additions and 56 deletions
|
@ -1,2 +1,4 @@
|
||||||
|
* Use prescription required field from product
|
||||||
|
|
||||||
Version 3.4.0 - 2015-01-22
|
Version 3.4.0 - 2015-01-22
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|
|
@ -21,8 +21,6 @@ PRESCRIPTION_CHANGES = BOM_CHANGES[:] + ['prescription']
|
||||||
class SupplyRequestLine:
|
class SupplyRequestLine:
|
||||||
__name__ = 'stock.supply_request.line'
|
__name__ = 'stock.supply_request.line'
|
||||||
|
|
||||||
prescription_required = fields.Boolean('Prescription Required')
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(SupplyRequestLine, cls).__setup__()
|
super(SupplyRequestLine, cls).__setup__()
|
||||||
|
@ -32,17 +30,12 @@ class SupplyRequestLine:
|
||||||
'configured as a farm for none specie.'),
|
'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):
|
def get_move(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Prescription = pool.get('farm.prescription')
|
Prescription = pool.get('farm.prescription')
|
||||||
|
|
||||||
move = super(SupplyRequestLine, self).get_move()
|
move = super(SupplyRequestLine, self).get_move()
|
||||||
if self.prescription_required:
|
if self.product.prescription_required:
|
||||||
with Transaction().set_user(0, set_context=True):
|
with Transaction().set_user(0, set_context=True):
|
||||||
prescription = self.get_prescription()
|
prescription = self.get_prescription()
|
||||||
prescription.save()
|
prescription.save()
|
||||||
|
@ -163,7 +156,8 @@ class Production:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.from_supply_request and (
|
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.prescription != self.origin.move.prescription):
|
||||||
self.raise_user_error('from_supply_request_invalid_prescription', {
|
self.raise_user_error('from_supply_request_invalid_prescription', {
|
||||||
'production': self.rec_name,
|
'production': self.rec_name,
|
||||||
|
|
|
@ -3,21 +3,6 @@
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
<!-- stock.supply_request.line -->
|
|
||||||
<record model="ir.ui.view" id="supply_request_line_view_form">
|
|
||||||
<field name="model">stock.supply_request.line</field>
|
|
||||||
<field name="inherit"
|
|
||||||
ref="stock_supply_request.supply_request_line_view_form"/>
|
|
||||||
<field name="name">supply_request_line_form</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record model="ir.ui.view" id="supply_request_line_view_list">
|
|
||||||
<field name="model">stock.supply_request.line</field>
|
|
||||||
<field name="inherit"
|
|
||||||
ref="stock_supply_request.supply_request_line_view_list"/>
|
|
||||||
<field name="name">supply_request_line_list</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- production -->
|
<!-- production -->
|
||||||
<record model="ir.ui.view" id="production_view_form">
|
<record model="ir.ui.view" id="production_view_form">
|
||||||
<field name="model">production</field>
|
<field name="model">production</field>
|
||||||
|
|
|
@ -55,7 +55,3 @@ msgstr ""
|
||||||
msgctxt "field:production,prescription:"
|
msgctxt "field:production,prescription:"
|
||||||
msgid "Prescription"
|
msgid "Prescription"
|
||||||
msgstr "Recepta"
|
msgstr "Recepta"
|
||||||
|
|
||||||
msgctxt "field:stock.supply_request.line,prescription_required:"
|
|
||||||
msgid "Prescription Required"
|
|
||||||
msgstr ""
|
|
||||||
|
|
|
@ -72,7 +72,3 @@ msgstr "Producción origen"
|
||||||
msgctxt "field:production,prescription:"
|
msgctxt "field:production,prescription:"
|
||||||
msgid "Prescription"
|
msgid "Prescription"
|
||||||
msgstr "Receta"
|
msgstr "Receta"
|
||||||
|
|
||||||
msgctxt "field:stock.supply_request.line,prescription_required:"
|
|
||||||
msgid "Prescription Required"
|
|
||||||
msgstr "Requiere receta"
|
|
||||||
|
|
|
@ -346,24 +346,20 @@ Create a supply request of 100 Kg of feed for individuals in location L1 and
|
||||||
... from_warehouse=warehouse,
|
... from_warehouse=warehouse,
|
||||||
... to_warehouse=farm,
|
... to_warehouse=farm,
|
||||||
... lines=[])
|
... lines=[])
|
||||||
>>> line1 = SupplyRequestLine()
|
>>> line1 = supply_request.lines.new()
|
||||||
>>> supply_request.lines.append(line1)
|
|
||||||
>>> line1.product = feed_product
|
>>> line1.product = feed_product
|
||||||
>>> line1.quantity = 100
|
>>> line1.quantity = 100
|
||||||
>>> line1.to_location = location1
|
>>> line1.to_location = location1
|
||||||
>>> line2 = SupplyRequestLine()
|
>>> line2 = supply_request.lines.new()
|
||||||
>>> supply_request.lines.append(line2)
|
|
||||||
>>> line2.product = feed_product
|
>>> line2.product = feed_product
|
||||||
>>> line2.quantity = 100
|
>>> line2.quantity = 100
|
||||||
>>> line2.to_location = location2
|
>>> line2.to_location = location2
|
||||||
>>> line2.prescription_required = True
|
|
||||||
>>> supply_request.save()
|
>>> supply_request.save()
|
||||||
|
|
||||||
Confirm supply request and check that moves, productions and prescriptions has
|
Confirm supply request and check that moves, productions and prescriptions has
|
||||||
been created::
|
been created::
|
||||||
|
|
||||||
>>> SupplyRequest.confirm([supply_request.id], config.context)
|
>>> supply_request.click('confirm')
|
||||||
>>> supply_request.reload()
|
|
||||||
>>> supply_request.state
|
>>> supply_request.state
|
||||||
u'confirmed'
|
u'confirmed'
|
||||||
>>> for line in supply_request.lines:
|
>>> for line in supply_request.lines:
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
|
||||||
copyright notices and license terms. -->
|
|
||||||
<data>
|
|
||||||
<xpath expr="/form/field[@name='delivery_date']" position="after">
|
|
||||||
<label name="prescription_required"/>
|
|
||||||
<field name="prescription_required"/>
|
|
||||||
</xpath>
|
|
||||||
</data>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
|
||||||
copyright notices and license terms. -->
|
|
||||||
<data>
|
|
||||||
<xpath expr="/tree/field[@name='delivery_date']" position="after">
|
|
||||||
<field name="prescription_required"/>
|
|
||||||
</xpath>
|
|
||||||
</data>
|
|
Loading…
Reference in a new issue