Skip to content

Commit

Permalink
[ADD] l10n_it_ddt new field boolean
Browse files Browse the repository at this point in the history
 it's necessary to check if a picking in 'picking_ids' is 'done'. if so, the button 'put in pack'(in the header) will be invisible
  • Loading branch information
mborrini committed May 11, 2017
1 parent b94bbd6 commit 6f33f5c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions l10n_it_ddt/i18n/it.po
Expand Up @@ -388,6 +388,12 @@ msgstr "Fatture da DDT"
msgid "To be invoiced"
msgstr "Da fatturare"

#. module: l10n_it_ddt
#: code:addons/l10n_it_ddt/models/stock_picking_package_preparation.py:148
#, python-format
msgid "Impossible to put in pack a picking whose state is 'done'"
msgstr "Impossibile mettere nel pacco un ordine di consegna con lo stato 'fatto'"

#. module: l10n_it_ddt
#: model:ir.model.fields,field_description:l10n_it_ddt.field_add_pickings_to_ddt___last_update
#: model:ir.model.fields,field_description:l10n_it_ddt.field_ddt_create_invoice___last_update
Expand Down
16 changes: 16 additions & 0 deletions l10n_it_ddt/models/stock_picking_package_preparation.py
Expand Up @@ -108,6 +108,17 @@ def _default_ddt_type(self):
string="Force Weight",
help="Fill this field with the value you want to be used as weight. "
"Leave empty to let the system to compute it")
check_if_picking_done = fields.Boolean(compute = '_compute_check_if_picking_done',)

@api.multi
@api.depends('picking_ids',
'picking_ids.state')
def _compute_check_if_picking_done(self):
for record in self:
record.check_if_picking_done = False
for package in record.picking_ids:
if package.state == 'done':
record.check_if_picking_done = True

@api.onchange('partner_id', 'ddt_type_id')
def on_change_partner(self):
Expand Down Expand Up @@ -139,6 +150,11 @@ def check_linked_picking(self, picking):

@api.multi
def action_put_in_pack(self):
# ----- Check if exist a stock picking whose state is 'done'
for record_picking in self.picking_ids:
if record_picking.state == 'done':
raise UserError(
_("Impossible to put in pack a picking whose state is 'done'"))
for package in self:
# ----- Check if package has details
if not package.line_ids:
Expand Down
4 changes: 4 additions & 0 deletions l10n_it_ddt/views/stock_picking_package_preparation.xml
Expand Up @@ -134,6 +134,10 @@
<xpath expr="//field[@name='company_id']" position="after">
<field name="to_be_invoiced"/>
<field name="invoice_id"/>
<field name="check_if_picking_done" invisible="True"></field>
</xpath>
<xpath expr="//form/header/button[@name='action_put_in_pack']" position="attributes">
<attribute name="attrs">{'invisible' : ['|',('check_if_picking_done','=',True)]}</attribute>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 6f33f5c

Please sign in to comment.