<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#  licence AGPL version 3 or later
#  see license in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt
#  Copyright (C) 2015 Akretion (http://www.akretion.com).
#  @author <NAME> <<EMAIL>>
#
##############################################################################

from openerp.osv import orm, fields
from openerp.addons.mrp_workcenter_load.workcenter import STATIC_STATES


PRODUCTION_PROPOSED_ORD_DEF = 'date_planned_ ASC'


class MrpWorkcenterOrdering(orm.Model):
    _name = 'mrp.workcenter.ordering'
    _description = "Workcenter Ordering"
    _order = 'sequence'

    _columns = {
        'sequence': fields.integer(
            'Sequence'),
        'workcenter_id': fields.many2one(
            'mrp.workcenter',
            'Workcenter'),
        'field_id': fields.many2one(
            'ir.model.fields',
            string='Work Order Field',
            domain=[('model', '=', 'mrp.production.workcenter.line'),
                    ('name', 'not in',
                     ['message_follower_ids',
                      'message_is_follower',
                      'message_unread',
                      'uom'])],
            help="",),
        'ttype': fields.related(
            'field_id', 'ttype',
            type='char',
            string='Type'),
        'order': fields.selection(
            [('asc', 'Asc'), ('desc', 'Desc')],
            string='Order'),
    }

    _defaults = {
        'order': 'asc',
    }


class MrpProdLine(orm.Model):
    _inherit = 'mrp.production.workcenter.line'

    def _get_criterious_html(self, cr, uid, ids, field_n, arg, context=None):
        """ Convert String criterious values to table format """
        table_format = """
        <table cellspacing="0" cellpadding="5" border="1"
               width="70%%" style="border-color:#cacaca;border-style:solid;"
               class="oe_list_content">
            <thead>
                <tr align='center'>
                    <th>Field</td>
                    <th>Value</td>
                </tr>
            </thead>
            <tbody style="cursor:default">"""
        res = {}
        for elm in self.browse(cr, uid, ids):
            for field in elm.workcenter_id.accessible_field_ids:
                table_format += """<tr align='center'>
                                    <td>%s</td>
                                    <td>%s</td>
                                </tr>"""% (
                    field.field_description, elm[field.name])
            table_format += """</tbody></table> """
            res[elm.id] = table_format
        return res

    _columns = {
        'criterious_output': fields.function(
            _get_criterious_html,
            string='Criterious',
            type='html',
            store=False,
            help="Display criterious tab"),
    }


class MrpWorkcenter(orm.Model):
    _inherit = 'mrp.workcenter'

    def _get_criterious_html(self, cr, uid, ids, field_n, arg, context=None):
        """ Convert String criterious values to table format """
        table_format = """
        <table cellspacing="0" cellpadding="5" border="1"
               width="70%%" style="border-color:#cacaca;border-style:solid;"
               class="oe_list_content">
            <thead>
                <tr align='center'>
                    <th>Field</td>
                    <th>Value</td>
                </tr>
            </thead>
            <tbody style="cursor:default">"""
        res = {}
        for elm in self.browse(cr, uid, ids):
            for field in elm.accessible_field_ids:
                table_format += """<tr align='center'>
                                    <td>%s</td>
                                    #<td></td>
                                </tr>""" % (field.field_description)
            table_format += """</tbody></table> """
            res[elm.id] = table_format
        return res

    def _order_by_production_line(self, cr, uid, context=None):
        return [(PRODUCTION_PROPOSED_ORD_DEF, 'Planned Date ASC')]

    def __order_by_production_line(self, cr, uid, context=None):
        return self._order_by_production_line(cr, uid, context=context)

    _columns = {
        'unable_load': fields.float('Unable'),
        'todo_load': fields.float('Todo'),
        'scheduled_load': fields.float('Scheduled'),
        'proposed_order': fields.selection(
            __order_by_production_line, 'Proposed Order',
            help="Define order of the work orders"),
        'ordering_field_ids': fields.one2many(
            'mrp.workcenter.ordering',
            'workcenter_id',
            string='Ordering fields',
            help=" "),
        'accessible_field_ids': fields.many2many(
            'ir.model.fields',
            string='Accessible fields',
            domain=[('model', '=', 'mrp.production.workcenter.line'),
                    ('name', 'not in',
                     ['message_follower_ids',
                      'message_is_follower',
                      'message_unread',
                      'uom'])],
            help="These fields will be accessible by production"),
        'production_line_ids': fields.one2many(
            'mrp.production.workcenter.line',
            'workcenter_id',
            string='Work Orders',
            readonly=True,
            # this domain is displayed in the view as filter
            # think about it when update domain:
            # search <!-- schedule_state_filter --> in the view
            domain=[('state', 'not in', STATIC_STATES),
                    ('schedule_state', 'in', ['scheduled', 'pending'])],
            help=""),
        'criterious_output': fields.function(
            _get_criterious_html,
            string='Criterious',
            type='html',
            store=False,
            help="Display criterious tab"),
    }
<commit_msg>[FIX] html table in work order<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#  licence AGPL version 3 or later
#  see license in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt
#  Copyright (C) 2015 Akretion (http://www.<EMAIL>).
#  @author <NAME> <<EMAIL>>
#
##############################################################################

from openerp.osv import orm, fields
from openerp.addons.mrp_workcenter_load.workcenter import STATIC_STATES


PRODUCTION_PROPOSED_ORD_DEF = 'date_planned_ ASC'
COMPLEX_WORK_ORDER_FIELDS = ['message_follower_ids',
                             'message_is_follower',
                             'message_unread',
                             'criterious_output',
                             ]


class MrpWorkcenterOrdering(orm.Model):
    _name = 'mrp.workcenter.ordering'
    _description = "Workcenter Ordering"
    _order = 'sequence'

    _columns = {
        'sequence': fields.integer(
            'Sequence'),
        'workcenter_id': fields.many2one(
            'mrp.workcenter',
            'Workcenter'),
        'field_id': fields.many2one(
            'ir.model.fields',
            string='Work Order Field',
            domain=[('model', '=', 'mrp.production.workcenter.line'),
                    ('name', 'not in', COMPLEX_WORK_ORDER_FIELDS)],
            help="",),
        'ttype': fields.related(
            'field_id', 'ttype',
            type='char',
            string='Type'),
        'order': fields.selection(
            [('asc', 'Asc'), ('desc', 'Desc')],
            string='Order'),
    }

    _defaults = {
        'order': 'asc',
    }


class MrpProdLine(orm.Model):
    _inherit = 'mrp.production.workcenter.line'

    def _get_criterious_html(self, cr, uid, ids, field_n, arg, context=None):
        """ Convert String criterious values to table format """
        table_format = """
        <table cellspacing="0" cellpadding="5" border="1"
               width="70%%" style="border-color:#cacaca;border-style:solid;"
               class="oe_list_content">
            <thead>
                <tr align='center'>
                    <th>Field</td>
                    <th>Value</td>
                </tr>
            </thead>
            <tbody style="cursor:default">"""
        res = {}
        for elm in self.browse(cr, uid, ids):
            for field in elm.workcenter_id.accessible_field_ids:
                value = elm[field.name]
                if field.ttype not in ('one2many', 'many2many'):
                    if field.ttype == 'many2one':
                        value = value.name or ''
                    table_format += """<tr align='center'>
                                        <td>%s</td>
                                        <td>%s</td>
                                    </tr>""" % (
                        field.field_description, value)
            table_format += """</tbody></table> """
            res[elm.id] = table_format
        return res

    _columns = {
        'criterious_output': fields.function(
            _get_criterious_html,
            string='Criterious',
            type='html',
            store=False,
            help="Display criterious tab"),
    }


class MrpWorkcenter(orm.Model):
    _inherit = 'mrp.workcenter'

    def _order_by_production_line(self, cr, uid, context=None):
        return [(PRODUCTION_PROPOSED_ORD_DEF, 'Planned Date ASC')]

    def __order_by_production_line(self, cr, uid, context=None):
        return self._order_by_production_line(cr, uid, context=context)

    _columns = {
        'unable_load': fields.float('Unable'),
        'todo_load': fields.float('Todo'),
        'scheduled_load': fields.float('Scheduled'),
        'proposed_order': fields.selection(
            __order_by_production_line, 'Proposed Order',
            help="Define order of the work orders"),
        'ordering_field_ids': fields.one2many(
            'mrp.workcenter.ordering',
            'workcenter_id',
            string='Ordering fields',
            help=" "),
        'accessible_field_ids': fields.many2many(
            'ir.model.fields',
            string='Accessible fields',
            domain=[('model', '=', 'mrp.production.workcenter.line'),
                    ('name', 'not in', COMPLEX_WORK_ORDER_FIELDS)],
            help="These fields will be accessible by production"),
        'production_line_ids': fields.one2many(
            'mrp.production.workcenter.line',
            'workcenter_id',
            string='Work Orders',
            readonly=True,
            # this domain is displayed in the view as filter
            # think about it when update domain:
            # search <!-- schedule_state_filter --> in the view
            domain=[('state', 'not in', STATIC_STATES),
                    ('schedule_state', 'in', ['scheduled', 'pending'])],
            help=""),
    }

{'fraction_non_alphanumeric': 0.1575763131359428, 'fraction_numerical': 0.004033366944724539, 'mean_word_length': 1.8448500651890483, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4312043', 'n_tokens_mistral': 3127, 'n_tokens_neox': 2969, 'n_words': 603}