[MIG] partner_changeset: Migrated to 10.0
parent
b41944685a
commit
c7f3b94037
|
@ -136,7 +136,7 @@ Bug Tracker
|
||||||
Bugs are tracked on `GitHub Issues
|
Bugs are tracked on `GitHub Issues
|
||||||
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
|
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
|
||||||
check there if your issue has already been reported. If you spotted it first,
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
help us smashing it by providing a detailed and welcomed `feedback
|
help us smashing it by providing a detailed and welcomed feedback
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
@ -151,6 +151,7 @@ Contributors
|
||||||
|
|
||||||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||||
* Denis Leemann <denis.leemann@camptocamp.com>
|
* Denis Leemann <denis.leemann@camptocamp.com>
|
||||||
|
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{'name': 'Partner Changesets',
|
{'name': 'Partner Changesets',
|
||||||
'version': '9.0.1.0.0',
|
'version': '10.0.1.0.0',
|
||||||
'author': 'Camptocamp, Odoo Community Association (OCA)',
|
'author': 'Camptocamp, Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Sales Management',
|
'category': 'Sales Management',
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
from . import res_partner_changeset
|
from . import res_partner_changeset
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import models, fields, api
|
from odoo import models, fields, api
|
||||||
from openerp.tools.cache import ormcache
|
from odoo.tools.cache import ormcache
|
||||||
|
|
||||||
|
|
||||||
class ChangesetFieldRule(models.Model):
|
class ChangesetFieldRule(models.Model):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from openerp import models, fields, api, exceptions, _
|
from odoo import models, fields, api, exceptions, _
|
||||||
from openerp.osv.orm import setup_modifiers
|
from odoo.osv.orm import setup_modifiers
|
||||||
|
|
||||||
# sentinel object to be sure that no empty value was passed to
|
# sentinel object to be sure that no empty value was passed to
|
||||||
# ResPartnerChangesetChange._value_for_changeset
|
# ResPartnerChangesetChange._value_for_changeset
|
||||||
|
@ -22,7 +22,7 @@ class ResPartnerChangeset(models.Model):
|
||||||
|
|
||||||
partner_id = fields.Many2one(comodel_name='res.partner',
|
partner_id = fields.Many2one(comodel_name='res.partner',
|
||||||
string='Partner',
|
string='Partner',
|
||||||
select=True,
|
index=True,
|
||||||
required=True,
|
required=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
ondelete='cascade')
|
ondelete='cascade')
|
||||||
|
@ -31,7 +31,7 @@ class ResPartnerChangeset(models.Model):
|
||||||
string='Changes',
|
string='Changes',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
date = fields.Datetime(default=fields.Datetime.now,
|
date = fields.Datetime(default=fields.Datetime.now,
|
||||||
select=True,
|
index=True,
|
||||||
readonly=True)
|
readonly=True)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
compute='_compute_state',
|
compute='_compute_state',
|
||||||
|
@ -378,7 +378,8 @@ class ResPartnerChangesetChange(models.Model):
|
||||||
|
|
||||||
field = change.field_id
|
field = change.field_id
|
||||||
value_for_write = change._convert_value_for_write(
|
value_for_write = change._convert_value_for_write(
|
||||||
change.get_new_value()
|
change.get_new_value(),
|
||||||
|
partner
|
||||||
)
|
)
|
||||||
values[field.name] = value_for_write
|
values[field.name] = value_for_write
|
||||||
|
|
||||||
|
@ -421,18 +422,18 @@ class ResPartnerChangesetChange(models.Model):
|
||||||
@api.model
|
@api.model
|
||||||
def _has_field_changed(self, record, field, value):
|
def _has_field_changed(self, record, field, value):
|
||||||
field_def = record._fields[field]
|
field_def = record._fields[field]
|
||||||
current_value = field_def.convert_to_write(record[field])
|
current_value = field_def.convert_to_write(record[field], record)
|
||||||
if not (current_value or value):
|
if not (current_value or value):
|
||||||
return False
|
return False
|
||||||
return current_value != value
|
return current_value != value
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _convert_value_for_write(self, value):
|
def _convert_value_for_write(self, value, record):
|
||||||
if not value:
|
if not value:
|
||||||
return value
|
return value
|
||||||
model = self.env[self.field_id.model_id.model]
|
model = self.env[self.field_id.model_id.model]
|
||||||
model_field_def = model._fields[self.field_id.name]
|
model_field_def = model._fields[self.field_id.name]
|
||||||
return model_field_def.convert_to_write(value)
|
return model_field_def.convert_to_write(value, record)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _value_for_changeset(self, record, field_name, value=_NO_VALUE):
|
def _value_for_changeset(self, record, field_name, value=_NO_VALUE):
|
||||||
|
@ -446,7 +447,7 @@ class ResPartnerChangesetChange(models.Model):
|
||||||
if value is _NO_VALUE:
|
if value is _NO_VALUE:
|
||||||
# when the value is read from the record, we need to prepare
|
# when the value is read from the record, we need to prepare
|
||||||
# it for the write (e.g. extract .id from a many2one record)
|
# it for the write (e.g. extract .id from a many2one record)
|
||||||
value = field_def.convert_to_write(record[field_name])
|
value = field_def.convert_to_write(record[field_name], record)
|
||||||
if field_def.type == 'many2one':
|
if field_def.type == 'many2one':
|
||||||
# store as 'reference'
|
# store as 'reference'
|
||||||
comodel = field_def.comodel_name
|
comodel = field_def.comodel_name
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="group_changeset_manager" model="res.groups">
|
<record id="group_changeset_manager" model="res.groups">
|
||||||
<field name="name">Changeset Configuration</field>
|
<field name="name">Changeset Configuration</field>
|
||||||
<field name="comment">The user will have an access to the configuration of the changeset rules.</field>
|
<field name="comment">The user will have an access to the configuration of the changeset rules.</field>
|
||||||
|
@ -24,6 +23,6 @@
|
||||||
<field name="implied_ids" eval="[(4, ref('group_changeset_manager'))]"/>
|
<field name="implied_ids" eval="[(4, ref('group_changeset_manager'))]"/>
|
||||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
|
||||||
|
</odoo>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|
||||||
class ChangesetMixin(object):
|
class ChangesetMixin(object):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp.tests import common
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
class TestChangesetFieldRule(common.TransactionCase):
|
class TestChangesetFieldRule(common.TransactionCase):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp.tests import common
|
from odoo.tests import common
|
||||||
from .common import ChangesetMixin
|
from .common import ChangesetMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from openerp import fields, exceptions
|
from odoo import fields, exceptions
|
||||||
from openerp.tests import common
|
from odoo.tests import common
|
||||||
from .common import ChangesetMixin
|
from .common import ChangesetMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2015-2016 Camptocamp SA
|
# Copyright 2015-2017 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp.tests import common
|
from odoo.tests import common
|
||||||
from .common import ChangesetMixin
|
from .common import ChangesetMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
<menuitem id="menu_changeset"
|
<menuitem id="menu_changeset"
|
||||||
name="Partner Changesets"
|
name="Partner Changesets"
|
||||||
groups="group_changeset_user"
|
groups="group_changeset_user"
|
||||||
parent="base.menu_sales_config"
|
parent="sale.menu_sales_config"
|
||||||
sequence="20"/>
|
sequence="20"/>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue