diff --git a/CHANGELOG b/CHANGELOG old mode 100755 new mode 100644 diff --git a/COPYRIGHT b/COPYRIGHT old mode 100755 new mode 100644 diff --git a/INSTALL b/INSTALL old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/MANIFEST.in b/MANIFEST.in old mode 100755 new mode 100644 index 5594cc6..eb44a40 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,3 +8,4 @@ include tryton.cfg include *.xml include locale/*.po include doc/* +include view/* diff --git a/README b/README old mode 100755 new mode 100644 diff --git a/TODO b/TODO old mode 100755 new mode 100644 diff --git a/__init__.py b/__init__.py old mode 100755 new mode 100644 index 08d466f..3994b49 --- a/__init__.py +++ b/__init__.py @@ -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') diff --git a/doc/index.rst b/doc/index.rst old mode 100755 new mode 100644 diff --git a/locale/ca_ES.po b/locale/ca_ES.po old mode 100755 new mode 100644 index 2e765d5..91c406e --- a/locale/ca_ES.po +++ b/locale/ca_ES.po @@ -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" diff --git a/locale/es_ES.po b/locale/es_ES.po old mode 100755 new mode 100644 index 2e765d5..91c406e --- a/locale/es_ES.po +++ b/locale/es_ES.po @@ -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" diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 diff --git a/shipment.py b/shipment.py old mode 100755 new mode 100644 index 9a025a0..6f58bff --- a/shipment.py +++ b/shipment.py @@ -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 diff --git a/shipment.xml b/shipment.xml old mode 100755 new mode 100644 index af10720..23380ed --- a/shipment.xml +++ b/shipment.xml @@ -6,18 +6,23 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig stock.shipment.out - - - - - - ]]> - + shipment_out_form + + + stock.shipment.out + + shipment_out_tree + + + + stock.shipment.out.return + + shipment_out_return_form + + + stock.shipment.out.return + + shipment_out_return_tree diff --git a/tests/__init__.py b/tests/__init__.py old mode 100755 new mode 100644 diff --git a/tests/test_stock_origin.py b/tests/test_stock_origin.py old mode 100755 new mode 100644 diff --git a/view/shipment_out_form.xml b/view/shipment_out_form.xml new file mode 100644 index 0000000..e0ba634 --- /dev/null +++ b/view/shipment_out_form.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/view/shipment_out_return_form.xml b/view/shipment_out_return_form.xml new file mode 100644 index 0000000..e0ba634 --- /dev/null +++ b/view/shipment_out_return_form.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/view/shipment_out_return_tree.xml b/view/shipment_out_return_tree.xml new file mode 100644 index 0000000..bd8e302 --- /dev/null +++ b/view/shipment_out_return_tree.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/view/shipment_out_tree.xml b/view/shipment_out_tree.xml new file mode 100644 index 0000000..02b0702 --- /dev/null +++ b/view/shipment_out_tree.xml @@ -0,0 +1,9 @@ + + + + + + +