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
|
||||
* Initial release
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -3,21 +3,6 @@
|
|||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<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 -->
|
||||
<record model="ir.ui.view" id="production_view_form">
|
||||
<field name="model">production</field>
|
||||
|
|
|
@ -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 ""
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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