Browse Source

Set fields readonly

pull/208/head
Guewen Baconnier 9 years ago
parent
commit
ecc5a82a55
  1. 66
      partner_revision/models/res_partner_revision.py
  2. 6
      partner_revision/views/res_partner_revision_views.xml

66
partner_revision/models/res_partner_revision.py

@ -36,12 +36,15 @@ class ResPartnerRevision(models.Model):
partner_id = fields.Many2one(comodel_name='res.partner', partner_id = fields.Many2one(comodel_name='res.partner',
string='Partner', string='Partner',
select=True, select=True,
required=True)
required=True,
readonly=True)
change_ids = fields.One2many(comodel_name='res.partner.revision.change', change_ids = fields.One2many(comodel_name='res.partner.revision.change',
inverse_name='revision_id', inverse_name='revision_id',
string='Changes')
string='Changes',
readonly=True)
date = fields.Datetime(default=fields.Datetime.now, date = fields.Datetime(default=fields.Datetime.now,
select=True)
select=True,
readonly=True)
state = fields.Selection( state = fields.Selection(
compute='_compute_state', compute='_compute_state',
selection=[('draft', 'Pending'), selection=[('draft', 'Pending'),
@ -126,10 +129,12 @@ class ResPartnerRevisionChange(models.Model):
revision_id = fields.Many2one(comodel_name='res.partner.revision', revision_id = fields.Many2one(comodel_name='res.partner.revision',
required=True, required=True,
string='Revision', string='Revision',
ondelete='cascade')
ondelete='cascade',
readonly=True)
field_id = fields.Many2one(comodel_name='ir.model.fields', field_id = fields.Many2one(comodel_name='ir.model.fields',
string='Field', string='Field',
required=True)
required=True,
readonly=True)
field_type = fields.Selection(related='field_id.ttype', field_type = fields.Selection(related='field_id.ttype',
string='Field Type', string='Field Type',
readonly=True) readonly=True)
@ -143,25 +148,41 @@ class ResPartnerRevisionChange(models.Model):
compute='_compute_value_display', compute='_compute_value_display',
) )
current_value_char = fields.Char(string='Current')
current_value_date = fields.Date(string='Current')
current_value_datetime = fields.Datetime(string='Current')
current_value_float = fields.Float(string='Current')
current_value_integer = fields.Integer(string='Current')
current_value_text = fields.Text(string='Current')
current_value_boolean = fields.Boolean(string='Current')
current_value_char = fields.Char(string='Current',
readonly=True)
current_value_date = fields.Date(string='Current',
readonly=True)
current_value_datetime = fields.Datetime(string='Current',
readonly=True)
current_value_float = fields.Float(string='Current',
readonly=True)
current_value_integer = fields.Integer(string='Current',
readonly=True)
current_value_text = fields.Text(string='Current',
readonly=True)
current_value_boolean = fields.Boolean(string='Current',
readonly=True)
current_value_reference = fields.Reference(string='Current', current_value_reference = fields.Reference(string='Current',
selection='_reference_models')
new_value_char = fields.Char(string='New')
new_value_date = fields.Date(string='New')
new_value_datetime = fields.Datetime(string='New')
new_value_float = fields.Float(string='New')
new_value_integer = fields.Integer(string='New')
new_value_text = fields.Text(string='New')
new_value_boolean = fields.Boolean(string='New')
selection='_reference_models',
readonly=True)
new_value_char = fields.Char(string='New',
readonly=True)
new_value_date = fields.Date(string='New',
readonly=True)
new_value_datetime = fields.Datetime(string='New',
readonly=True)
new_value_float = fields.Float(string='New',
readonly=True)
new_value_integer = fields.Integer(string='New',
readonly=True)
new_value_text = fields.Text(string='New',
readonly=True)
new_value_boolean = fields.Boolean(string='New',
readonly=True)
new_value_reference = fields.Reference(string='New', new_value_reference = fields.Reference(string='New',
selection='_reference_models')
selection='_reference_models',
readonly=True)
state = fields.Selection( state = fields.Selection(
selection=[('draft', 'Pending'), selection=[('draft', 'Pending'),
@ -170,6 +191,7 @@ class ResPartnerRevisionChange(models.Model):
], ],
required=True, required=True,
default='draft', default='draft',
readonly=True,
) )
@api.model @api.model

6
partner_revision/views/res_partner_revision_views.xml

@ -5,7 +5,7 @@
<field name="name">res.partner.revision.tree</field> <field name="name">res.partner.revision.tree</field>
<field name="model">res.partner.revision</field> <field name="model">res.partner.revision</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Partner Revision">
<tree string="Partner Revision" delete="false" create="false">
<field name="partner_id"/> <field name="partner_id"/>
<field name="date"/> <field name="date"/>
<field name="state"/> <field name="state"/>
@ -17,7 +17,7 @@
<field name="name">res.partner.revision.form</field> <field name="name">res.partner.revision.form</field>
<field name="model">res.partner.revision</field> <field name="model">res.partner.revision</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Partner Revision">
<form string="Partner Revision" delete="false" create="false">
<header> <header>
<button name="apply" <button name="apply"
string="Apply pending changes" type="object" string="Apply pending changes" type="object"
@ -68,7 +68,7 @@
<field name="name">res.partner.revision.change.form</field> <field name="name">res.partner.revision.change.form</field>
<field name="model">res.partner.revision.change</field> <field name="model">res.partner.revision.change</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Partner Revision Change">
<form string="Partner Revision Change" delete="false" create="false">
<header> <header>
<button name="apply" <button name="apply"
string="Apply" type="object" string="Apply" type="object"

Loading…
Cancel
Save