mirror of
https://gitlab.com/datalifeit/trytond-stock_party_warehouse
synced 2023-12-14 06:32:52 +01:00
Added button in party warehouse to create warehouse
This commit is contained in:
parent
0dd4f484da
commit
74acaec864
4 changed files with 43 additions and 0 deletions
|
@ -115,3 +115,7 @@ msgstr "Almacén"
|
|||
msgctxt "field:party.party.warehouse,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "model:ir.model.button,string:party_warehouse_create_button"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
32
party.py
32
party.py
|
@ -65,6 +65,18 @@ class PartyWarehouse(ModelSQL, ModelView, ValueMixin):
|
|||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls._order.insert(0, ('party', 'ASC'))
|
||||
cls._buttons.update({
|
||||
'create_warehouse':
|
||||
{
|
||||
'readonly': Bool(Eval('warehouse')),
|
||||
'invisible': Bool(Eval('warehouse')),
|
||||
'depends': ['warehouse']
|
||||
}
|
||||
})
|
||||
|
||||
@property
|
||||
def warehouse_name(self):
|
||||
return self.party.name
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
|
@ -95,6 +107,26 @@ class PartyWarehouse(ModelSQL, ModelView, ValueMixin):
|
|||
)
|
||||
party_h.drop_column('warehouse')
|
||||
|
||||
@classmethod
|
||||
def create_warehouse(cls, records):
|
||||
pool = Pool()
|
||||
CreateWarehouse = pool.get('party.party.create_warehouse',
|
||||
type='wizard')
|
||||
Configuration = pool.get('stock.configuration')
|
||||
Location = pool.get('stock.location')
|
||||
|
||||
to_save = []
|
||||
conf = Configuration(1)
|
||||
for record in records:
|
||||
if not record.warehouse:
|
||||
warehouse = CreateWarehouse._get_warehouse(Location,
|
||||
record.warehouse_name, conf.party_warehouse_parent)
|
||||
warehouse.save()
|
||||
record.warehouse = warehouse
|
||||
to_save.append(record)
|
||||
if to_save:
|
||||
cls.save(to_save)
|
||||
|
||||
|
||||
class CreateWarehouseStart(ModelView):
|
||||
"""Create Party Warehouse Start"""
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
<field name="act_window" ref="act_party_warehouse"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="party_warehouse_create_button">
|
||||
<field name="name">create_warehouse</field>
|
||||
<field name="string">Create</field>
|
||||
<field name="model" search="[('model', '=', 'party.party.warehouse')]"/>
|
||||
</record>
|
||||
|
||||
<!-- Menus -->
|
||||
<menuitem action="act_party_warehouse" id="menu_party_warehouse"
|
||||
parent="stock.menu_configuration" sequence="30" name="Party Warehouse"/>
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
copyright notices and license terms. -->
|
||||
<tree editable="1">
|
||||
<field name="party" expand="1"/>
|
||||
<button name="create_warehouse"/>
|
||||
<field name="warehouse" expand="1"/>
|
||||
</tree>
|
Loading…
Reference in a new issue