mirror of
https://github.com/NaN-tic/trytond-stock_origin.git
synced 2023-12-13 21:30:34 +01:00
Added origin for ShipmentOutReturn. Changed origin field to function field for ShipmentOut
This commit is contained in:
parent
8546170b65
commit
d3f400c2f7
1
MANIFEST.in
Executable file → Normal file
1
MANIFEST.in
Executable file → Normal file
|
@ -8,3 +8,4 @@ include tryton.cfg
|
|||
include *.xml
|
||||
include locale/*.po
|
||||
include doc/*
|
||||
include view/*
|
||||
|
|
4
__init__.py
Executable file → Normal file
4
__init__.py
Executable file → Normal file
|
@ -7,4 +7,8 @@ from .shipment import *
|
|||
def register():
|
||||
Pool.register(
|
||||
ShipmentOut,
|
||||
ShipmentOutReturn,
|
||||
module='stock_origin', type_='model')
|
||||
Pool.register(
|
||||
CreateShipmentOutReturn,
|
||||
module='stock', type_='wizard')
|
||||
|
|
0
doc/index.rst
Executable file → Normal file
0
doc/index.rst
Executable file → Normal file
4
locale/ca_ES.po
Executable file → Normal file
4
locale/ca_ES.po
Executable file → Normal file
|
@ -5,3 +5,7 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
|
|||
msgctxt "field:stock.shipment.out,origin:"
|
||||
msgid "Origin"
|
||||
msgstr "Origen"
|
||||
|
||||
msgctxt "field:stock.shipment.out.return,origin:"
|
||||
msgid "Origin"
|
||||
msgstr "Origen"
|
||||
|
|
4
locale/es_ES.po
Executable file → Normal file
4
locale/es_ES.po
Executable file → Normal file
|
@ -5,3 +5,7 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
|
|||
msgctxt "field:stock.shipment.out,origin:"
|
||||
msgid "Origin"
|
||||
msgstr "Origen"
|
||||
|
||||
msgctxt "field:stock.shipment.out.return,origin:"
|
||||
msgid "Origin"
|
||||
msgstr "Origen"
|
||||
|
|
60
shipment.py
Executable file → Normal file
60
shipment.py
Executable file → Normal file
|
@ -4,14 +4,24 @@
|
|||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.rpc import RPC
|
||||
|
||||
__all__ = ['ShipmentOut']
|
||||
__all__ = ['ShipmentOut', 'ShipmentOutReturn', 'CreateShipmentOutReturn']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class ShipmentOut:
|
||||
__name__ = 'stock.shipment.out'
|
||||
origin = fields.Reference('Origin', selection='get_origin')
|
||||
origin = fields.Function(fields.Reference('Origin', selection='get_origin'),
|
||||
'get_origin_value')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ShipmentOut, cls).__setup__()
|
||||
cls.__rpc__.update({
|
||||
'get_origin': RPC(),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
|
@ -26,3 +36,49 @@ class ShipmentOut:
|
|||
('model', 'in', models),
|
||||
])
|
||||
return [('', '')] + [(m.model, m.name) for m in models]
|
||||
|
||||
@classmethod
|
||||
def get_origin_value(cls, shipments, name):
|
||||
origin = {}
|
||||
for shipment in shipments:
|
||||
origin[shipment.id] = None
|
||||
return origin
|
||||
|
||||
|
||||
class ShipmentOutReturn:
|
||||
__name__ = 'stock.shipment.out.return'
|
||||
origin = fields.Reference('Origin', selection='get_origin')
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
'Return list of Model names for origin Reference'
|
||||
return ['stock.shipment.out']
|
||||
|
||||
@classmethod
|
||||
def get_origin(cls):
|
||||
Model = Pool().get('ir.model')
|
||||
models = cls._get_origin()
|
||||
models = Model.search([
|
||||
('model', 'in', models),
|
||||
])
|
||||
return [('', '')] + [(m.model, m.name) for m in models]
|
||||
|
||||
|
||||
class CreateShipmentOutReturn:
|
||||
__name__ = 'stock.shipment.out.return.create'
|
||||
|
||||
def do_start(self, action):
|
||||
pool = Pool()
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentOutReturn = pool.get('stock.shipment.out.return')
|
||||
|
||||
action, data = super(CreateShipmentOutReturn, self).do_start(action)
|
||||
shipment_ids = Transaction().context['active_ids']
|
||||
shipment_outs = ShipmentOut.browse(shipment_ids)
|
||||
shipment_out_returns = ShipmentOutReturn.browse(data['res_id'])
|
||||
|
||||
for shipment_out, shipment_out_return in \
|
||||
zip(shipment_outs, shipment_out_returns):
|
||||
shipment_out_return.origin = shipment_out
|
||||
shipment_out_return.save()
|
||||
return action, data
|
||||
|
|
29
shipment.xml
Executable file → Normal file
29
shipment.xml
Executable file → Normal file
|
@ -6,18 +6,23 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<record model="ir.ui.view" id="shipment_out_view_form">
|
||||
<field name="model">stock.shipment.out</field>
|
||||
<field name="inherit" ref="stock.shipment_out_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name="warehouse"]"
|
||||
position="after">
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
</field>
|
||||
<field name="name">shipment_out_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="shipment_out_view_tree">
|
||||
<field name="model">stock.shipment.out</field>
|
||||
<field name="inherit" ref="stock.shipment_out_view_tree"/>
|
||||
<field name="name">shipment_out_tree</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="shipment_out_return_view_form">
|
||||
<field name="model">stock.shipment.out.return</field>
|
||||
<field name="inherit" ref="stock.shipment_out_return_view_form"/>
|
||||
<field name="name">shipment_out_return_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="shipment_out_return_view_tree">
|
||||
<field name="model">stock.shipment.out.return</field>
|
||||
<field name="inherit" ref="stock.shipment_out_return_view_tree"/>
|
||||
<field name="name">shipment_out_return_tree</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
0
tests/__init__.py
Executable file → Normal file
0
tests/__init__.py
Executable file → Normal file
0
tests/test_stock_origin.py
Executable file → Normal file
0
tests/test_stock_origin.py
Executable file → Normal file
10
view/shipment_out_form.xml
Normal file
10
view/shipment_out_form.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name="warehouse"]" position="after">
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
</xpath>
|
||||
</data>
|
10
view/shipment_out_return_form.xml
Normal file
10
view/shipment_out_return_form.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name="warehouse"]" position="after">
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
</xpath>
|
||||
</data>
|
9
view/shipment_out_return_tree.xml
Normal file
9
view/shipment_out_return_tree.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. 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_address"]" position="after">
|
||||
<field name="origin"/>
|
||||
</xpath>
|
||||
</data>
|
9
view/shipment_out_tree.xml
Normal file
9
view/shipment_out_tree.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/tree/field[@name="state"]" position="after">
|
||||
<field name="origin"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue