Exemplo n.º 1
0
def _build_attribute_field(self, cr, uid, page, attribute, context=None):
    parent = etree.SubElement(page, 'group', colspan="2", col="4")
    kwargs = {'name': "%s" % attribute.name}
#    if attribute.ttype in ['many2many', 'text']:
    #only the many2many without many2many_tags then need display 'separator', by johnw 04/30/2014
    if (attribute.ttype == 'many2many' and not attribute.m2m_tags) or attribute.ttype == 'text':
        parent = etree.SubElement(parent, 'group', colspan="2", col="4")
        sep = etree.SubElement(parent,
                               'separator',
                                string="%s" % attribute.field_description,
                                colspan="4")

        kwargs['nolabel'] = "1"
    if attribute.ttype in ['many2one', 'many2many']:
        if attribute.relation_model_id:
            if attribute.domain:
                kwargs['domain'] = attribute.domain
            else:
                ids = [op.value_ref.id for op in attribute.option_ids]
                kwargs['domain'] = "[('id', 'in', %s)]" % ids
        else:
            kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id
    #set the 'many2many_tags' widget for the multiselect attribute, by johnw 04/30/2014
    if attribute.ttype == 'many2many' and attribute.m2m_tags:
        kwargs['widget'] = "many2many_tags"
    #Add the field's description as the field label
#    field = etree.SubElement(parent, 'field', **kwargs)    
    field = etree.SubElement(parent, 'field', string="%s" % attribute.field_description, **kwargs)
    orm.setup_modifiers(field, self.fields_get(cr, uid, attribute.name, context))
    return parent 
 def _set_attr(field_name, attr_name, attr_value, in_tree_view):
     field = arch.find('.//field[@name="' + field_name + '"]')
     if field is not None:
         field.attrib[attr_name] = attr_value
         if hasattr(orm, 'setup_modifiers'):
             orm.setup_modifiers(field, context=context,
                                 in_tree_view=in_tree_view)
Exemplo n.º 3
0
    def fields_view_get(self,
                        cr,
                        uid,
                        view_id=None,
                        view_type='form',
                        context=None,
                        toolbar=False,
                        submenu=False):
        if view_type == 'form':
            if context is None:
                context = {}
            context['via_reporting_tree.tree_fields_view_get'] = True
        res = super(tree, self).fields_view_get(cr, uid, view_id, view_type,
                                                context, toolbar, submenu)
        if view_type != 'form':
            return res

        arch = etree.XML(res['arch'])
        nodes_view = self._get_tree_type_nodes_fields_view(cr,
                                                           uid,
                                                           context=context)
        for node in nodes_view.xpath('//*'):
            if float(release.major_version) >= 6.1:
                orm.setup_modifiers(node, context=context)
            if node.tag == 'field' and node.get('name') is not None:
                res['fields'][node.get('name')] = {
                    'relation': 'via.reporting.tree.node',
                    'type': 'many2one',
                }
        arch.insert(2, nodes_view)
        res['arch'] = etree.tostring(arch, pretty_print=True)

        return res
    def fields_view_get(self, cr, uid, view_id=None, view_type='form',
                        context=None, toolbar=False, submenu=False):
        if view_type == 'form':
            if context is None:
                context = {}
            context['via_reporting_tree.tree_fields_view_get'] = True
        res = super(tree, self).fields_view_get(cr, uid, view_id, view_type,
                                                context, toolbar, submenu)
        if view_type != 'form':
            return res

        arch = etree.XML(res['arch'])
        nodes_view = self._get_tree_type_nodes_fields_view(cr, uid,
                                                           context=context)
        for node in nodes_view.xpath('//*'):
            if float(release.major_version) >= 6.1:
                orm.setup_modifiers(node, context=context)
            if node.tag == 'field' and node.get('name') is not None:
                res['fields'][node.get('name')] = {
                    'relation': 'via.reporting.tree.node',
                    'type': 'many2one',
                }
        arch.insert(2, nodes_view)
        res['arch'] = etree.tostring(arch, pretty_print=True)

        return res
Exemplo n.º 5
0
 def _set_attr(field_name, attr_name, attr_value, in_tree_view):
     field = arch.find('.//field[@name="' + field_name + '"]')
     if field is not None:
         field.attrib[attr_name] = attr_value
         if hasattr(orm, 'setup_modifiers'):
             orm.setup_modifiers(field,
                                 context=context,
                                 in_tree_view=in_tree_view)
 def _freeze_field(self, name, fields, arch, freeze):
     """
     Freezes (or enables) a field, if the field node is found.
     """
     freeze = int(freeze)
     if name in fields:
         fields[name]['readonly'] = freeze
         for node in arch.xpath("//field[@name='%s']" % name):
             setup_modifiers(node, fields[name])
 def _hide_field(self, name, fields, arch, freeze):
     """
     Hides (or shows) a field, if the field node is found.
     """
     freeze = int(freeze)
     if name in fields:
         fields[name]['invisible'] = freeze
         for node in arch.xpath("//field[@name='%s']" % name):
             setup_modifiers(node, fields[name])
 def _freeze_field(self, name, fields, arch, freeze):
     """
     Freezes (or enables) a field, if the field node is found.
     """
     freeze = int(freeze)
     if name in fields:
         fields[name]['readonly'] = freeze
         for node in arch.xpath("//field[@name='%s']" % name):
             setup_modifiers(node, fields[name])
 def _hide_field(self, name, fields, arch, freeze):
     """
     Hides (or shows) a field, if the field node is found.
     """
     freeze = int(freeze)
     if name in fields:
         fields[name]['invisible'] = freeze
         for node in arch.xpath("//field[@name='%s']" % name):
             setup_modifiers(node, fields[name])
Exemplo n.º 10
0
def _build_attribute_field(self, cr, uid, page, attribute, context=None):
    parent = etree.SubElement(page, 'group', colspan="2", col="4")
    kwargs = {'name': "%s" % attribute.name}
    #    if attribute.ttype in ['many2many', 'text']:
    #only the many2many without many2many_tags then need display 'separator', by johnw 04/30/2014
    if (attribute.ttype == 'many2many'
            and not attribute.m2m_tags) or attribute.ttype == 'text':
        parent = etree.SubElement(parent, 'group', colspan="2", col="4")
        sep = etree.SubElement(parent,
                               'separator',
                               string="%s" % attribute.field_description,
                               colspan="4")

        kwargs['nolabel'] = "1"
    if attribute.ttype in ['many2one', 'many2many']:
        if attribute.relation_model_id:
            if attribute.domain:
                kwargs['domain'] = attribute.domain
            else:
                ids = [op.value_ref.id for op in attribute.option_ids]
                kwargs['domain'] = "[('id', 'in', %s)]" % ids
        else:
            kwargs[
                'domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id
    #set the 'many2many_tags' widget for the multiselect attribute, by johnw 04/30/2014
    if attribute.ttype == 'many2many' and attribute.m2m_tags:
        kwargs['widget'] = "many2many_tags"
    #Add the field's description as the field label


#    field = etree.SubElement(parent, 'field', **kwargs)
    field = etree.SubElement(parent,
                             'field',
                             string="%s" % attribute.field_description,
                             **kwargs)
    orm.setup_modifiers(field, self.fields_get(cr, uid, attribute.name,
                                               context))
    return parent
Exemplo n.º 11
0
    def _build_form(self, cr, uid, field_datas, value1, value2):

        update_values = {}
        update_fields = {}
        columns = {}

        form_grp = etree.Element('group', colspan="4", col="2")
        orm.setup_modifiers(form_grp)

        for fid, fname, fdescription, ttype, required, relation, readonly in field_datas:
            val1 = value1[fname]
            val2 = value2[fname]
            my_selection = []
            size = 24

            if (val1 and val2) and (val1 == val2):
                if ttype in ('many2one'):
                    update_values.update({fname: val1.id})
                elif ttype in ('many2many'):
                    update_values.update(
                        {fname: [(6, 0, map(lambda x: x.id, val1))]})
                else:
                    update_values.update({fname: val1})

            if (val1 and val2) and (val1 != val2) and not readonly:
                if ttype in ('char', 'text', 'selection'):
                    my_selection = [(val1, val1), (val2, val2)]
                    size = max(len(val1), len(val2))
                if ttype in ('float', 'integer'):
                    my_selection = [(str(val1), str(val1)),
                                    (str(val2), str(val2))]
                if ttype in ('many2one'):
                    my_selection = [(str(val1.id), val1.name),
                                    (str(val2.id), val2.name)]
                if ttype in ('many2many'):
                    update_values.update({
                        fname:
                        [(6, 0, list(set(map(lambda x: x.id, val1 + val2))))]
                    })
                if my_selection:
                    if not required:
                        my_selection.append((False, ''))
                    columns.update({
                        fname:
                        fields.sparse('container',
                                      type='selection',
                                      selection=my_selection,
                                      string=fdescription,
                                      required=required,
                                      size=size)
                    })
                    update_fields.update({
                        fname: {
                            'string': fdescription,
                            'type': 'selection',
                            'selection': my_selection,
                            'required': required
                        }
                    })
                    f = etree.SubElement(form_grp, 'field', name=fname)
                    orm.setup_modifiers(f, field=update_fields[fname])

            if fname == 'ref':
                if val1 == False or val2 == False:
                    update_values.update({fname: val1 or val2})
                else:
                    my_selection = [(val1, val1), (val2, val2)]
                    size = max(len(val1), len(val2))

                    if my_selection:
                        columns.update({
                            fname:
                            fields.sparse('container',
                                          type='selection',
                                          selection=my_selection,
                                          string=fdescription,
                                          required=required,
                                          size=size)
                        })
                        update_fields.update({
                            fname: {
                                'string': fdescription,
                                'type': 'selection',
                                'selection': my_selection,
                                'required': required
                            }
                        })
                        f = etree.SubElement(form_grp, 'field', name=fname)
                        orm.setup_modifiers(f, field=update_fields[fname])

            if (val1 and not val2) or (not val1 and val2):
                if ttype == 'many2one':
                    update_values.update(
                        {fname: val1 and val1.id or val2 and val2.id})
                elif ttype == 'many2many':
                    update_values.update(
                        {fname: [(6, 0, map(lambda x: x.id, val1 or val2))]})
                elif ttype == 'one2many':
                    #skip one2many values
                    pass
                else:
                    update_values.update({fname: val1 or val2})

        return form_grp, update_fields, update_values, columns
Exemplo n.º 12
0
    def fields_view_get(self, cr, uid, view_id=None, view_type="form", context=None, toolbar=False, submenu=False):
        journal_pool = self.pool.get("account.journal")
        if context is None:
            context = {}
        result = super(account_move_line, self).fields_view_get(
            cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu
        )
        if view_type != "tree":
            # Remove the toolbar from the form view
            if view_type == "form":
                if result.get("toolbar", False):
                    result["toolbar"]["action"] = []
            # Restrict the list of journal view in search view
            if view_type == "search" and result["fields"].get("journal_id", False):
                result["fields"]["journal_id"]["selection"] = journal_pool.name_search(cr, uid, "", [], context=context)
                ctx = context.copy()
                # we add the refunds journal in the selection field of journal
                if context.get("journal_type", False) == "sale":
                    ctx.update({"journal_type": "sale_refund"})
                    result["fields"]["journal_id"]["selection"] += journal_pool.name_search(
                        cr, uid, "", [], context=ctx
                    )
                elif context.get("journal_type", False) == "purchase":
                    ctx.update({"journal_type": "purchase_refund"})
                    result["fields"]["journal_id"]["selection"] += journal_pool.name_search(
                        cr, uid, "", [], context=ctx
                    )
            return result
        if context.get("view_mode", False):
            return result
        fld = []
        fields = {}
        flds = []
        title = _("Accounting Entries")  # self.view_header_get(cr, uid, view_id, view_type, context)

        ids = journal_pool.search(cr, uid, [])
        journals = journal_pool.browse(cr, uid, ids, context=context)
        all_journal = [None]
        common_fields = {}
        total = len(journals)
        for journal in journals:
            all_journal.append(journal.id)
            for field in journal.view_id.columns_id:
                if not field.field in fields:
                    fields[field.field] = [journal.id]
                    fld.append((field.field, field.sequence))
                    flds.append(field.field)
                    common_fields[field.field] = 1
                else:
                    fields.get(field.field).append(journal.id)
                    common_fields[field.field] = common_fields[field.field] + 1
        fld.append(("period_id", 3))
        fld.append(("journal_id", 10))
        fld.append(("journal_type", 50))
        fld.append(("journal_required_fields", 60))
        fld.append(("account_required_fields", 70))
        fld.append(("move_type_id", 80))
        fld.append(("select_to_payment", 90))
        fld.append(("partner_bank_id", 90))
        flds.append("period_id")
        flds.append("journal_id")
        flds.append(("journal_type"))
        flds.append(("journal_required_fields"))
        flds.append(("account_required_fields"))
        flds.append(("move_type_id"))
        flds.append(("select_to_payment"))
        flds.append(("partner_bank_id"))
        fields["period_id"] = all_journal
        fields["journal_id"] = all_journal
        fields["journal_type"] = all_journal
        fields["journal_required_fields"] = all_journal
        fields["account_required_fields"] = all_journal
        fields["move_type_id"] = all_journal
        fields["select_to_payment"] = all_journal
        fields["partner_bank_id"] = all_journal
        fld = sorted(fld, key=itemgetter(1))
        widths = {"statement_id": 50, "state": 60, "tax_code_id": 50, "move_id": 40}

        document = etree.Element(
            "tree",
            string=title,
            editable="top",
            refresh="5",
            on_write="on_create_write",
            colors="red:state=='draft';black:state=='valid'",
        )
        fields_get = self.fields_get(cr, uid, flds, context)
        for field, _seq in fld:
            if common_fields.get(field) == total:
                fields.get(field).append(None)
            # if field=='state':
            #     state = 'colors="red:state==\'draft\'"'
            f = etree.SubElement(document, "field", name=field)

            if field == "debit":
                f.set("sum", _("Total debit"))

            elif field == "credit":
                f.set("sum", _("Total credit"))

            elif field == "move_id":
                f.set("required", "False")

            elif field == "account_tax_id":
                f.set("domain", "[('parent_id', '=' ,False)]")
                f.set("context", "{'journal_id': journal_id}")

            elif field == "account_id" and journal.id:
                f.set("domain", "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
                f.set("on_change", "onchange_account_id(account_id, partner_id)")

            elif field == "partner_id":
                f.set(
                    "on_change", "onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"
                )

            elif field == "journal_id":
                f.set("context", "{'journal_id': journal_id}")
                f.set("on_change", "onchange_journal_id(journal_id)")

            elif field == "statement_id":
                f.set("domain", "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
                f.set("invisible", "True")

            elif field == "date":
                f.set("on_change", "onchange_date(date)")

            elif field == "analytic_account_id":
                # Currently it is not working due to being executed by superclass's fields_view_get
                # f.set('groups', 'analytic.group_analytic_accounting')
                pass

            # elif field in ('journal_type', 'journal_required_fields', 'account_required_fields', 'select_to_payment', 'move_type_id', 'partner_bank_id'):
            #    f.set('invisible', 'True')

            elif field == "select_to_payment":
                f.set("on_change", "onchange_select_to_payment(partner_id)")

            if field in ("amount_currency", "currency_id"):
                f.set("on_change", "onchange_currency(account_id, amount_currency, currency_id, date, journal_id)")
                f.set("attrs", "{'readonly': [('state', '=', 'valid')]}")

            if field in widths:
                f.set("width", str(widths[field]))

            if field in ("journal_id",):
                f.set("invisible", "context.get('journal_id', False)")
            elif field in ("period_id",):
                f.set("invisible", "context.get('period_id', False)")

            orm.setup_modifiers(f, fields_get[field], context=context, in_tree_view=True)

        result["arch"] = etree.tostring(document, pretty_print=True)
        result["fields"] = fields_get
        return result
Exemplo n.º 13
0
    def fields_view_get(self,
                        cr,
                        uid,
                        view_id=None,
                        view_type='form',
                        context=None,
                        toolbar=False,
                        submenu=False):
        if context is None:
            context = {}

        line_name = {
            '': 'Cash Advance Lines',
            'topup': 'Top-ups',
            'disbursement': 'Disbursements',
            'expense': 'Expenses',
        }
        line_type = context.get('via_cash_advance.line_type', '')

        result = super(cash_advance_establishment_line,
                       self).fields_view_get(cr,
                                             uid,
                                             view_id,
                                             view_type,
                                             context=context,
                                             toolbar=toolbar,
                                             submenu=submenu)

        def _set_attr(field_name, attr_name, attr_value, in_tree_view):
            field = arch.find('.//field[@name="' + field_name + '"]')
            if field is not None:
                field.attrib[attr_name] = attr_value
                if hasattr(orm, 'setup_modifiers'):
                    orm.setup_modifiers(field,
                                        context=context,
                                        in_tree_view=in_tree_view)

        def _activate_attr(field_name, attr_name, in_tree_view):
            _set_attr(field_name, attr_name, 'True', in_tree_view)

        def _make_invisible(field_name, in_tree_view=False):
            _activate_attr(field_name, 'invisible', in_tree_view)

        def _make_required(field_name, in_tree_view=False):
            _activate_attr(field_name, 'required', in_tree_view)

        def _set_string(field_name, string, in_tree_view=False):
            _set_attr(field_name, 'string', string, in_tree_view)

        if view_type == 'form':
            arch = etree.XML(result['arch'])
            arch.attrib['string'] = line_name[line_type][:-1]

            if line_type == 'expense':
                _make_invisible('topup_disbursement_journal')
                _make_required('expense_account')
            elif line_type == 'topup':
                _set_string('topup_disbursement_journal', 'Top-up from')
            elif line_type == 'disbursement':
                _set_string('topup_disbursement_journal', 'Disburse to')
            else:
                raise osv.except_osv(_('Invalid action !'),
                                     _('Unknown line type %s' % line_type))

            if line_type in ('topup', 'disbursement'):
                field = arch.find(
                    './/field[@name="topup_disbursement_journal"]')
                if field is not None:
                    field.attrib['required'] = 'True'
                    if hasattr(orm, 'setup_modifiers'):
                        orm.setup_modifiers(field, context=context)

                    ca_journal_id = context.get(
                        'via_cash_advance.cash_advance_journal_id',
                        None) or None
                    if ca_journal_id is None:
                        raise osv.except_osv(
                            _('Error !'),
                            _('Select an establishment journal first before creating any %s'
                              % line_type))
                    else:
                        get_journal_currency = cash_advance_establishment.get_journal_currency
                        establishment_pool = self.pool.get(
                            'cash.advance.establishment')
                        ca_journal_curr_id = get_journal_currency(
                            establishment_pool,
                            cr,
                            uid,
                            ca_journal_id,
                            context=context)
                        sels = result['fields']['topup_disbursement_journal'][
                            'selection']
                        sels = filter(
                            lambda s: ((s[0] != ca_journal_id) and (
                                (type(s[0]) in (int, str, unicode)) and
                                (ca_journal_curr_id == get_journal_currency(
                                    establishment_pool,
                                    cr,
                                    uid,
                                    s[0],
                                    context=context))) or
                                       (type(s[0]) not in
                                        (int, str, unicode))), sels)
                        result['fields']['topup_disbursement_journal'][
                            'selection'] = sels

                _make_invisible('product')
                _make_invisible('expense_account')

            result['arch'] = etree.tostring(arch, pretty_print=True)
        elif view_type == 'tree':
            arch = etree.XML(result['arch'])
            if line_type == 'expense':
                arch.attrib['string'] = line_name[line_type]
                arch.attrib['editable'] = 'bottom'
                _make_required('expense_account', in_tree_view=True)
            elif line_type in ('topup', 'disbursement'):
                arch.attrib['string'] = line_name[line_type]
                _make_invisible('product', in_tree_view=True)
                _make_invisible('expense_account', in_tree_view=True)
                _make_invisible('period', in_tree_view=True)
                _make_invisible('ref', in_tree_view=True)
                _make_invisible('narration', in_tree_view=True)
            else:
                raise osv.except_osv(_('Invalid action !'),
                                     _('Unknown line type %s' % line_type))
            result['arch'] = etree.tostring(arch, pretty_print=True)

        return result
    def fields_view_get(self, cr, uid, view_id=None, view_type='form',
                        context=None, toolbar=False, submenu=False):
        if context is None:
            context = {}

        line_name = {
            '': 'Cash Advance Lines',
            'topup': 'Top-ups',
            'disbursement': 'Disbursements',
            'expense': 'Expenses',
        }
        line_type = context.get('via_cash_advance.line_type', '')

        result = super(cash_advance_establishment_line, self).fields_view_get(cr, uid, view_id,
                                                                              view_type,
                                                                              context=context,
                                                                              toolbar=toolbar,
                                                                              submenu=submenu)

        def _set_attr(field_name, attr_name, attr_value, in_tree_view):
            field = arch.find('.//field[@name="' + field_name + '"]')
            if field is not None:
                field.attrib[attr_name] = attr_value
                if hasattr(orm, 'setup_modifiers'):
                    orm.setup_modifiers(field, context=context,
                                        in_tree_view=in_tree_view)
        def _activate_attr(field_name, attr_name, in_tree_view):
            _set_attr(field_name, attr_name, 'True', in_tree_view)

        def _make_invisible(field_name, in_tree_view=False):
            _activate_attr(field_name, 'invisible', in_tree_view)
        def _make_required(field_name, in_tree_view=False):
            _activate_attr(field_name, 'required', in_tree_view)
        def _set_string(field_name, string, in_tree_view=False):
            _set_attr(field_name, 'string', string, in_tree_view)

        if view_type == 'form':
            arch = etree.XML(result['arch'])
            arch.attrib['string'] = line_name[line_type][:-1]

            if line_type == 'expense':
                _make_invisible('topup_disbursement_journal')
                _make_required('expense_account')
            elif line_type == 'topup':
                _set_string('topup_disbursement_journal', 'Top-up from')
            elif line_type == 'disbursement':
                _set_string('topup_disbursement_journal', 'Disburse to')
            else:
                raise osv.except_osv(_('Invalid action !'),
                                     _('Unknown line type %s' % line_type))

            if line_type in ('topup', 'disbursement'):
                field = arch.find('.//field[@name="topup_disbursement_journal"]')
                if field is not None:
                    field.attrib['required'] = 'True'
                    if hasattr(orm, 'setup_modifiers'):
                        orm.setup_modifiers(field, context=context)

                    ca_journal_id = context.get('via_cash_advance.cash_advance_journal_id', None) or None
                    if ca_journal_id is None:
                        raise osv.except_osv(_('Error !'),
                                             _('Select an establishment journal first before creating any %s'
                                               % line_type))
                    else:
                        get_journal_currency = cash_advance_establishment.get_journal_currency
                        establishment_pool = self.pool.get('cash.advance.establishment')
                        ca_journal_curr_id = get_journal_currency(establishment_pool, cr, uid,
                                                                  ca_journal_id, context=context)
                        sels = result['fields']['topup_disbursement_journal']['selection']
                        sels = filter(lambda s: ((s[0] != ca_journal_id)
                                                 and ((type(s[0]) in (int, str, unicode))
                                                      and (ca_journal_curr_id == get_journal_currency(establishment_pool,
                                                                                                      cr, uid, s[0],
                                                                                                      context=context)))
                                                 or (type(s[0]) not in (int, str, unicode))),
                                      sels)
                        result['fields']['topup_disbursement_journal']['selection'] = sels

                _make_invisible('product')
                _make_invisible('expense_account')

            result['arch'] = etree.tostring(arch, pretty_print=True)
        elif view_type == 'tree':
            arch = etree.XML(result['arch'])
            if line_type == 'expense':
                arch.attrib['string'] = line_name[line_type]
                arch.attrib['editable'] = 'bottom'
                _make_required('expense_account', in_tree_view=True)
            elif line_type in ('topup', 'disbursement'):
                arch.attrib['string'] = line_name[line_type]
                _make_invisible('product', in_tree_view=True)
                _make_invisible('expense_account', in_tree_view=True)
                _make_invisible('period', in_tree_view=True)
                _make_invisible('ref', in_tree_view=True)
                _make_invisible('narration', in_tree_view=True)
            else:
                raise osv.except_osv(_('Invalid action !'),
                                     _('Unknown line type %s' % line_type))
            result['arch'] = etree.tostring(arch, pretty_print=True)

        return result
Exemplo n.º 15
0
    def _build_form(self, cr, uid, field_datas, value1, value2):

        update_values = {}
        update_fields = {}
        columns = {}

        form_grp = etree.Element('group', colspan="4", col="2")
        orm.setup_modifiers(form_grp)

        for fid, fname, fdescription, ttype, required, relation, readonly in field_datas:
            val1 = value1[fname]
            val2 = value2[fname]
            my_selection = []
            size = 24

            if (val1 and val2) and (val1 == val2):
                if ttype in ('many2one'):
                    update_values.update({fname: val1.id})
                elif ttype in ('many2many'):
                    update_values.update({fname: [(6, 0, map(lambda x: x.id, val1))]})
                else:
                    update_values.update({fname: val1})

            if (val1 and val2) and (val1 != val2) and not readonly:
                if ttype in ('char', 'text', 'selection'):
                    my_selection = [(val1, val1), (val2, val2)]
                    size = max(len(val1), len(val2))
                if ttype in ('float', 'integer'):
                    my_selection = [(str(val1), str(val1)), (str(val2), str(val2))]
                if ttype in ('many2one'):
                    my_selection = [(str(val1.id), val1.name),
                                    (str(val2.id), val2.name)]
                if ttype in ('many2many'):
                    update_values.update({fname:
                        [(6, 0, list(set(map(lambda x: x.id, val1 + val2))))]})
                if my_selection:
                    if not required:
                        my_selection.append((False, ''))
                    columns.update({fname:
                        fields.sparse('container',
                                      type='selection',
                                      selection=my_selection,
                                      string=fdescription,
                                      required=required,
                                      size=size)})
                    update_fields.update({fname: {
                        'string': fdescription,
                        'type': 'selection',
                        'selection': my_selection,
                        'required': required}})
                    f = etree.SubElement(form_grp, 'field', name=fname)
                    orm.setup_modifiers(f, field=update_fields[fname])

            if (val1 and not val2) or (not val1 and val2):
                if ttype == 'many2one':
                    update_values.update({fname: val1 and val1.id or val2 and val2.id})
                elif ttype == 'many2many':
                    update_values.update({fname: [(6, 0, map(lambda x: x.id, val1 or val2))]})
                elif ttype == 'one2many':
                    #skip one2many values
                    pass
                else:
                    update_values.update({fname: val1 or val2})

        return form_grp, update_fields, update_values, columns