Exemplo n.º 1
0
 def write(self, fields):
     #print"\n write()",self._context
     gantt_start_date = ''
     gantt_end_date = ''
     if self._context.has_key('gantt_pass') and self._context.has_key(
             'gantt_pass') == True:
         if self.business_unit_id:
             if self.business_unit_id.name == 'Ferry' or not self.gantt_start_date or not self.gantt_end_date:
                 raise UserError(
                     _('Start date and End date in Work Order Can`t be edited.'
                       ))
             else:
                 for laycan_record in self.sale_order_id.laycan_ids:
                     if laycan_record.commence_date == self.gantt_start_date and laycan_record.complete_date == self.gantt_end_date:
                         laycan_record_update = laycan_record
                         gantt_start_date = fields.get('gantt_start_date')
                         gantt_end_date = fields.get('gantt_end_date')
                 #result = super(StockPicking, self).write(fields)
                 if gantt_start_date and gantt_end_date and self.sale_order_id:
                     laycan_record_update.write({
                         'commence_date':
                         gantt_start_date,
                         'complete_date':
                         gantt_end_date
                     })
     return super(StockPicking, self).write(fields)
Exemplo n.º 2
0
 def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
     res = super(Product, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
     if self._context.get('location') and isinstance(self._context['location'], int):
         location = self.env['stock.location'].browse(self._context['location'])
         fields = res.get('fields')
         if fields:
             if location.usage == 'supplier':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Receipts')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Received Qty')
             elif location.usage == 'internal':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Forecasted Quantity')
             elif location.usage == 'customer':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Deliveries')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Delivered Qty')
             elif location.usage == 'inventory':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future P&L')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('P&L Qty')
             elif location.usage == 'production':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Productions')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Produced Qty')
     return res
Exemplo n.º 3
0
 def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
     res = super(Product, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
     if self._context.get('location') and isinstance(self._context['location'], int):
         location = self.env['stock.location'].browse(self._context['location'])
         fields = res.get('fields')
         if fields:
             if location.usage == 'supplier':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Receipts')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Received Qty')
             elif location.usage == 'internal':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Forecasted Quantity')
             elif location.usage == 'customer':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Deliveries')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Delivered Qty')
             elif location.usage == 'inventory':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future P&L')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('P&L Qty')
             elif location.usage == 'production':
                 if fields.get('virtual_available'):
                     res['fields']['virtual_available']['string'] = _('Future Productions')
                 if fields.get('qty_available'):
                     res['fields']['qty_available']['string'] = _('Produced Qty')
     return res
Exemplo n.º 4
0
def set_custom_labels_on_fields(labels: List[dict],
                                fields: Mapping[str, dict]) -> str:
    """Set the custom labels on the related fields.

    :param labels: a list of custom labels to apply.
    :param fields: the dict of fields data to extend.
    """
    field_labels = (l for l in labels
                    if l['type_'] == 'field' and l['position'] == 'string')
    for label in field_labels:
        field = fields.get(label['reference'])
        if field:
            field['string'] = label['term']
Exemplo n.º 5
0
 def fields_view_get(self,
                     view_id=None,
                     view_type='form',
                     toolbar=False,
                     submenu=False):
     res = super(AccountInvoiceLine,
                 self).fields_view_get(view_id=view_id,
                                       view_type=view_type,
                                       toolbar=toolbar,
                                       submenu=submenu)
     if self._context.get('is_company_konkreto'):
         fields = res.get('fields')
         if fields:
             if fields.get('name'):
                 res['fields']['name']['string'] = _('Design/Description')
     return res
Exemplo n.º 6
0
 def fields_view_get(self,
                     view_id=None,
                     view_type='form',
                     toolbar=False,
                     submenu=False):
     res = super(AccountInvoice, self).fields_view_get(view_id=view_id,
                                                       view_type=view_type,
                                                       toolbar=toolbar,
                                                       submenu=submenu)
     if view_type == 'form':
         company = self.env.user.company_id.name
         if "KONGKRETO" in company:
             fields = res.get('fields')
             if fields:
                 if fields.get('invoice_line_ids'):
                     res['fields']['invoice_line_ids']['views']['tree'][
                         'fields']['name']['string'] = _(
                             'Design/Description')
     return res
Exemplo n.º 7
0
    def validate_device_id(self, devices):
        """
        Returns name of devices if related record with specified ID exists
        """
        resp = {}

        for field_name, id in devices.items():
            # Assume that by default ID is wrong
            resp[field_name] = False

            id = int(id)
            fields = self.fields_get([field_name])

            field = fields.get(field_name, {})
            model = field.get('relation')

            # Bad field name or field is not relation
            if not model:
                continue

            resp[field_name] = self.env[model].browse([id]).exists().name

        return resp