Browse Source
Merge pull request #515 from hbrunn/8.0-partner_contact_birthdate-mute_logger
[IMP] mute logger in test
pull/444/merge
Stefan Rijnhart (Opener)
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
19 additions and
15 deletions
-
partner_contact_birthdate/__openerp__.py
-
partner_contact_birthdate/hooks.py
-
partner_contact_birthdate/models.py
-
partner_contact_birthdate/tests/test_birthdate.py
|
|
@ -29,4 +29,5 @@ |
|
|
|
"views/res_partner.xml", |
|
|
|
], |
|
|
|
"post_init_hook": "post_init_hook", |
|
|
|
"license": "AGPL-3", |
|
|
|
} |
|
|
@ -7,4 +7,4 @@ from openerp.api import Environment |
|
|
|
def post_init_hook(cr, pool): |
|
|
|
env = Environment(cr, SUPERUSER_ID, {}) |
|
|
|
env['res.partner'].search( |
|
|
|
[('birthdate', "!=", False)])._birthdate_inverse() |
|
|
|
[('birthdate', "!=", False)])._inverse_birthdate() |
|
|
@ -32,22 +32,24 @@ class Partner(models.Model): |
|
|
|
|
|
|
|
# Make the old Char field to reflect the new Date field |
|
|
|
birthdate = fields.Char( |
|
|
|
compute="_birthdate_compute", |
|
|
|
inverse="_birthdate_inverse", |
|
|
|
compute="_compute_birthdate", |
|
|
|
inverse="_inverse_birthdate", |
|
|
|
store=True) |
|
|
|
|
|
|
|
@api.one |
|
|
|
@api.multi |
|
|
|
@api.depends("birthdate_date") |
|
|
|
def _birthdate_compute(self): |
|
|
|
def _compute_birthdate(self): |
|
|
|
"""Store a string of the new date in the old field.""" |
|
|
|
self.birthdate = self.birthdate_date |
|
|
|
for this in self: |
|
|
|
this.birthdate = this.birthdate_date |
|
|
|
|
|
|
|
@api.one |
|
|
|
def _birthdate_inverse(self): |
|
|
|
@api.multi |
|
|
|
def _inverse_birthdate(self): |
|
|
|
"""Convert the old Char date to the new Date format.""" |
|
|
|
try: |
|
|
|
self.birthdate_date = self.birthdate |
|
|
|
except ValueError: |
|
|
|
_logger.warn( |
|
|
|
_("Could not convert '{0.birthdate}' to date in " |
|
|
|
"res.partner {0.id} ({0.name}). Skipping.").format(self)) |
|
|
|
for this in self: |
|
|
|
try: |
|
|
|
this.birthdate_date = this.birthdate |
|
|
|
except ValueError: |
|
|
|
_logger.warn( |
|
|
|
_("Could not convert '{0.birthdate}' to date in " |
|
|
|
"res.partner {0.id} ({0.name}). Skipping.").format(this)) |
|
|
@ -16,7 +16,7 @@ |
|
|
|
# You should have received a copy of the GNU Affero General Public License |
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
from openerp import fields |
|
|
|
from openerp import fields, tools |
|
|
|
from openerp.tests.common import TransactionCase |
|
|
|
from datetime import date |
|
|
|
|
|
|
@ -49,5 +49,6 @@ class BadCase(TransactionCase): |
|
|
|
self.partner.birthdate_date) |
|
|
|
super(BadCase, self).tearDown() |
|
|
|
|
|
|
|
@tools.mute_logger('openerp.addons.partner_contact_birthdate.models') |
|
|
|
def test_old_to_new(self): |
|
|
|
self.partner.birthdate = "Not a date" |