<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Author:  <NAME>, <NAME>, <NAME>
#    Copyright 2013 Camptocamp SA
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more description.
#
#    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/>.
#
##############################################################################

import logging
import time

from openerp.osv import fields, orm
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
import openerp.addons.decimal_precision as dp

_logger = logging.getLogger(__name__)


class res_partner(orm.Model):
    _inherit = "res.partner"

    def _store_get_requisition_ids(self, cr, uid, ids, sfield, context=None):
        req_obj = self.pool.get('logistic.requisition')
        req_ids = req_obj.search(cr, uid, [(sfield, 'in', ids)], context=context)
        return req_ids


class logistic_requisition(orm.Model):
    _name = "logistic.requisition"
    _description = "Logistic Requisition"
    _inherit = ['mail.thread']
    _order = "name desc"

    REQ_STATES = {'confirmed': [('readonly', True)],
                  'done': [('readonly', True)]
                  }

    def get_partner_requisition(self, cr, uid, ids, context=None):
        model = self.pool['res.partner']
        return model._store_get_requisition_ids(cr, uid, ids, sfield='consignee_shipping_id', context=context)

    _columns = {
        'name': fields.char(
            'Reference',
            required=True,
            readonly=True),
        # Not intended to match OpenERP origin field convention.
        # Source comes from paper
        'source_document': fields.char(
            'Source Document',
            states=REQ_STATES,
        ),
        'date': fields.date(
            'Requisition Date',
            states=REQ_STATES,
            required=True
        ),
        'date_delivery': fields.date(
            'Desired Delivery Date',
            states=REQ_STATES,
            required=True
        ),
        'user_id': fields.many2one(
            'res.users', 'Business Unit Officer', required=True,
            states=REQ_STATES,
            help="Mobilization Officer or Logistic Coordinator "
                 "in charge of the Logistic Requisition"
        ),
        'partner_id': fields.many2one(
            'res.partner', 'Customer', required=True,
            states=REQ_STATES
        ),
        'consignee_id': fields.many2one(
            'res.partner', 'Consignee',
            states=REQ_STATES
        ),
        'consignee_shipping_id': fields.many2one(
            'res.partner', 'Delivery Address',
            states=REQ_STATES
        ),
        'country_id': fields.related(
            'consignee_shipping_id',
            'country_id',
            string='Country',
            type='many2one',
            relation='res.country',
            select=True,
            readonly=True,
            store={<commit_msg>[MRG] add domain on LR to filter on partner of type customer for customer field<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Author:  <NAME>, <NAME>, <NAME>
#    Copyright 2013 Camptocamp SA
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more description.
#
#    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/>.
#
##############################################################################

import logging
import time

from openerp.osv import fields, orm
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
import openerp.addons.decimal_precision as dp

_logger = logging.getLogger(__name__)


class res_partner(orm.Model):
    _inherit = "res.partner"

    def _store_get_requisition_ids(self, cr, uid, ids, sfield, context=None):
        req_obj = self.pool.get('logistic.requisition')
        req_ids = req_obj.search(cr, uid, [(sfield, 'in', ids)], context=context)
        return req_ids


class logistic_requisition(orm.Model):
    _name = "logistic.requisition"
    _description = "Logistic Requisition"
    _inherit = ['mail.thread']
    _order = "name desc"

    REQ_STATES = {'confirmed': [('readonly', True)],
                  'done': [('readonly', True)]
                  }

    def get_partner_requisition(self, cr, uid, ids, context=None):
        model = self.pool['res.partner']
        return model._store_get_requisition_ids(cr, uid, ids, sfield='consignee_shipping_id', context=context)

    _columns = {
        'name': fields.char(
            'Reference',
            required=True,
            readonly=True),
        # Not intended to match OpenERP origin field convention.
        # Source comes from paper
        'source_document': fields.char(
            'Source Document',
            states=REQ_STATES,
        ),
        'date': fields.date(
            'Requisition Date',
            states=REQ_STATES,
            required=True
        ),
        'date_delivery': fields.date(
            'Desired Delivery Date',
            states=REQ_STATES,
            required=True
        ),
        'user_id': fields.many2one(
            'res.users', 'Business Unit Officer', required=True,
            states=REQ_STATES,
            help="Mobilization Officer or Logistic Coordinator "
                 "in charge of the Logistic Requisition"
        ),
        'partner_id': fields.many2one(
            'res.partner', 'Customer', required=True, domain=[('customer', '=', True)],
            states=REQ_STATES
        ),
        'consignee_id': fields.many2one(
            'res.partner', 'Consignee',
            states=REQ_STATES
        ),
        'consignee_shipping_id': fields.many2one(
            'res.partner', 'Delivery Address',
            states=REQ_STATES
        ),
        'country_id': fields.related(
            'consignee_shipping_id',
            'country_id',
            string='Country',
            type='many2one',
            relation='res.country',
            select=True,
            readonly=True,
            store={
{'fraction_non_alphanumeric': 0.1382013201320132, 'fraction_numerical': 0.003025302530253025, 'mean_word_length': 2.5067502410800384, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2553405', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1958, 'n_words': 563}