@@ -151,22 +193,14 @@
colors="grey:state=='cancelled';blue:state in ('active',);black:state in ('closed',); red:state in ()"
>
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -174,5 +208,3 @@
-
diff --git a/logistic/waybill.py b/logistic/waybill.py
index d9174ad..a6c2060 100644
--- a/logistic/waybill.py
+++ b/logistic/waybill.py
@@ -1,109 +1,451 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# Logistic
-# Copyright (C) 2014 No author.
-# No email
-#
-# 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 details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see
.
-#
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
##############################################################################
-import re
+from openerp import models, fields, api
from openerp import netsvc
-from openerp.osv import osv, fields
+from openerp.exceptions import Warning
+from openerp.tools.translate import _
+
+
+class waybill(models.Model):
-class waybill(osv.osv):
""""""
-
_name = 'logistic.waybill'
- _description = 'waybill'
- _inherits = { }
- _inherit = [ 'ir.needaction_mixin','mail.thread' ]
+ _inherit = ['ir.needaction_mixin', 'mail.thread']
_states_ = [
# State machine: weybill_basic
- ('active','Active'),
- ('closed','Closed'),
- ('cancelled','Cancelled'),
+ ('active', 'Active'),
+ ('closed', 'Closed'),
+ ('cancelled', 'Cancelled'),
]
_track = {
'state': {
- 'logistic.waybill_active': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'active',
- 'logistic.waybill_closed': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'closed',
- 'logistic.waybill_cancelled': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancelled',
+ 'logistic.waybill_active': (
+ lambda self, cr, uid, obj, ctx=None: obj['state'] == 'active'),
+ 'logistic.waybill_closed': (
+ lambda self, cr, uid, obj, ctx=None: obj['state'] == 'closed'),
+ 'logistic.waybill_cancelled': (
+ lambda self, cr, uid, obj, ctx=None:
+ obj['state'] == 'cancelled'),
},
}
- _columns = {
- 'name': fields.char(string='Name', readonly=True),
- 'reference': fields.char(string='Reference'),
- 'date': fields.date(string='Date', readonly=True, required=True, states={'active': [('readonly', False)]}),
- 'tractor_id': fields.many2one('fleet.vehicle', string='Tractor', readonly=True, required=True, states={'active': [('readonly', False)]}, context={'default_type':'tractor'}, domain=[('type','=','tractor')], on_change='on_change_vehicle(vehicle_id, context)'),
- 'wagon_id': fields.many2one('fleet.vehicle', string='Wagon', readonly=True, required=True, states={'active': [('readonly', False)]}, context={'default_type':'wagon'}, domain=[('type','=','wagon')]),
- 'driver_id': fields.many2one('res.partner', string='Driver', readonly=True, required=True, states={'active': [('readonly', False)]}, context={'default_is_driver':True}, domain=[('is_driver','=',True)]),
- 'initial_odometer': fields.float(string='Initial Odometer', readonly=True, required=True, states={'active': [('readonly', False)]}),
- 'final_odometer': fields.float(string='Final Odometer', readonly=True, required=True, states={'active': [('readonly', False)]}),
- 'odometer_unit': fields.selection([(u'kilometers', u'Kilometers'), (u'miles', u'Miles')], string='Odometer Unit', readonly=True, required=True, states={'active': [('readonly', False)]}),
- 'note': fields.text(string='Note'),
- 'company_id': fields.many2one('res.company', string='Company', required=True),
- 'date_start': fields.datetime(string='Date Start', readonly=True, states={'active': [('readonly', False)]}),
- 'date_finish': fields.datetime(string='Date Finish', readonly=True, states={'active': [('readonly', False)]}),
- 'driver_product_id': fields.many2one('product.product', string='Driver Product', readonly=True, states={'active': [('readonly', False)]}, context={'default_type':'service','default_service_subtype':'other'}, domain=[('type','=','service'),('service_subtype','=','other')]),
- 'distance': fields.float(string='Distance', readonly=True),
- 'driver_unit_price': fields.float(string='Driver Unit Price', states={'active': [('readonly', False)]}),
- 'currency_id': fields.many2one('res.currency', string='Currency'),
- 'company_id': fields.many2one('res.company', string='Company', required=True),
- 'initial_liters': fields.float(string='Initial Liters', readonly=True, states={'active': [('readonly', False)]}),
- 'final_liters': fields.float(string='Final Liters', readonly=True, states={'active': [('readonly', False)]}),
- 'charged_liters': fields.float(string='Charged Liters', readonly=True),
- 'consumed_liters': fields.float(string='Consumed Liters', readonly=True),
- 'consumption': fields.float(string='Consumption (Km/L)', readonly=True),
- 'state': fields.selection(_states_, "State"),
- 'travel_ids': fields.one2many('logistic.travel', 'waybill_id', string='Travels', readonly=True, states={'active': [('readonly', False)]}),
- 'waybill_expense_ids': fields.one2many('logistic.waybill_expense', 'waybill_id', string='Expenses', readonly=True, states={'active': [('readonly', False)]}),
- 'driver_payment_id': fields.many2one('logistic.waybill_driver_payment', string='Driver Payment', readonly=True),
- }
- _defaults = {
- 'state': 'active',
- 'date': fields.date.context_today,
- 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'logistic.waybill', context=c),
- 'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
- 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'logistic.waybill', context=c),
- 'odometer_unit': 'kilometers',
- }
+ @api.one
+ def _get_currency(self):
+ self.currency_id = self.env['res.users'].browse(
+ self._uid).company_id.currency_id.id
+ name = fields.Char(
+ string='Name',
+ readonly=True
+ )
+ reference = fields.Char(
+ string='Reference'
+ )
+ date = fields.Date(
+ string='Date',
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]},
+ default=fields.date.today()
+ )
+ tractor_id = fields.Many2one(
+ 'fleet.vehicle',
+ string='Tractor',
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]},
+ context={'default_type': 'tractor'},
+ domain=[('type', '=', 'tractor')],
+ on_change='on_change_vehicle(vehicle_id, context)'
+ )
+ wagon_id = fields.Many2one(
+ 'fleet.vehicle',
+ string='Wagon',
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]},
+ context={'default_type': 'wagon'},
+ domain=[('type', '=', 'wagon')]
+ )
+ driver_id = fields.Many2one(
+ 'res.partner',
+ string='Driver',
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]},
+ context={'default_is_driver': True},
+ domain=[('is_driver', '=', True)]
+ )
+ odometer_unit = fields.Selection(
+ [('kilometers', 'Kilometers'), ('miles', 'Miles')],
+ string='Odometer Unit',
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]},
+ default='kilometers'
+ )
+ note = fields.Text(
+ string='Note'
+ )
+ company_id = fields.Many2one(
+ 'res.company',
+ string='Company',
+ required=True
+ )
+ date_start = fields.Datetime(
+ string='Date Start',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ date_finish = fields.Datetime(
+ string='Date Finish',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ driver_product_id = fields.Many2one(
+ 'product.product',
+ string='Driver Product',
+ readonly=True,
+ states={'active': [('readonly', False)]},
+ context={'default_type': 'service',
+ 'default_service_subtype': 'other'},
+ domain=[('type', '=', 'service'), ('service_subtype', '=', 'other')]
+ )
+ driver_unit_price = fields.Float(
+ string='Driver Unit Price',
+ states={'active': [('readonly', False)]}
+ )
+ currency_id = fields.Many2one(
+ 'res.currency',
+ string='Currency',
+ default=_get_currency
+ )
+ company_id = fields.Many2one(
+ 'res.company',
+ string='Company',
+ required=True,
+ default=lambda s: s.env['res.company']._company_default_get(
+ 'logistic.waybill')
+ )
+ initial_liters = fields.Float(
+ string='Initial Liters',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ final_liters = fields.Float(
+ string='Final Liters',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ state = fields.Selection(
+ _states_,
+ "State",
+ default='active'
+ )
+ travel_ids = fields.One2many(
+ 'logistic.travel',
+ 'waybill_id',
+ string='Travels',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ waybill_expense_ids = fields.One2many(
+ 'logistic.waybill_expense',
+ 'waybill_id',
+ string='Expenses',
+ readonly=True, states={'active': [('readonly', False)]}
+ )
+ driver_payment_id = fields.Many2one(
+ 'logistic.waybill_driver_payment',
+ string='Driver Payment', readonly=True
+ )
+ charged_liters = fields.Float(
+ string=_('Charged'),
+ compute='_get_fuel_data'
+ )
+ consumed_liters = fields.Float(
+ string=_('Consumed Liters'),
+ compute='_get_fuel_data'
+ )
+ consumption = fields.Float(
+ string='Consumption (l/km)',
+ compute='_get_fuel_data',
+ store=True,
+ )
+ consumption_copy = fields.Float(
+ related='consumption',
+ string=_('Consumption')
+ )
+ initial_odometer_id = fields.Many2one(
+ 'fleet.vehicle.odometer',
+ string='Initial Odometer',
+ help='Odometer measure of the vehicle at the moment of this log',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ initial_odometer = fields.Float(
+ inverse='_set_initial_odometer',
+ compute='_get_initial_odometer',
+ string=_('Initial Odometer'),
+ readonly=True,
+ required=True,
+ states={'active': [('readonly', False)]}
+ )
+ final_odometer_id = fields.Many2one(
+ 'fleet.vehicle.odometer', 'Final Odometer',
+ help='Odometer measure of the vehicle at the moment of this log',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ final_odometer = fields.Float(
+ inverse='_set_final_odometer',
+ compute='_get_final_odometer',
+ string='Final Odometer',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ distance = fields.Float(
+ string=_('Distance'),
+ compute='_get_distance'
+ )
+ driver_total = fields.Float(
+ string=_('Driver Total'),
+ compute='_get_amounts'
+ )
+ wagon_initial_odometer_id = fields.Many2one(
+ 'fleet.vehicle.odometer', 'Initial Odometer',
+ help='Odometer measure of the vehicle at the moment of this log',
+ readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ wagon_initial_odometer = fields.Float(
+ inverse='_set_wagon_initial_odometer',
+ compute='_get_wagon_initial_odometer',
+ string='Initial Odometer', readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ wagon_final_odometer_id = fields.Many2one(
+ 'fleet.vehicle.odometer', 'Final Odometer',
+ help='Odometer measure of the vehicle at the moment of this log',
+ readonly=True, states={'active': [('readonly', False)]})
+ wagon_final_odometer = fields.Float(
+ inverse='_set_wagon_final_odometer',
+ compute='_get_wagon_final_odometer',
+ string='Final Odometer', readonly=True,
+ states={'active': [('readonly', False)]}
+ )
+ tractor_status = fields.Selection(
+ related='tractor_id.requirement_state',
+ string='Tractor Status'
+ )
+ wagon_status = fields.Selection(
+ related='wagon_id.requirement_state',
+ string='Wagon Status'
+ )
+ driver_status = fields.Selection(
+ related='driver_id.requirement_state',
+ string='Driver Status'
+ )
- _constraints = [
- ]
+ @api.one
+ @api.depends('initial_odometer', 'final_odometer')
+ def _get_distance(self):
+ if self.initial_odometer and self.final_odometer:
+ self.distance = self.final_odometer - self.initial_odometer
+ @api.one
+ @api.onchange(
+ 'final_odometer', 'initial_odometer', 'wagon_initial_odometer')
+ def on_change_tractor_final_odometer(self):
+ if (
+ self.initial_odometer and
+ self.final_odometer and
+ self.wagon_initial_odometer
+ ):
+ self.wagon_final_odometer = self.final_odometer - \
+ self.initial_odometer + self.wagon_initial_odometer
- def on_change_vehicle(self, cr, uid, ids, vehicle_id, context=None):
- """"""
- raise NotImplementedError
+ @api.one
+ @api.onchange('wagon_id')
+ def on_change_wagon(self):
+ self.wagon_initial_odometer = self.wagon_id.odometer
+
+ @api.one
+ @api.onchange('driver_id')
+ def on_change_driver(self):
+ self.driver_product_id = self.driver_id.driver_product_id.id
+
+ @api.one
+ @api.onchange('driver_product_id')
+ def on_change_product(self):
+ self.driver_unit_price = self.driver_product_id.list_price
+
+ @api.one
+ @api.onchange('tractor_id')
+ def on_change_tractor(self):
+ self.initial_odometer = self.tractor_id.odometer
+ if self.tractor_id.wagon_id.id:
+ self.wagon_id = self.tractor_id.wagon_id.id
+ else:
+ self.wagon_id = False
+ self.wagon_initial_odometer = False
+ if self.tractor_id.driver_id.id:
+ self.driver_id = self.tractor_id.driver_id.id
+ else:
+ self.driver_id = False
def action_wfk_set_active(self, cr, uid, ids, *args):
- self.write(cr, uid, ids, {'state':'active'})
+ self.write(cr, uid, ids, {'state': 'active'})
wf_service = netsvc.LocalService("workflow")
for obj_id in ids:
wf_service.trg_delete(uid, 'logistic.waybill', obj_id, cr)
wf_service.trg_create(uid, 'logistic.waybill', obj_id, cr)
return True
+ @api.one
+ def _get_initial_odometer(self):
+ if self.initial_odometer_id:
+ self.initial_odometer = self.initial_odometer_id.value
+
+ @api.one
+ def _set_initial_odometer(self):
+ if not self.initial_odometer:
+ return True
+ date = self.date
+ if not self.date:
+ date = fields.date.today()
+ data = {'value': self.initial_odometer, 'date': date,
+ 'vehicle_id': self.tractor_id.id}
+ odometer_id = self.env['fleet.vehicle.odometer'].create(data)
+ self.initial_odometer_id = odometer_id
+
+ @api.one
+ def _get_final_odometer(self):
+ if self.final_odometer_id:
+ self.final_odometer = self.final_odometer_id.value
+
+ @api.one
+ def _set_final_odometer(self):
+ if not self.final_odometer:
+ return True
+ date = self.date
+ if not self.date:
+ date = fields.date.today()
+ data = {'value': self.final_odometer, 'date': date,
+ 'vehicle_id': self.tractor_id.id}
+ odometer_id = self.env['fleet.vehicle.odometer'].create(data)
+ self.final_odometer_id = odometer_id
+
+ @api.one
+ def _get_wagon_initial_odometer(self):
+ if self.wagon_initial_odometer_id:
+ self.wagon_initial_odometer = self.wagon_initial_odometer_id.value
+
+ @api.one
+ def _set_wagon_initial_odometer(self):
+ if not self.wagon_initial_odometer:
+ return True
+ date = self.date
+ if not self.date:
+ date = fields.date.today()
+ data = {'value': self.wagon_initial_odometer, 'date': date,
+ 'vehicle_id': self.wagon_id.id}
+ odometer_id = self.env['fleet.vehicle.odometer'].create(data)
+ self.wagon_initial_odometer_id = odometer_id
+
+ @api.one
+ def _get_wagon_final_odometer(self):
+ if self.wagon_final_odometer_id:
+ self.wagon_final_odometer = self.wagon_final_odometer_id.value
+
+ @api.one
+ def _set_wagon_final_odometer(self):
+ if not self.wagon_final_odometer:
+ return True
+ date = self.date
+ if not self.date:
+ date = fields.date.today()
+ data = {'value': self.wagon_final_odometer, 'date': date,
+ 'vehicle_id': self.wagon_id.id}
+ odometer_id = self.env['fleet.vehicle.odometer'].create(data)
+ self.wagon_final_odometer_id = odometer_id
+
+ def _get_amounts(self):
+ self.driver_total = False
+ if self.driver_unit_price and self.distance:
+ self.driver_total = self.driver_unit_price * self.distance
+
+ @api.one
+ @api.depends(
+ 'distance',
+ 'initial_liters',
+ 'final_liters',
+ 'waybill_expense_ids.product_id.is_fuel',
+ 'waybill_expense_ids.product_uom_qty')
+ def _get_fuel_data(self):
+ charged_liters = sum(self.mapped('waybill_expense_ids').filtered(
+ lambda x: x.product_id.is_fuel).mapped('product_uom_qty'))
+ consumed_liters = self.initial_liters + \
+ charged_liters - self.final_liters
+ if self.distance != 0:
+ consumption = consumed_liters / self.distance
+ else:
+ consumption = 0
+ self.charged_liters = charged_liters
+ self.consumed_liters = consumed_liters
+ self.consumption = consumption
+ def create(self, cr, uid, vals, context=None):
+ if vals.get('name', '/') == '/':
+ vals['name'] = self.pool.get('ir.sequence').get(
+ cr, uid, 'logistic.waybill') or '/'
+ return super(waybill, self).create(cr, uid, vals, context=context)
-waybill()
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default:
+ default = {}
+ default.update({
+ 'date': fields.date_today(),
+ 'travel_ids': [],
+ 'waybill_expense_ids': [],
+ 'initial_odometer_id': False,
+ 'initial_odometer': self.browse(cr, uid, id, context=context).tractor_id.odometer,
+ 'final_odometer_id': False,
+ 'wagon_initial_odometer_id': False,
+ 'wagon_initial_odometer': self.browse(cr, uid, id, context=context).wagon_id.odometer,
+ 'wagon_final_odometer_id': False,
+ 'name': self.pool.get('ir.sequence').get(cr, uid, 'logistic.waybill'),
+ })
+ return super(waybill, self).copy(cr, uid, id, default, context=context)
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ def check_closure(self, cr, uid, ids, context=None):
+ travel_obj = self.pool['logistic.travel']
+ for record in self.browse(cr, uid, ids, context=context):
+ if not record.final_odometer or record.initial_odometer >= record.final_odometer:
+ raise Warning(
+ _('Error!'), _('Tractor Final odometer must be greater than initial odometer!'))
+ if not record.wagon_final_odometer or record.wagon_initial_odometer >= record.wagon_final_odometer:
+ raise Warning(
+ _('Error!'), _('Wagon Final odometer must be greater than initial odometer!'))
+ if not record.date_start:
+ travel_ids = travel_obj.search(
+ cr, uid, [('waybill_id', '=', record.id)], order='from_date', context=context)
+ if travel_ids and not record.date_start:
+ date_start = travel_obj.browse(
+ cr, uid, travel_ids[0], context=context).from_date
+ self.write(
+ cr, uid, [record.id], {'date_start': date_start}, context=context)
+ if not record.date_finish:
+ travel_ids = travel_obj.search(
+ cr, uid, [('waybill_id', '=', record.id)], order='to_date desc', context=context)
+ if travel_ids and not record.date_finish:
+ date_finish = travel_obj.browse(
+ cr, uid, travel_ids[0], context=context).to_date
+ self.write(
+ cr, uid, [record.id], {'date_finish': date_finish}, context=context)
diff --git a/logistic/waybill_driver_payment.py b/logistic/waybill_driver_payment.py
index 54b6019..5657fb5 100644
--- a/logistic/waybill_driver_payment.py
+++ b/logistic/waybill_driver_payment.py
@@ -1,43 +1,27 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# Logistic
-# Copyright (C) 2014 No author.
-# No email
-#
-# 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 details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see
.
-#
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
##############################################################################
-import re
+from openerp import models, fields
from openerp import netsvc
-from openerp.osv import osv, fields
-class waybill_driver_payment(osv.osv):
+
+class waybill_driver_payment(models.Model):
+
""""""
-
+
_name = 'logistic.waybill_driver_payment'
_description = 'waybill_driver_payment'
- _inherits = { }
- _inherit = [ 'ir.needaction_mixin','mail.thread' ]
+ _inherit = 'ir.needaction_mixin', 'mail.thread'
_states_ = [
# State machine: driver_payment_basic
- ('draft','Draft'),
- ('paid','Paid'),
- ('cancelled','Cancelled'),
+ ('draft', 'Draft'),
+ ('paid', 'Paid'),
+ ('cancelled', 'Cancelled'),
]
_track = {
'state': {
@@ -46,35 +30,38 @@ class waybill_driver_payment(osv.osv):
'logistic.waybill_driver_payment_cancelled': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancelled',
},
}
- _columns = {
- 'name': fields.char(string='Name', readonly=True, required=True, states={'draft': [('readonly', False)]}),
- 'date': fields.date(string='Date', readonly=True, required=True, states={'draft': [('readonly', False)]}),
- 'driver_id': fields.many2one('res.partner', string='Driver', readonly=True, required=True, states={'draft': [('readonly', False)]}, context={'default_is_driver':True}, domain=[('is_driver','=',True)]),
- 'note': fields.text(string='Note'),
- 'state': fields.selection(_states_, "State"),
- 'waybill_ids': fields.one2many('logistic.waybill', 'driver_payment_id', string='Waybills', readonly=True, states={'draft': [('readonly', False)]}),
- }
-
- _defaults = {
- 'state': 'draft',
- 'date': fields.date.context_today,
- }
-
-
- _constraints = [
- ]
+ name = fields.Char(
+ string='Name',
+ readonly=True,
+ required=True, states={'draft': [('readonly', False)]})
+ date = fields.Date(
+ string='Date',
+ readonly=True,
+ required=True,
+ states={'draft': [('readonly', False)]},
+ default=fields.date.today())
+ driver_id = fields.Many2one(
+ 'res.partner',
+ string='Driver',
+ readonly=True,
+ required=True,
+ states={'draft': [('readonly', False)]},
+ context={'default_is_driver': True}, domain=[('is_driver', '=', True)])
+ note = fields.Text(string='Note')
+ state = fields.Selection(_states_, "State", default='draft')
+ waybill_ids = fields.One2many(
+ 'logistic.waybill',
+ 'driver_payment_id',
+ string='Waybills',
+ readonly=True, states={'draft': [('readonly', False)]})
def action_wfk_set_draft(self, cr, uid, ids, *args):
- self.write(cr, uid, ids, {'state':'draft'})
+ self.write(cr, uid, ids, {'state': 'draft'})
wf_service = netsvc.LocalService("workflow")
for obj_id in ids:
- wf_service.trg_delete(uid, 'logistic.waybill_driver_payment', obj_id, cr)
- wf_service.trg_create(uid, 'logistic.waybill_driver_payment', obj_id, cr)
+ wf_service.trg_delete(
+ uid, 'logistic.waybill_driver_payment', obj_id, cr)
+ wf_service.trg_create(
+ uid, 'logistic.waybill_driver_payment', obj_id, cr)
return True
-
-
-
-waybill_driver_payment()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/logistic/waybill_expense.py b/logistic/waybill_expense.py
index cd1c29e..d2f574f 100644
--- a/logistic/waybill_expense.py
+++ b/logistic/waybill_expense.py
@@ -1,59 +1,301 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# Logistic
-# Copyright (C) 2014 No author.
-# No email
-#
-# 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 details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see
.
-#
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
##############################################################################
+from openerp import models, fields, api, _
+import time
+from openerp.exceptions import Warning
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
+import openerp.addons.decimal_precision as dp
-import re
-from openerp import netsvc
-from openerp.osv import osv, fields
-class waybill_expense(osv.osv):
+class waybill_expense(models.Model):
+
""""""
-
+
_name = 'logistic.waybill_expense'
_description = 'waybill_expense'
- _columns = {
- 'supplier_id': fields.many2one('res.partner', string='Supplier', context={'default_supplier':True,'default_customer':False}, domain=[('supplier','=',True)]),
- 'product_id': fields.many2one('product.product', string='Product', required=True, context={'default_purchase_ok':True}, domain=[('purchase_ok','=',True)]),
- 'price_unit': fields.float(string='Price Unit', required=True),
- 'product_uom_qty': fields.float(string='Quantity', required=True),
- 'price_subtotal': fields.float(string='Subtotal', readonly=True, required=True),
- 'invoice_state': fields.boolean(string='Do not Invoice'),
- 'note': fields.text(string='Note'),
- 'invoice_line_id': fields.many2one('account.invoice.line', string='Invoice Line', readonly=True),
- 'waybill_id': fields.many2one('logistic.waybill', string='Waybill', required=True, ondelete='cascade'),
- }
+ @api.one
+ @api.depends('price_unit', 'product_uom_qty')
+ def _amount_line(self):
+ # tax_obj = self.pool.get('account.tax')
+ # cur_obj = self.pool.get('res.currency')
+ self.price_subtotal = self.price_unit * self.product_uom_qty
+ # taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
+ # cur = line.order_id.pricelist_id.currency_id
+ # res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
+
+ price_subtotal = fields.Float(
+ compute='_amount_line',
+ string='Subtotal',
+ digits_compute=dp.get_precision('Account'))
+ supplier_id = fields.Many2one(
+ 'res.partner',
+ string='Supplier',
+ context={'default_supplier': True, 'default_customer': False},
+ domain=[('supplier', '=', True)])
+ product_id = fields.Many2one(
+ 'product.product',
+ string='Product',
+ required=True,
+ context={'default_purchase_ok': True},
+ domain=[('purchase_ok', '=', True)])
+ price_unit = fields.Float(string='Price Unit', required=True)
+ product_uom_qty = fields.Float(
+ string='Quantity', required=True, default=1.0)
+ invoice_state = fields.Boolean(string='Do not Invoice')
+ note = fields.Text(string='Note')
+ invoice_line_id = fields.Many2one(
+ 'account.invoice.line', string='Invoice Line', readonly=True)
+ waybill_id = fields.Many2one(
+ 'logistic.waybill',
+ string='Waybill', required=True, ondelete='cascade')
+ date = fields.Date(
+ related='waybill_id.date', string='Date', store=True)
+
+ def action_invoice_create(self, cr, uid, ids, grouped=False, date_invoice=False, context=None):
+ invoice_ids = []
+ partner_currency = {}
+
+ if context is None:
+ context = {}
+ # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
+ # last day of the last month as invoice date
+ if date_invoice:
+ context['date_invoice'] = date_invoice
+
+ for o in self.browse(cr, uid, ids, context=context):
+ pricelist = self.get_pricelist(
+ cr, uid, o.supplier_id, context=context)
+ currency_id = pricelist.currency_id.id
+ if not o.supplier_id or not o.product_id:
+ raise Warning(
+ _('Warning!'), _('To create invoice expenses must have supplier and product'))
+ if (o.supplier_id.id in partner_currency) and (partner_currency[o.supplier_id.id] <> currency_id):
+ raise Warning(
+ _('Error!'),
+ _('You cannot group expenses having different currencies for the same supplier.'))
+
+ partner_currency[o.supplier_id.id] = currency_id
+ if grouped:
+ for supplier_id in partner_currency:
+ expense_ids = self.search(
+ cr, uid, [('id', 'in', ids), ('supplier_id', '=', supplier_id)], context=context)
+ invoice_ids.append(
+ self._invoice_create(cr, uid, expense_ids, context=context))
+ else:
+ for expense_id in ids:
+ invoice_ids.append(
+ self._invoice_create(cr, uid, [expense_id], context=context))
+ return invoice_ids
+
+ def _invoice_create(self, cr, uid, ids, context=None):
+ inv_obj = self.pool.get('account.invoice')
+ if context is None:
+ context = {}
+ # TODO
+ # self.check_travel_one_partner
+ # Just to make clear that all ids should be from the same partner
+ partner_expense_ids = ids
+ invoice_line_ids = self.invoice_line_create(
+ cr, uid, partner_expense_ids, context=context)
+
+ invoice_vals = self._prepare_invoice(
+ cr, uid, partner_expense_ids, invoice_line_ids, context=context)
+ inv_id = inv_obj.create(cr, uid, invoice_vals, context=context)
+ data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], invoice_vals[
+ 'payment_term'], time.strftime(DEFAULT_SERVER_DATE_FORMAT))
+ if data.get('value', False):
+ inv_obj.write(cr, uid, [inv_id], data['value'], context=context)
+ inv_obj.button_compute(cr, uid, [inv_id])
+ return inv_id
+
+ def get_pricelist(self, cr, uid, partner, context=None):
+ if partner.property_product_pricelist:
+ return partner.property_product_pricelist
+ else:
+ pricelist_ids = self.pool['product.pricelist'].search(
+ cr, uid, [('type', '=', 'purchase')], context=context)
+ if pricelist_ids:
+ pricelist_id = pricelist_ids[0]
+ else:
+ raise Warning(
+ _('Error!'), _('Order cannot be created because no purchase pricelist exists!'))
+ return self.pool['product.pricelist'].browse(cr, uid, pricelist_id, context=context)
+
+ def invoice_line_create(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+
+ create_ids = []
+ if context.get('grouped_line'):
+ product_ids = [x.product_id.id for x in self.browse(
+ cr, uid, ids, context=context) if x.product_id]
+ for product_id in list(set(product_ids)):
+ expense_ids = self.search(
+ cr, uid,
+ [('id', 'in', ids), ('product_id', '=', product_id)],
+ context=context)
+ if expense_ids == []:
+ expense_ids = ids
+ expenses = self.browse(cr, uid, expense_ids, context=context)
+ vals = self._prepare_order_line_invoice_line(
+ cr, uid, expenses, context=context)
+ if vals:
+ inv_line_id = self.pool.get('account.invoice.line').create(
+ cr, uid, vals, context=context)
+ self.write(
+ cr, uid, expense_ids, {'invoice_line_id': inv_line_id}, context=context)
+ create_ids.append(inv_line_id)
+ else:
+ for expense in self.browse(cr, uid, ids, context=context):
+ vals = self._prepare_order_line_invoice_line(
+ cr, uid, expense, context=context)
+ if vals:
+ inv_line_id = self.pool.get('account.invoice.line').create(
+ cr, uid, vals, context=context)
+ self.write(
+ cr, uid, [expense.id], {'invoice_line_id': inv_line_id}, context=context)
+ create_ids.append(inv_line_id)
+ return create_ids
- _defaults = {
- 'product_uom_qty': 1.0,
- }
+ def _prepare_order_line_invoice_line(self, cr, uid, expense, context=None):
+ """Prepare the dict of values to create the new invoice line for a
+ sales order line. This method may be overridden to implement custom
+ invoice generation (making sure to call super() to establish
+ a clean extension chain).
+ :param browse_record line: sale.order.line record to invoice
+ :param int account_id: optional ID of a G/L account to force
+ (this is used for returning products including service)
+ :return: dict of values to create() the invoice line
+ """
+ res = {}
+ if context.get('grouped_line'):
+ if not expense[0].invoice_line_id:
+ if expense[0].product_id:
+ account_id = expense[
+ 0].product_id.property_account_income.id
+ if not account_id:
+ account_id = expense[
+ 0].product_id.categ_id.property_account_income_categ.id
+ if not account_id:
+ raise Warning(_('Error!'),
+ _('Please define income account for this product: "%s" (id:%d).') %
+ (expense.product_id.name, expense.product_id.id,))
+ fpos = expense[0].supplier_id.property_account_position.id or False
+ account_id = self.pool.get('account.fiscal.position').map_account(
+ cr, uid, fpos, account_id)
+ tax_ids = self.pool.get('account.fiscal.position').map_tax(
+ cr, uid, fpos, expense[0].product_id.taxes_id)
+ name = expense[0].product_id.name
+ name += ', Hoja de Ruta: '
+ name += ", ".join(
+ [x.waybill_id.reference for x in expense if x.waybill_id.reference])
+ pu = 0.0
+ uosqty = 0.0
+ for expense_id in expense:
+ uosqty = uosqty + expense_id.product_uom_qty
+ if uosqty:
+ pu = round(expense_id.price_unit,
+ self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
+ if not account_id:
+ raise Warning(_('Error!'),
+ _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
+ res = {
+ 'name': name,
+ 'account_id': account_id,
+ 'price_unit': pu,
+ 'quantity': uosqty,
+ 'uos_id': expense[0].product_id and expense[0].product_id.uom_id.id or False,
+ 'product_id': expense[0].product_id.id or False,
+ 'invoice_line_tax_id': [(6, 0, tax_ids)],
+ }
- _constraints = [
- ]
+ else:
+ if not expense.invoice_line_id:
+ if expense.product_id:
+ account_id = expense.product_id.property_account_income.id
+ if not account_id:
+ account_id = expense.product_id.categ_id.property_account_income_categ.id
+ if not account_id:
+ raise Warning(_('Error!'),
+ _('Please define income account for this product: "%s" (id:%d).') %
+ (expense.product_id.name, expense.product_id.id,))
+ uosqty = self._get_line_qty(cr, uid, expense, context=context)
+ uos_id = self._get_line_uom(cr, uid, expense, context=context)
+ pu = 0.0
+ if uosqty:
+ pu = round(expense.price_unit,
+ self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
+ fpos = expense.supplier_id.property_account_position.id or False
+ account_id = self.pool.get('account.fiscal.position').map_account(
+ cr, uid, fpos, account_id)
+ if not account_id:
+ raise Warning(_('Error!'),
+ _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
+ tax_ids = self.pool.get('account.fiscal.position').map_tax(
+ cr, uid, fpos, expense.product_id.taxes_id)
+ res = {
+ 'name': expense.product_id.name,
+ 'account_id': account_id,
+ 'price_unit': pu,
+ 'quantity': uosqty,
+ # 'discount': line.discount,
+ 'uos_id': uos_id,
+ 'product_id': expense.product_id.id or False,
+ # TODO: add tax
+ 'invoice_line_tax_id': [(6, 0, tax_ids)],
+ }
+ return res
+ def _get_line_qty(self, cr, uid, expense, context=None):
+ return expense.product_uom_qty
+ def _get_line_uom(self, cr, uid, expense, context=None):
+ return expense.product_id and expense.product_id.uom_id.id or False
-waybill_expense()
+ def _prepare_invoice(self, cr, uid, partner_expense_ids, lines, context=None):
+ """Prepare the dict of values to create the new invoice for a
+ sales order. This method may be overridden to implement custom
+ invoice generation (making sure to call super() to establish
+ a clean extension chain).
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ :param browse_record order: sale.order record to invoice
+ :param list(int) line: list of invoice line IDs that must be
+ attached to the invoice
+ :return: dict of value to create() the invoice
+ """
+ expense = self.browse(cr, uid, partner_expense_ids[0], context=context)
+ partner = expense.supplier_id
+ waybill = self.browse(
+ cr, uid, partner_expense_ids[0], context=context).waybill_id
+ company = waybill.company_id
+ if context is None:
+ context = {}
+ journal_ids = self.pool.get('account.journal').search(cr, uid,
+ [('type', '=', 'purchase'),
+ ('company_id', '=', company.id)],
+ limit=1)
+ if not journal_ids:
+ raise Warning(_('Error!'),
+ _('Please define purchases journal for this company: "%s" (id:%d).') % (company.name, company.id))
+ origin = _('Gastos de Hoja de Ruta')
+ invoice_vals = {
+ 'origin': origin,
+ 'type': 'in_invoice',
+ 'account_id': partner.property_account_payable.id,
+ 'partner_id': partner.id,
+ 'journal_id': journal_ids[0],
+ 'invoice_line': [(6, 0, lines)],
+ 'currency_id': self.get_pricelist(cr, uid, partner, context=context).currency_id.id,
+ 'payment_term': partner.property_supplier_payment_term and partner.property_supplier_payment_term.id or False,
+ 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
+ 'date_invoice': context.get('date_invoice', False),
+ 'company_id': company.id,
+ }
+ return invoice_vals
diff --git a/logistic/wizard/__init__.py b/logistic/wizard/__init__.py
index 7465385..e56e7d9 100644
--- a/logistic/wizard/__init__.py
+++ b/logistic/wizard/__init__.py
@@ -1,26 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# Logistic
-# Copyright (C) 2014 No author.
-# No email
-#
-# 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 details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see
.
-#
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
##############################################################################
-
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# import travel_sale_order
+from . import travel_make_invoice
+from . import expense_make_invoice
diff --git a/logistic_x/wizard/expense_make_invoice.py b/logistic/wizard/expense_make_invoice.py
similarity index 100%
rename from logistic_x/wizard/expense_make_invoice.py
rename to logistic/wizard/expense_make_invoice.py
diff --git a/logistic_x/wizard/expense_make_invoice.xml b/logistic/wizard/expense_make_invoice.xml
similarity index 100%
rename from logistic_x/wizard/expense_make_invoice.xml
rename to logistic/wizard/expense_make_invoice.xml
diff --git a/logistic_x/wizard/requirement_replace_wizard.py b/logistic/wizard/requirement_replace_wizard.py
similarity index 100%
rename from logistic_x/wizard/requirement_replace_wizard.py
rename to logistic/wizard/requirement_replace_wizard.py
diff --git a/logistic_x/wizard/requirement_replace_wizard_view.xml b/logistic/wizard/requirement_replace_wizard_view.xml
similarity index 100%
rename from logistic_x/wizard/requirement_replace_wizard_view.xml
rename to logistic/wizard/requirement_replace_wizard_view.xml
diff --git a/logistic_x/wizard/travel_make_invoice.py b/logistic/wizard/travel_make_invoice.py
similarity index 100%
rename from logistic_x/wizard/travel_make_invoice.py
rename to logistic/wizard/travel_make_invoice.py
diff --git a/logistic_x/wizard/travel_make_invoice.xml b/logistic/wizard/travel_make_invoice.xml
similarity index 100%
rename from logistic_x/wizard/travel_make_invoice.xml
rename to logistic/wizard/travel_make_invoice.xml
diff --git a/logistic_x/wizard/travel_sale_order.py b/logistic/wizard/travel_sale_order.py
similarity index 99%
rename from logistic_x/wizard/travel_sale_order.py
rename to logistic/wizard/travel_sale_order.py
index c811c5c..e4bb09e 100644
--- a/logistic_x/wizard/travel_sale_order.py
+++ b/logistic/wizard/travel_sale_order.py
@@ -3,7 +3,7 @@
# For copyright and license notices, see __openerp__.py file in module root
# directory
##############################################################################
-from openerp import models, fields, api
+from openerp import models, fields
from openerp.exceptions import Warning
diff --git a/logistic_x/wizard/travel_sale_order.xml b/logistic/wizard/travel_sale_order.xml
similarity index 100%
rename from logistic_x/wizard/travel_sale_order.xml
rename to logistic/wizard/travel_sale_order.xml
diff --git a/logistic/workflow/requirement_workflow.xml b/logistic/workflow/requirement_workflow.xml
index e65ecd9..729de8c 100644
--- a/logistic/workflow/requirement_workflow.xml
+++ b/logistic/workflow/requirement_workflow.xml
@@ -1,32 +1,7 @@
-
-
-
-
-
+
logistic.requirement.requirement_basic
@@ -49,6 +24,7 @@
OK
+ set_ok()
write({'state':'ok'})
function
@@ -73,6 +49,7 @@
Renewal Requested
+ request_renew()
write({'state':'renewal_requested'})
function
@@ -90,6 +67,7 @@
True
Cancelled
+ action_cancel()
write({'state':'cancelled'})
function
@@ -177,5 +155,3 @@
-
diff --git a/logistic/workflow/waybill_driver_payment_workflow.xml b/logistic/workflow/waybill_driver_payment_workflow.xml
index 71c022a..92a186f 100644
--- a/logistic/workflow/waybill_driver_payment_workflow.xml
+++ b/logistic/workflow/waybill_driver_payment_workflow.xml
@@ -1,29 +1,4 @@
-
-
-
-
@@ -85,5 +60,3 @@
-
diff --git a/logistic/workflow/waybill_workflow.xml b/logistic/workflow/waybill_workflow.xml
index 1123ff3..067502f 100644
--- a/logistic/workflow/waybill_workflow.xml
+++ b/logistic/workflow/waybill_workflow.xml
@@ -1,29 +1,4 @@
-
-
-
-
@@ -49,6 +24,7 @@
Closed
+ check_closure()
write({'state':'closed'})
function
@@ -91,5 +67,3 @@
-
diff --git a/logistic_custom_translations/__openerp__.py b/logistic_custom_translations/__openerp__.py
index f0dde93..9919522 100644
--- a/logistic_custom_translations/__openerp__.py
+++ b/logistic_custom_translations/__openerp__.py
@@ -21,20 +21,19 @@
{'active': False,
- 'author': 'ADHOC.',
- 'category': u'base.module_category_knowledge_management',
- 'demo_xml': [
+ 'author': 'ADHOC SA',
+ 'category': 'base.module_category_knowledge_management',
+ 'demo': [
],
- 'depends': [u'fleet'],
+ 'depends': ['fleet'],
'description': """
Logistic translations
""",
- 'init_xml': [],
'installable': True,
'license': 'AGPL-3',
- 'name': u'Logistic Translations',
+ 'name': 'Logistic Translations',
'test': [],
- 'update_xml': [
+ 'data': [
],
'version': '8.0.0.1.0',
'css': [
diff --git a/logistic_project/__openerp__.py b/logistic_project/__openerp__.py
index fcfd7eb..3253b32 100644
--- a/logistic_project/__openerp__.py
+++ b/logistic_project/__openerp__.py
@@ -22,19 +22,19 @@
{'active': False,
'application': True,
- 'author': 'ADHOC.',
- 'category': u'base.module_category_knowledge_management',
- 'demo_xml': [],
+ 'author': 'ADHOC S.A',
+ 'category': 'base.module_category_knowledge_management',
+ 'demo': [],
'depends': [
- 'logistic_x',
+ 'logistic',
'product_customer_price',
'disable_openerp_online',
- 'purchase_double_validation_imp',
+ # 'purchase_double_validation_imp',
'cron_run_manually',
'partner_person',
'logistic_reports',
],
- 'description': u"""
+ 'description': """
AFTER INSTALLATION CONFIGURATIONS:
* Set purchase ammount to 0
* Enable supplier pricelist on products
@@ -42,12 +42,11 @@
Necesita los repo:
lp:server-env-tools
""",
- 'init_xml': [],
'installable': True,
'license': 'AGPL-3',
- 'name': u'Logistic Project',
+ 'name': 'Logistic Project',
'test': [],
- 'update_xml': [
+ 'data': [
],
- 'version': 'No version',
+ 'version': '8.0.0.0.0',
'website': 'www.adhoc.com.ar'}
diff --git a/logistic_project/i18n/es_AR.po b/logistic_project/i18n/es_AR.po
index d748607..dfcca6e 100644
--- a/logistic_project/i18n/es_AR.po
+++ b/logistic_project/i18n/es_AR.po
@@ -1,12 +1,12 @@
-# Translation of OpenERP Server.
+# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
+"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-05-23 13:27+0000\n"
-"PO-Revision-Date: 2014-05-23 13:27+0000\n"
+"POT-Creation-Date: 2015-09-23 11:57+0000\n"
+"PO-Revision-Date: 2015-09-23 11:57+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
diff --git a/logistic_project/i18n/logistic_project.pot b/logistic_project/i18n/logistic_project.pot
new file mode 100644
index 0000000..dfcca6e
--- /dev/null
+++ b/logistic_project/i18n/logistic_project.pot
@@ -0,0 +1,16 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-23 11:57+0000\n"
+"PO-Revision-Date: 2015-09-23 11:57+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
diff --git a/logistic_reports/__openerp__.py b/logistic_reports/__openerp__.py
index bf00e10..c2160fe 100644
--- a/logistic_reports/__openerp__.py
+++ b/logistic_reports/__openerp__.py
@@ -21,24 +21,23 @@
{'active': False,
'author': 'ADHOC',
'category': 'base.module_category_knowledge_management',
- 'demo_xml': [
+ 'demo': [
],
- 'depends': ['logistic_x', 'report_aeroo'],
+ 'depends': ['logistic', 'report_aeroo'],
'description': """
Logistic Reports
""",
- 'init_xml': [],
'installable': True,
'license': 'AGPL-3',
'name': 'Logistic Reports',
'test': [],
- 'update_xml': [
+ 'data': [
'report/waybill_report.xml',
'view/travel_view.xml',
'view/waybill_view.xml',
'view/report_menu_item.xml',
],
- 'version': 'No version',
+ 'version': '8.0.0.0.0',
'website': 'www.adhoc.com.ar'}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/logistic_reports/i18n/es_AR.po b/logistic_reports/i18n/es.po
similarity index 74%
rename from logistic_reports/i18n/es_AR.po
rename to logistic_reports/i18n/es.po
index 0a9b8dd..593bbb7 100644
--- a/logistic_reports/i18n/es_AR.po
+++ b/logistic_reports/i18n/es.po
@@ -1,13 +1,13 @@
-# Translation of OpenERP Server.
+# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * logistic_reports
#
msgid ""
msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
+"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-02-24 14:29+0000\n"
-"PO-Revision-Date: 2015-02-24 11:40-0300\n"
+"POT-Creation-Date: 2015-09-23 12:11+0000\n"
+"PO-Revision-Date: 2015-09-23 09:13-0300\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -17,49 +17,45 @@ msgstr ""
"X-Generator: Poedit 1.5.4\n"
#. module: logistic_reports
-#: field:logistic.travel,days_range:0 field:logistic.waybill,days_range:0
-msgid "Days Range"
-msgstr "Días de viaje"
-
-#. module: logistic_reports
-#: field:logistic.travel,days_range_avg:0
-msgid "Days Range Average"
-msgstr "Promedio de Días de viaje"
+#: model:ir.actions.act_window,name:logistic_reports.action_analysis_travel_report
+#: model:ir.ui.menu,name:logistic_reports.menu_analysis_travel
+msgid "Analysis Travel"
+msgstr "Análisis de Viaje"
#. module: logistic_reports
-#: view:logistic.travel:0 view:logistic.waybill:0
-msgid "Total"
-msgstr "Total"
+#: field:logistic.waybill,conumption:0
+msgid "Conumption"
+msgstr "Consumo"
#. module: logistic_reports
#: field:logistic.waybill,cost_km:0
-msgid "Cost per km"
-msgstr "Costo por km"
+msgid "Cost km"
+msgstr "Costo por Km"
#. module: logistic_reports
-#: field:logistic.waybill,consumption_copy:0
-msgid "Consumption (l/km)"
-msgstr "Consumo (l/km)"
+#: field:logistic.travel,days_range:0
+msgid "Days Range"
+msgstr "Días de viaje"
#. module: logistic_reports
-#: model:ir.actions.report.xml,name:logistic_reports.waybill_report
-msgid "Waybill"
-msgstr "Hoja de Ruta"
+#: field:logistic.travel,days_range_avg:0
+msgid "Days Range Average"
+msgstr "Promedio de Días de viaje"
#. module: logistic_reports
-#: view:logistic.travel:0
-msgid "Travel"
-msgstr "Viaje"
+#: model:ir.model,name:logistic_reports.model_logistic_waybill
+msgid "Email Thread"
+msgstr "Hilo de Mensajes"
#. module: logistic_reports
-#: view:logistic.waybill:0
-msgid "Payment And Cost"
-msgstr "Costo y Pago"
+#: model:ir.ui.menu,name:logistic_reports.menu_logistic_report
+msgid "Logistic"
+msgstr "Logística"
#. module: logistic_reports
-#: field:logistic.waybill,net_km:0
-msgid "Net per km"
-msgstr "Neto por km"
+#: field:logistic.waybill,net:0
+msgid "Net"
+msgstr "Neto"
#. module: logistic_reports
#: field:logistic.waybill,net_avg:0
@@ -67,43 +63,36 @@ msgid "Net %"
msgstr "Neto %"
#. module: logistic_reports
-#: model:ir.actions.act_window,name:logistic_reports.action_analysis_travel_report
-#: model:ir.ui.menu,name:logistic_reports.menu_analysis_travel
-msgid "Analysis Travel"
-msgstr "Análisis de Viaje"
-
-#. module: logistic_reports
-#: model:ir.ui.menu,name:logistic_reports.menu_logistic_report
-msgid "Logistic"
-msgstr "Logística"
+#: field:logistic.waybill,net_km:0
+msgid "Net per km"
+msgstr "Neto por km"
#. module: logistic_reports
-#: model:ir.model,name:logistic_reports.model_logistic_waybill
-#: view:logistic.waybill:0
-msgid "waybill"
-msgstr "Hoja de ruta"
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_form
+msgid "Payment And Cost"
+msgstr "Costo y Pago"
#. module: logistic_reports
-#: field:logistic.waybill,net:0
-msgid "Net"
-msgstr "Neto"
+#: field:logistic.waybill,price_km:0
+msgid "Price per km"
+msgstr "Precio por km"
#. module: logistic_reports
#: model:ir.actions.act_window,name:logistic_reports.action_logistic_waybill_report
#: model:ir.ui.menu,name:logistic_reports.menu_waybills_report
-#: view:logistic.waybill:0
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_form
msgid "Summary"
msgstr "Resumen"
#. module: logistic_reports
-#: model:ir.model,name:logistic_reports.model_logistic_travel
-msgid "travel"
-msgstr "Viaje"
+#: view:logistic.travel:logistic_reports.view_logistic_travel_tree
+msgid "Total"
+msgstr "Total"
#. module: logistic_reports
-#: field:logistic.waybill,price_km:0
-msgid "Price per km"
-msgstr "Precio por km"
+#: field:logistic.waybill,total_cost:0
+msgid "Total Cost"
+msgstr "Costo Total"
#. module: logistic_reports
#: field:logistic.waybill,total_price:0
@@ -111,6 +100,22 @@ msgid "Total Price"
msgstr "Precio Total"
#. module: logistic_reports
-#: field:logistic.waybill,total_cost:0
-msgid "Total Cost"
-msgstr "Costo Total"
+#: view:logistic.travel:logistic_reports.view_logistic_travel_graph
+#: view:logistic.travel:logistic_reports.view_logistic_travel_tree
+msgid "Travel"
+msgstr "Viaje"
+
+#. module: logistic_reports
+#: model:ir.actions.report.xml,name:logistic_reports.waybill_report
+msgid "Waybill"
+msgstr "Hoja de Ruta"
+
+#. module: logistic_reports
+#: model:ir.model,name:logistic_reports.model_logistic_travel
+msgid "travel"
+msgstr "Viaje"
+
+#. module: logistic_reports
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_report_graph
+msgid "waybill"
+msgstr "Hoja de ruta"
diff --git a/logistic_reports/i18n/logistic_reports.pot b/logistic_reports/i18n/logistic_reports.pot
new file mode 100644
index 0000000..9cf6d28
--- /dev/null
+++ b/logistic_reports/i18n/logistic_reports.pot
@@ -0,0 +1,121 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * logistic_reports
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-23 11:59+0000\n"
+"PO-Revision-Date: 2015-09-23 11:59+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: logistic_reports
+#: model:ir.actions.act_window,name:logistic_reports.action_analysis_travel_report
+#: model:ir.ui.menu,name:logistic_reports.menu_analysis_travel
+msgid "Analysis Travel"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,conumption:0
+msgid "Conumption"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,cost_km:0
+msgid "Cost km"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.travel,days_range:0
+msgid "Days Range"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.travel,days_range_avg:0
+msgid "Days Range Average"
+msgstr ""
+
+#. module: logistic_reports
+#: model:ir.model,name:logistic_reports.model_logistic_waybill
+msgid "Email Thread"
+msgstr ""
+
+#. module: logistic_reports
+#: model:ir.ui.menu,name:logistic_reports.menu_logistic_report
+msgid "Logistic"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,net:0
+msgid "Net"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,net_avg:0
+msgid "Net %"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,net_km:0
+msgid "Net per km"
+msgstr ""
+
+#. module: logistic_reports
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_form
+msgid "Payment And Cost"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,price_km:0
+msgid "Price per km"
+msgstr ""
+
+#. module: logistic_reports
+#: model:ir.actions.act_window,name:logistic_reports.action_logistic_waybill_report
+#: model:ir.ui.menu,name:logistic_reports.menu_waybills_report
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_form
+msgid "Summary"
+msgstr ""
+
+#. module: logistic_reports
+#: view:logistic.travel:logistic_reports.view_logistic_travel_tree
+msgid "Total"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,total_cost:0
+msgid "Total Cost"
+msgstr ""
+
+#. module: logistic_reports
+#: field:logistic.waybill,total_price:0
+msgid "Total Price"
+msgstr ""
+
+#. module: logistic_reports
+#: view:logistic.travel:logistic_reports.view_logistic_travel_graph
+#: view:logistic.travel:logistic_reports.view_logistic_travel_tree
+msgid "Travel"
+msgstr ""
+
+#. module: logistic_reports
+#: model:ir.actions.report.xml,name:logistic_reports.waybill_report
+msgid "Waybill"
+msgstr ""
+
+#. module: logistic_reports
+#: model:ir.model,name:logistic_reports.model_logistic_travel
+msgid "travel"
+msgstr ""
+
+#. module: logistic_reports
+#: view:logistic.waybill:logistic_reports.view_logistic_waybill_report_graph
+msgid "waybill"
+msgstr ""
+
diff --git a/logistic_reports/view/report_menu_item.xml b/logistic_reports/view/report_menu_item.xml
index 48c76f7..b227a82 100644
--- a/logistic_reports/view/report_menu_item.xml
+++ b/logistic_reports/view/report_menu_item.xml
@@ -32,8 +32,8 @@
Summary
logistic.waybill
form
-
tree,form
-
+
graph
+
-
diff --git a/logistic_reports/view/waybill_view.xml b/logistic_reports/view/waybill_view.xml
index 6146b6b..859981b 100644
--- a/logistic_reports/view/waybill_view.xml
+++ b/logistic_reports/view/waybill_view.xml
@@ -6,24 +6,24 @@
logistic.waybill.form
logistic.waybill
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
@@ -36,7 +36,7 @@
-
+
+
+
+ logistic_report.waybill.graph
+ logistic.waybill
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logistic_reports/waybill.py b/logistic_reports/waybill.py
index e8d7d5e..efcce9a 100644
--- a/logistic_reports/waybill.py
+++ b/logistic_reports/waybill.py
@@ -28,7 +28,6 @@ def _get_days_range(self):
@api.one
@api.depends(
- 'state',
'travel_ids',
'travel_ids.price',
'waybill_expense_ids',
@@ -41,8 +40,8 @@ def _get_total(self):
for travel in self.travel_ids:
total_price = total_price + travel.price
if self.waybill_expense_ids:
- for travel in self.waybill_expense_ids:
- total_cost = total_cost + travel.price_subtotal
+ for expense in self.waybill_expense_ids:
+ total_cost = total_cost + expense.price_subtotal
net = total_price - total_cost
net_avg = 0
if total_cost != 0:
@@ -55,14 +54,9 @@ def _get_total(self):
@api.one
@api.depends(
- 'state',
'distance',
'total_price',
- 'total_cost',
- 'travel_ids',
- 'travel_ids.price',
- 'waybill_expense_ids',
- 'waybill_expense_ids.price_subtotal')
+ 'total_cost')
def _get_price_cost_km(self):
if self.distance != 0:
self.price_km = self.total_price / self.distance
@@ -73,27 +67,48 @@ def _get_price_cost_km(self):
self.cost_km = 0
self.net_km = 0
- days_range = fields.Integer(compute='_get_days_range', string='Days Range')
+ days_range = fields.Integer(
+ compute='_get_days_range',
+ string='Days Range'
+ )
total_price = fields.Float(
- compute='_get_total', string='Total Price',
- multi="total", store=True)
-
+ compute='_get_total',
+ string='Total Price',
+ store=True)
+ conumption = fields.Float(
+ group_operator="avg"
+ )
total_cost = fields.Float(
- compute='_get_total', string='Total Cost',
- multi="total", store=True)
+ compute='_get_total',
+ string='Total Cost',
+ store=True
+ )
net = fields.Float(
- compute='_get_total', string='Net', multi="total", store=True)
+ compute='_get_total',
+ string='Net',
+ store=True
+ )
net_avg = fields.Float(
compute='_get_total',
- string='Net %', multi="total", store=True, group_operator="avg")
+ string='Net %',
+ store=True,
+ group_operator="avg"
+ )
price_km = fields.Float(
- compute='_get_price_cost_km', string='Price per km',
- multi="total_km", store=True, group_operator="avg")
+ compute='_get_price_cost_km',
+ string='Price per km',
+ store=True,
+ group_operator="avg"
+ )
cost_km = fields.Float(
compute='_get_price_cost_km',
tring='Cost per km',
- multi="total_km", store=True, group_operator="avg")
+ store=True,
+ group_operator="avg"
+ )
net_km = fields.Float(
compute='_get_price_cost_km',
string='Net per km',
- multi="total_km", store=True, group_operator="avg")
+ store=True,
+ group_operator="avg"
+ )
diff --git a/logistic_x/__init__.py b/logistic_x/__init__.py
deleted file mode 100644
index 4144bf2..0000000
--- a/logistic_x/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-import waybill
-import wizard
-import travel
-import vehicle
-import requirement
-import res_partner
-import waybill_expense
-import account_invoice
-
diff --git a/logistic_x/__openerp__.py b/logistic_x/__openerp__.py
deleted file mode 100644
index 2c719cf..0000000
--- a/logistic_x/__openerp__.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar)
-# All Rights Reserved.
-#
-# 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 details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-{'active': False,
- 'author': 'ADHOC SA',
- 'category': 'base.module_category_knowledge_management',
- 'demo_xml': [
- 'data/demo/res.partner.csv',
- 'data/demo/logistic.location.csv',
- 'data/demo/product.product.csv',
- 'data/demo/fleet.vehicle.csv',
- 'data/demo/logistic.waybill.csv',
- 'data/demo/logistic.travel.csv',
- # 'data/demo/product.supplierinfo.csv',
- 'data/demo/documents/logistic.requirement.csv',
- 'data/demo/maintenances/logistic.requirement.csv',
- 'data/demo/logistic.requirement.xml',
- ],
- 'depends': ['logistic'],
- 'description': """
-Logistic Modifications
-""",
- 'init_xml': [],
- 'installable': True,
- 'license': 'AGPL-3',
- 'name': 'Logistic Modifications',
- 'test': [],
- 'update_xml': [
- # 'wizard/travel_sale_order.xml',
- 'wizard/travel_make_invoice.xml',
- 'wizard/expense_make_invoice.xml',
- 'view/partner_view.xml',
- 'view/waybill_view.xml',
- 'view/product_view.xml',
- 'view/travel_view.xml',
- 'view/waybill_expense_view.xml',
- 'view/fleet_view.xml',
- 'view/requirement_view.xml',
- 'view/purchase_order.xml',
- 'view/waybill_driver_payment_view.xml',
- 'data/waybill_sequence.xml',
- 'data/cron.xml',
- 'workflow/waybill_workflow.xml',
- 'workflow/requirement_workflow.xml',
- 'security/logistic_group.xml',
- 'security/ir.model.access.csv',
- ],
- 'version': 'No version',
- 'css': [
- 'static/src/css/logistic.css',
- ],
- 'website': 'www.adhoc.com.ar'}
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/logistic_x/i18n/es_AR.po b/logistic_x/i18n/es_AR.po
deleted file mode 100644
index 1213dbb..0000000
--- a/logistic_x/i18n/es_AR.po
+++ /dev/null
@@ -1,515 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * logistic_x
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-05-04 16:03+0000\n"
-"PO-Revision-Date: 2015-05-04 13:04-0300\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: \n"
-"X-Generator: Poedit 1.5.4\n"
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.travel:0 view:logistic.waybill:0
-#: view:logistic.waybill_expense:0
-msgid "Group By..."
-msgstr "Agrupar Por..."
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.waybill:0
-msgid "Vehicle"
-msgstr "Vehículo"
-
-#. module: logistic_x
-#: view:logistic.waybill_expense:0
-msgid "Supplier"
-msgstr "Proveedor"
-
-#. module: logistic_x
-#: model:ir.actions.act_window,name:logistic_x.action_expense_make_invoice
-#: model:ir.actions.act_window,name:logistic_x.action_travel_make_invoice
-msgid "Make Invoices"
-msgstr "Realizar facturas"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill_expense:0
-msgid "To Invoice"
-msgstr "A Facturar"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Final"
-msgstr "Final"
-
-#. module: logistic_x
-#: field:logistic.expense.make.invoice,invoice_date:0
-#: field:logistic.travel.make.invoice,invoice_date:0
-msgid "Invoice Date"
-msgstr "Fecha de Factura"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "base.group_no_one"
-msgstr "base.group_no_one"
-
-#. module: logistic_x
-#: field:fleet.vehicle,length:0
-msgid "Length (mts)"
-msgstr "Largo (mts)"
-
-#. module: logistic_x
-#: view:product.product:0
-msgid "Others"
-msgstr "Otros"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Services"
-msgstr "Servicios"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_expense_make_invoice
-msgid "Expense Make Invoice"
-msgstr "Facturar Gasto"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Wagon"
-msgstr "Furgón"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Initial"
-msgstr "Inicial"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Notes"
-msgstr "Notas"
-
-#. module: logistic_x
-#: field:fleet.vehicle,requirement_state:0
-#: field:res.partner,requirement_state:0
-msgid "Requirements State"
-msgstr "Estado de Requerimientos"
-
-#. module: logistic_x
-#: field:logistic.requirement,purchase_order_id:0
-msgid "Purchase Order"
-msgstr "Orden de Compra"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill:0 view:product.product:0
-msgid "Travels"
-msgstr "Viajes"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Fuel Logs"
-msgstr "Registros de combustible"
-
-#. module: logistic_x
-#: view:logistic.travel:0 field:logistic.travel,tractor_id:0
-msgid "Tractor"
-msgstr "Tractor"
-
-#. module: logistic_x
-#: field:logistic.waybill,tractor_status:0
-msgid "Tractor Status"
-msgstr "Estado del Tractor"
-
-#. module: logistic_x
-#: selection:fleet.vehicle,requirement_state:0
-#: selection:res.partner,requirement_state:0
-msgid "OK"
-msgstr "OK"
-
-#. module: logistic_x
-#: view:logistic.expense.make.invoice:0 view:logistic.travel.make.invoice:0
-msgid "Create Invoices"
-msgstr "Crear Facturas"
-
-#. module: logistic_x
-#: view:logistic.travel:0
-msgid "From Location"
-msgstr "Desde Ubicación"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_res_partner view:logistic.travel:0
-msgid "Partner"
-msgstr "Empresa"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_requirement
-msgid "requirement"
-msgstr "requerimiento"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0 field:fleet.vehicle,document_ids:0
-#: view:product.product:0 field:res.partner,document_ids:0
-msgid "Documents"
-msgstr "Documentos"
-
-#. module: logistic_x
-#: field:logistic.waybill,driver_status:0
-msgid "Driver Status"
-msgstr "Estado del Conductor"
-
-#. module: logistic_x
-#: view:logistic.requirement:0
-msgid "State"
-msgstr "Estado"
-
-#. module: logistic_x
-#: field:logistic.requirement,invoice_line_ids:0
-msgid "Invoice Lines"
-msgstr "Líneas de Factura"
-
-#. module: logistic_x
-#: field:logistic.waybill,consumption_copy:0
-msgid "Consumption (l/km)"
-msgstr "Consumo (l/km)"
-
-#. module: logistic_x
-#: help:logistic.travel.make.invoice,grouped:0
-msgid "Check the box to group the invoices for the same customers"
-msgstr "Marque la casilla para agrupar facturas para el mismo cliente"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill_expense:0
-msgid "Waybill"
-msgstr "Hoja de Ruta"
-
-#. module: logistic_x
-#: field:account.invoice,available_journal_ids:0
-msgid "Available Journals"
-msgstr "Available Journals"
-
-#. module: logistic_x
-#: selection:fleet.vehicle,requirement_state:0
-#: selection:res.partner,requirement_state:0
-msgid "Next To Renew"
-msgstr "Próximo a Renovarse"
-
-#. module: logistic_x
-#: field:logistic.waybill,final_odometer_id:0
-#: field:logistic.waybill,wagon_final_odometer:0
-#: field:logistic.waybill,wagon_final_odometer_id:0
-msgid "Final Odometer"
-msgstr "Odómetro Final"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Engine Options"
-msgstr "Opciones del motor"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_waybill
-#: view:logistic.waybill:0
-msgid "waybill"
-msgstr "hoja de ruta"
-
-#. module: logistic_x
-#: view:logistic.travel:0
-msgid "True"
-msgstr "True"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Payment And Cost"
-msgstr "Costo y Pago"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Date To"
-msgstr "Fecha hasta"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Número de Chasis"
-msgstr "Número de Chasis"
-
-#. module: logistic_x
-#: field:logistic.expense.make.invoice,grouped:0
-#: field:logistic.travel.make.invoice,grouped:0
-msgid "Group the invoices"
-msgstr "Agrupar las Facturas"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Notes......"
-msgstr "Notas......"
-
-#. module: logistic_x
-#: field:logistic.travel,ordered:0
-msgid "Ordered?"
-msgstr "Ordenado?"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0 field:fleet.vehicle,maintenance_ids:0
-#: view:product.product:0
-msgid "Maintenances"
-msgstr "Mantenimientos"
-
-#. module: logistic_x
-#: view:logistic.waybill_expense:0
-msgid "Invoice Line"
-msgstr "Línea de Factura"
-
-#. module: logistic_x
-#: view:logistic.expense.make.invoice:0 view:logistic.travel.make.invoice:0
-msgid "or"
-msgstr "o"
-
-#. module: logistic_x
-#: view:logistic.expense.make.invoice:0 view:logistic.travel.make.invoice:0
-msgid "Create invoices"
-msgstr "Crear Facturas"
-
-#. module: logistic_x
-#: field:fleet.vehicle,capacity:0
-msgid "Capacity (pallets)"
-msgstr "Capacidad (pallets)"
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.travel:0 view:logistic.waybill:0
-#: view:logistic.waybill_expense:0
-msgid "By Attribute"
-msgstr "Por Atributo"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Date From"
-msgstr "Fecha desde"
-
-#. module: logistic_x
-#: model:ir.ui.menu,name:logistic_x.fleet_vehicle_state_menu
-msgid "Vehicle Status"
-msgstr "Estado del vehículo"
-
-#. module: logistic_x
-#: view:logistic.travel:0
-msgid "base.group_sale_salesman,account.group_account_invoice"
-msgstr "base.group_sale_salesman,account.group_account_invoice"
-
-#. module: logistic_x
-#: help:logistic.requirement,initial_odometer_id:0
-#: help:logistic.waybill,final_odometer_id:0
-#: help:logistic.waybill,initial_odometer_id:0
-#: help:logistic.waybill,wagon_final_odometer_id:0
-#: help:logistic.waybill,wagon_initial_odometer_id:0
-msgid "Odometer measure of the vehicle at the moment of this log"
-msgstr "Medida del Odómetro del vehíuclo en el momento de este registro"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Contracts"
-msgstr "Contratos"
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.travel:0
-#: field:logistic.travel,driver_id:0 view:logistic.waybill:0
-msgid "Driver"
-msgstr "Conductor"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill:0
-#: view:logistic.waybill_expense:0 field:logistic.waybill_expense,date:0
-msgid "Date"
-msgstr "Fecha"
-
-#. module: logistic_x
-#: model:ir.ui.menu,name:logistic_x.fleet_vehicle_model_menu
-msgid "Vehicle Model"
-msgstr "Modelo del vehículo"
-
-#. module: logistic_x
-#: field:logistic.travel.make.invoice,grouped_line:0
-msgid "Group the Invoice Lines"
-msgstr "Group the Invoice Lines"
-
-#. module: logistic_x
-#: field:logistic.waybill,driver_total:0
-msgid "Driver Total"
-msgstr "Conductor Total"
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.waybill:0
-msgid "Active"
-msgstr "Activo"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_travel_make_invoice
-msgid "Travel Make Invoice"
-msgstr "Facturar Viaje"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_account_invoice
-#: field:logistic.travel,invoice_id:0
-msgid "Invoice"
-msgstr "Factura"
-
-#. module: logistic_x
-#: view:logistic.expense.make.invoice:0 view:logistic.travel.make.invoice:0
-msgid "Cancel"
-msgstr "Cancelar"
-
-#. module: logistic_x
-#: help:logistic.expense.make.invoice,grouped:0
-msgid "Check the box to group the invoices for the same suppliers"
-msgstr ""
-"Marque la casilla para agrupar las facturas para los mismos proveedores"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "General Properties"
-msgstr "Propiedades generales"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Information"
-msgstr "Información"
-
-#. module: logistic_x
-#: field:logistic.requirement,initial_odometer_id:0
-#: field:logistic.waybill,initial_odometer_id:0
-#: field:logistic.waybill,wagon_initial_odometer:0
-#: field:logistic.waybill,wagon_initial_odometer_id:0
-msgid "Initial Odometer"
-msgstr "Odómetro Inicial"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill_expense:0
-msgid "false"
-msgstr "falso"
-
-#. module: logistic_x
-#: field:logistic.waybill,wagon_status:0
-msgid "Wagon Status"
-msgstr "Estado del Furgón"
-
-#. module: logistic_x
-#: model:ir.ui.menu,name:logistic_x.fleet_vehicle_model_brand_menu
-msgid "Model brand of Vehicle"
-msgstr "Modelo del vehículo"
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill:0
-msgid "Create Invoice"
-msgstr "Crear Factura"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Fuel"
-msgstr "Combustible"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Additional Properties"
-msgstr "Propiedades adicionales"
-
-#. module: logistic_x
-#: view:logistic.requirement:0 view:logistic.travel:0
-#: view:logistic.waybill_expense:0
-msgid "Product"
-msgstr "Producto"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_waybill_expense
-msgid "waybill_expense"
-msgstr "waybill_expense"
-
-#. module: logistic_x
-#: field:res.partner,parent_name:0
-msgid "Parent name"
-msgstr "Parent name"
-
-#. module: logistic_x
-#: view:logistic.expense.make.invoice:0 view:logistic.travel.make.invoice:0
-msgid "Do you really want to create the invoice(s)?"
-msgstr "Quiere realmente crear la(s) factura(s)?"
-
-#. module: logistic_x
-#: view:logistic.travel:0
-msgid "To Location"
-msgstr "A Ubicación"
-
-#. module: logistic_x
-#: view:logistic.requirement:0
-msgid "Name"
-msgstr "Nombre"
-
-#. module: logistic_x
-#: field:fleet.vehicle,width:0
-msgid "Width (mts)"
-msgstr "Ancho (mts)"
-
-#. module: logistic_x
-#: model:ir.actions.act_window,name:logistic_x.action_logistic_waybill_expense_expenses_to_invoice_by_product
-msgid "Expenses to Invoice By Products"
-msgstr "Gastos a Facturar por Producto"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Waybill "
-msgstr "Hoja de Ruta"
-
-#. module: logistic_x
-#: view:logistic.requirement:0
-msgid ""
-"grey:state in ('cancelled','renewed');green:state in ('ok');violet:state in "
-"('next_to_renew',); red:state in ('need_renew'); black:"
-"state=='renewal_requested'"
-msgstr ""
-"grey:state in ('cancelled','renewed');green:state in ('ok');violet:state in "
-"('next_to_renew',); red:state in ('need_renew'); black:"
-"state=='renewal_requested'"
-
-#. module: logistic_x
-#: view:fleet.vehicle:0
-msgid "Costs"
-msgstr "Costes"
-
-#. module: logistic_x
-#: selection:fleet.vehicle,requirement_state:0
-#: selection:res.partner,requirement_state:0
-msgid "Need Renew"
-msgstr "Necesita Renovación"
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_fleet_vehicle
-msgid "Information on a vehicle"
-msgstr "Información en un vehículo"
-
-#. module: logistic_x
-#: model:ir.ui.menu,name:logistic_x.menu_expenses_to_invoice_by_product
-msgid "Expenses to Invoice By Product"
-msgstr "Gastos a Facturar por Producto"
-
-#. module: logistic_x
-#: view:logistic.waybill:0
-msgid "Reference..."
-msgstr "Referencia..."
-
-#. module: logistic_x
-#: view:logistic.travel:0 view:logistic.waybill:0
-#: view:logistic.waybill_driver_payment:0 view:logistic.waybill_expense:0
-msgid "Total"
-msgstr "Total"
-
-#. module: logistic_x
-#: constraint:logistic.travel:0
-msgid "Error! From date must be lower then to date."
-msgstr "Error! From date must be lower then to date."
-
-#. module: logistic_x
-#: model:ir.model,name:logistic_x.model_logistic_travel
-msgid "travel"
-msgstr "viaje"
diff --git a/logistic_x/report/README b/logistic_x/report/README
deleted file mode 100644
index e69de29..0000000
diff --git a/logistic_x/report/__init__.py b/logistic_x/report/__init__.py
deleted file mode 100644
index 40a96af..0000000
--- a/logistic_x/report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# -*- coding: utf-8 -*-
diff --git a/logistic_x/requirement.py b/logistic_x/requirement.py
deleted file mode 100644
index dfa7d98..0000000
--- a/logistic_x/requirement.py
+++ /dev/null
@@ -1,430 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-from openerp import netsvc
-from openerp import models, fields, api
-from openerp.exceptions import Warning
-# from datetime import datetime
-import datetime
-from dateutil.relativedelta import relativedelta
-from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
-import time
-
-
-class requirement(models.Model):
-
- """"""
-
- _inherit = 'logistic.requirement'
-
- def _get_initial_odometer(self, cr, uid, ids, initial_odometer_id, arg, context):
- res = dict.fromkeys(ids, False)
- for record in self.browse(cr, uid, ids, context=context):
- if record.initial_odometer_id:
- res[record.id] = record.initial_odometer_id.value
- return res
-
- def _set_initial_odometer(self, cr, uid, id, name, value, args=None, context=None):
- if not value:
- # raise except_orm(_('Operation not allowed!'), _('Emptying the odometer value of a vehicle is not allowed.'))
- return True
- date = self.browse(cr, uid, id, context=context).date
- if not(date):
- date = fields.date.context_today(self, cr, uid, context=context)
- vehicle_id = self.browse(cr, uid, id, context=context).vehicle_id
- data = {'value': value, 'date': date, 'vehicle_id': vehicle_id.id}
- odometer_id = self.pool.get('fleet.vehicle.odometer').create(
- cr, uid, data, context=context)
- return self.write(cr, uid, id, {'initial_odometer_id': odometer_id}, context=context)
-
- @api.one
- def get_remainings(self, name, args):
- # for record in self.browse(cr, uid, ids, context=context):
- self.remaining_range = False
- self.remaining_days = False
- if self.type == 'maintenance':
- if self.initial_odometer and self.vehicle_id.odometer and self.odometer_range:
- self.remaining_range = self.initial_odometer + \
- self.odometer_range - self.vehicle_id.odometer
- elif self.expiration_date:
- today = datetime.datetime.today()
- expiration_date = datetime.datetime.strptime(
- self.expiration_date, DEFAULT_SERVER_DATE_FORMAT)
- remaining_days = (expiration_date - today).days
- self.remaining_days = remaining_days
-
- def get_renews_id(self, cr, uid, ids, name, args, context=None):
- res = {}
- for record_id in ids:
- renews_ids = self.search(
- cr, uid, [('renewed_by_id', '=', record_id)], context=context)
- print 'renews_ids', renews_ids
- if renews_ids:
- res[record_id] = renews_ids[0]
- else:
- res[record_id] = False
- return res
-
- initial_odometer_id = fields.Many2one(
- 'fleet.vehicle.odometer',
- 'Initial Odometer',
- help='Odometer measure of the vehicle at the moment of this log')
- initial_odometer = fields.Float(
- fnct_inv=_set_initial_odometer,
- string='Initial Odometer', compute='_get_initial_odometer')
- remaining_range = fields.Integer(
- string='Remaining Range',
- compute='get_remainings', multi='get_remainings')
- remaining_days = fields.Integer(
- string='Remaining Days',
- compute='get_remainings', multi='get_remainings')
- renews_id = fields.Many2one(
- 'logistic.requirement', string='Renews', compute='get_renews_id')
- po_line_id = fields.Many2one(
- 'purchase.order.line', string='Purchase Order Line', readonly=True)
- invoice_line_ids = fields.Many2many(
- 'account.invoice.line',
- related='po_line_id.invoice_lines',
- string='Invoice Lines', readonly=True)
- purchase_order_id = fields.Many2one(
- 'purchase.order',
- related='po_line_id.order_id', string='Purchase Order', readonly=True)
-
- @api.one
- def unlink(self):
- for t in self.read(['state']):
- if t['state'] not in ('draft', 'cancelled'):
- raise Warning(_('Invalid Action!'), _(
- 'Cannot delete requirement(s) which are not in draft or cancelled state.'))
- return super(requirement, self).unlink()
-
- def action_cancel(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- for record in self.browse(cr, uid, ids, context=context):
- if record.renewed_by_id:
- raise Warning(
- _('Invalid Action!'),
- _('Cannot cancel requirements that has a renewed by requirement! You must first delete the related renewed by requirement.'))
- return True
-
- def verify_requirement_state(self, cr, uid, ids=None, context=None):
- if context is None:
- context = {}
- date = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
- wf_service = netsvc.LocalService("workflow")
- # Next to renew requirements
- ok_requirement_ids = self.search(
- cr, uid, [('state', 'in', ['ok', 'need_renew'])], context=context)
- for record in self.browse(cr, uid, ok_requirement_ids, context):
- if (record.type == 'document' and record.remaining_days <= record.warning_days) or (record.type == 'maintenance' and record.remaining_range <= record.warning_range):
- wf_service.trg_validate(
- uid, 'logistic.requirement', record.id, 'sgn_next_to_renew', cr)
-
- # need renew requirements
- need_renew_ids = self.search(cr, uid, [('state', 'in', ['ok', 'next_to_renew']), (
- 'expiration_date', '<=', date), ('type', '=', 'document')], context=context)
-
- # No peudo agregar esta parte en el search porque remianing_range es un
- # function sin search
- maintenance_ids = self.search(cr, uid, [('state', 'in', [
- 'ok', 'next_to_renew']), ('type', '=', 'maintenance')], context=context)
- for record in self.browse(cr, uid, maintenance_ids, context):
- if (record.type == 'maintenance' and record.remaining_range <= 0) or (record.type == 'document' and record.remaining_days <= 0):
- need_renew_ids.append(record.id)
- for record_id in need_renew_ids:
- wf_service.trg_validate(
- uid, 'logistic.requirement', record_id, 'sgn_need_renew', cr)
-
- return True
-
- def on_change_product(self, cr, uid, ids, product_id, issue_date, context=None):
- v = {}
- if product_id:
- product = self.pool['product.product'].browse(
- cr, uid, product_id, context=context)
- if product.service_subtype == 'maintenance':
- v = {
- 'odometer_range': product.default_range,
- 'warning_range': product.default_warning_range,
- 'name': product.name,
- }
- elif product.service_subtype == 'document':
- if issue_date and product.default_validity_days:
- expiration_date = (datetime.datetime.strptime(
- issue_date, '%Y-%m-%d') + relativedelta(days=product.default_validity_days)).strftime('%Y-%m-%d')
- v = {
- 'expiration_date': expiration_date,
- 'warning_days': product.default_warning_days,
- 'name': product.name,
- }
- else:
- v = {
- 'expiration_date': False,
- 'warning_days': False,
- 'name': False,
- }
- return {'value': v}
-
- def on_change_vehicle(self, cr, uid, ids, vehicle_id, context=None):
- v = {
- 'initial_odometer': False,
- }
- if vehicle_id:
- vehicle = self.pool['fleet.vehicle'].browse(
- cr, uid, vehicle_id, context=context)
- if vehicle.odometer:
- v = {
- 'initial_odometer': vehicle.odometer,
- }
- return {'value': v}
-
- def make_new_requirement(self, cr, uid, ids, po_line_dic, context=None):
- res = {}
- for requirement in self.browse(cr, uid, ids, context=context):
- if requirement.vehicle_id:
- initial_odometer = requirement.vehicle_id.odometer
- else:
- initial_odometer = False
- if requirement.expiration_date:
- expiration_date = (datetime.datetime.strptime(requirement.expiration_date, '%Y-%m-%d') +
- relativedelta(days=requirement.product_id.default_validity_days)).strftime('%Y-%m-%d')
- vals = {
- 'type': requirement.type,
- 'vehicle_id': requirement.vehicle_id.id,
- 'partner_id': requirement.partner_id.id,
- 'name': requirement.name,
- 'product_id': requirement.product_id.id,
- 'initial_odometer': initial_odometer,
- 'odometer_range': requirement.product_id.default_range,
- 'warning_range': requirement.product_id.default_warning_range,
- 'odometer_unit': requirement.product_id.range_unit,
- 'odometer_unit': requirement.product_id.range_unit,
- 'issue_date': requirement.expiration_date,
- 'expiration_date': requirement.expiration_date,
- 'warning_days': requirement.product_id.default_warning_days,
- 'note': requirement.note,
- 'po_line_id': po_line_dic.get(requirement.id, False),
- }
- new_requirement_id = self.create(cr, uid, vals, context=context)
- res[requirement.id] = new_requirement_id
- self.write(cr, uid, [requirement.id], {
- 'renewed_by_id': new_requirement_id}, context=context)
- return res
-
- def request_renew(self, cr, uid, ids, context=None):
- po_line_dic = self.make_po(cr, uid, ids, context=context)
- self.make_new_requirement(cr, uid, ids, po_line_dic, context=context)
- return True
-
- def set_ok(self, cr, uid, ids, context=None):
- for requirement in self.browse(cr, uid, ids, context=context):
- if requirement.renews_id:
- self.write
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(
- uid, 'logistic.requirement', requirement.renews_id.id, 'sgn_renewed', cr)
-
- def check_supplier_info(self, cr, uid, ids, context=None):
- partner_obj = self.pool.get('res.partner')
- user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
- for requirement in self.browse(cr, uid, ids, context=context):
- message = ''
- # Taken Main Supplier of Product of requirement.
- partner = requirement.product_id.seller_id
-
- if not requirement.product_id.seller_ids:
- raise Warning(
- _('Error!'), _('No supplier defined for this product !'))
- elif not partner:
- raise Warning(
- _('Error!'), _('No default supplier defined for this product'))
- elif not partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']:
- raise Warning(
- _('Error!'), _('No address defined for the supplier'))
-
- if message:
- if requirement.message != message:
- cr.execute(
- 'update requirement_order set message=%s where id=%s', (message, requirement.id))
- return False
-
- if user.company_id and user.company_id.partner_id:
- if partner.id == user.company_id.partner_id.id:
- raise Warning(_('Configuration Error!'), _(
- 'The product "%s" has been defined with your company as reseller which seems to be a configuration error!' % requirement.product_id.name))
-
- return True
-
- def _get_purchase_schedule_date(self, cr, uid, requirement, company, context=None):
- """Return the datetime value to use as Schedule Date (``date_planned``) for the
- Purchase Order Lines created to satisfy the given requirement.
-
- :param browse_record requirement: the requirement for which a PO will be created.
- :param browse_report company: the company to which the new PO will belong to.
- :rtype: datetime
- :return: the desired Schedule Date for the PO lines
- """
- requirement_date_planned = datetime.datetime.strptime(
- time.strftime(DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT)
- # requirement_date_planned = datetime.strptime(requirement.date_planned, DEFAULT_SERVER_DATETIME_FORMAT)
- schedule_date = (
- requirement_date_planned - relativedelta(days=company.po_lead))
- return schedule_date
-
- def _get_purchase_order_date(self, cr, uid, requirement, company, schedule_date, context=None):
- """Return the datetime value to use as Order Date (``date_order``) for the
- Purchase Order created to satisfy the given requirement.
-
- :param browse_record requirement: the requirement for which a PO will be created.
- :param browse_report company: the company to which the new PO will belong to.
- :param datetime schedule_date: desired Scheduled Date for the Purchase Order lines.
- :rtype: datetime
- :return: the desired Order Date for the PO
- """
- seller_delay = int(requirement.product_id.seller_delay)
- return schedule_date - relativedelta(days=seller_delay)
-
- def make_po(self, cr, uid, ids, context=None):
- """ Make purchase order from requirement
- @return: New created Purchase Orders requirement wise
- """
- self.check_supplier_info(cr, uid, ids, context=context)
- res = {}
- if context is None:
- context = {}
- company = self.pool.get('res.users').browse(
- cr, uid, uid, context=context).company_id
- partner_obj = self.pool.get('res.partner')
- uom_obj = self.pool.get('product.uom')
- pricelist_obj = self.pool.get('product.pricelist')
- prod_obj = self.pool.get('product.product')
- acc_pos_obj = self.pool.get('account.fiscal.position')
- seq_obj = self.pool.get('ir.sequence')
- warehouse_ids = self.pool['stock.warehouse'].search(
- cr, uid, [], context=context)
- if warehouse_ids:
- warehouse = self.pool['stock.warehouse'].browse(
- cr, uid, warehouse_ids[0], context=context)
- for requirement in self.browse(cr, uid, ids, context=context):
- # Taken Main Supplier of Product of requirement.
- partner = requirement.product_id.seller_id
- seller_qty = requirement.product_id.seller_qty
- partner_id = partner.id
- address_id = partner_obj.address_get(
- cr, uid, [partner_id], ['delivery'])['delivery']
- pricelist_id = partner.property_product_pricelist_purchase.id
- uom_id = requirement.product_id.uom_po_id.id
-
- qty = 1
- if seller_qty:
- qty = max(qty, seller_qty)
-
- price = pricelist_obj.price_get(cr, uid, [
- pricelist_id], requirement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id]
-
- schedule_date = self._get_purchase_schedule_date(
- cr, uid, requirement, company, context=context)
- purchase_date = self._get_purchase_order_date(
- cr, uid, requirement, company, schedule_date, context=context)
-
- # Passing partner_id to context for purchase order line integrity
- # of Line name
- new_context = context.copy()
- new_context.update(
- {'lang': partner.lang, 'partner_id': partner_id})
-
- product = prod_obj.browse(
- cr, uid, requirement.product_id.id, context=new_context)
- taxes_ids = requirement.product_id.supplier_taxes_id
- taxes = acc_pos_obj.map_tax(
- cr, uid, partner.property_account_position, taxes_ids)
-
- name = seq_obj.get(cr, uid, 'purchase.order') or _(
- 'PO: %s') % requirement.name
- if requirement.vehicle_id:
- origin = requirement.vehicle_id.name
- elif requirement.partner_id:
- origin = requirement.partner_id.name
- else:
- origin = ''
- po_vals = {
- 'name': name,
- 'origin': origin + ' - ' + requirement.name,
- 'partner_id': partner_id,
- 'location_id': warehouse.lot_input_id.id,
- 'warehouse_id': warehouse.id,
- 'pricelist_id': pricelist_id,
- 'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
- 'company_id': company.id,
- 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
- 'payment_term_id': partner.property_supplier_payment_term.id or False,
- }
- po_id = self.pool.get('purchase.order').create(
- cr, uid, po_vals, context=context)
- name = product.partner_ref
- if product.description_purchase:
- name += '\n' + product.description_purchase
- line_vals = {
- 'name': name,
- 'product_qty': qty,
- 'product_id': requirement.product_id.id,
- 'product_uom': uom_id,
- 'price_unit': price or 0.0,
- 'date_planned': schedule_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
- 'order_id': po_id,
- 'taxes_id': [(6, 0, taxes)],
- }
- po_line_id = self.pool.get('purchase.order.line').create(
- cr, uid, line_vals, context=context)
-
- # self.write(cr, uid, [requirement.id], {'po_line_id': po_line_id}, context=context)
- res[requirement.id] = po_line_id
- return res
- # return True
-
-
-# This methods works and creates a requirement order than later will be a purchase order. The problem is that we want the requirement to have a m2o to the pruchase order line in order to have the price history
- # def _prepare_order_line_requirement(self, cr, uid, requirement, context=None):
- # date_planned = datetime.strptime(time.strftime(DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT)
- # location_ids = self.pool['stock.warehouse'].search(cr, uid, [], context=context)
- # company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
- # if location_ids:
- # default_location_id = location_ids[0]
- # else:
- # print 'error'
- # if requirement.vehicle_id:
- # name = requirement.vehicle_id.name
- # elif requirement.partner_id:
- # name = requirement.partner_id.name
- # else:
- # name = ''
- # return {
- # 'name': requirement.name,
- # 'origin': name + ' - ' + requirement.name,
- # 'date_planned': date_planned,
- # 'product_id': requirement.product_id.id,
- # 'product_qty': 1,
- # 'product_uom': requirement.product_id.uom_id.id,
- # 'product_uos_qty': 1,
- # 'product_uos': requirement.product_id.uom_id.id,
- # 'location_id': default_location_id,
- # 'procure_method': 'make_to_order',
- # 'move_id': move_id,
- # 'company_id': company.id,
- # 'note': line.name,
- # }
-
- # def make_purchase_order(self, cr, uid, ids, context=None):
- # requirement_obj = self.pool.get('requirement.order')
- # requirement_ids = []
- # for requirement in self.browse(cr, uid, ids, context=context):
- # requirement_id = requirement_obj.create(cr, uid, self._prepare_order_line_requirement(cr, uid, requirement, context=context))
- # requirement_ids.append(requirement_id)
- # wf_service = netsvc.LocalService("workflow")
- # wf_service.trg_validate(uid, 'requirement.order', requirement_id, 'button_confirm', cr)
- # return requirement_ids
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/logistic_x/security/README b/logistic_x/security/README
deleted file mode 100644
index e69de29..0000000
diff --git a/logistic_x/security/ir.model.access.csv b/logistic_x/security/ir.model.access.csv
deleted file mode 100644
index a80ec8c..0000000
--- a/logistic_x/security/ir.model.access.csv
+++ /dev/null
@@ -1,53 +0,0 @@
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-logistic.access_fleet_vehicle_manager,fleet.vehicle.manager,logistic.model_fleet_vehicle,logistic.group_manager,1,1,1,1
-logistic.access_fleet_vehicle_user,fleet.vehicle.user,logistic.model_fleet_vehicle,logistic.group_user,1,1,0,0
-logistic.access_fleet_vehicle_view,fleet.vehicle.view,logistic.model_fleet_vehicle,logistic.group_view,1,0,0,0
-logistic.access_logistic_location_manager,logistic.location.manager,logistic.model_logistic_location,logistic.group_manager,1,1,1,1
-logistic.access_logistic_location_user,logistic.location.user,logistic.model_logistic_location,logistic.group_user,1,1,0,0
-logistic.access_logistic_location_view,logistic.location.view,logistic.model_logistic_location,logistic.group_view,1,0,0,0
-logistic.access_logistic_requirement_manager,logistic.requirement.manager,logistic.model_logistic_requirement,logistic.group_manager,1,1,1,1
-logistic.access_logistic_requirement_user,logistic.requirement.user,logistic.model_logistic_requirement,logistic.group_user,1,1,0,0
-logistic.access_logistic_requirement_view,logistic.requirement.view,logistic.model_logistic_requirement,logistic.group_view,1,0,0,0
-logistic.access_logistic_travel_manager,logistic.travel.manager,logistic.model_logistic_travel,logistic.group_manager,1,1,1,1
-logistic.access_logistic_travel_user,logistic.travel.user,logistic.model_logistic_travel,logistic.group_user,1,1,1,1
-logistic.access_logistic_travel_view,logistic.travel.view,logistic.model_logistic_travel,logistic.group_view,1,0,0,0
-logistic.access_logistic_waybill_manager,logistic.waybill.manager,logistic.model_logistic_waybill,logistic.group_manager,1,1,1,1
-logistic.access_logistic_waybill_user,logistic.waybill.user,logistic.model_logistic_waybill,logistic.group_user,1,1,1,1
-logistic.access_logistic_waybill_view,logistic.waybill.view,logistic.model_logistic_waybill,logistic.group_view,1,0,0,0
-logistic.access_logistic_waybill_driver_payment_manager,logistic.waybill_driver_payment.manager,logistic.model_logistic_waybill_driver_payment,logistic.group_manager,1,1,1,1
-logistic.access_logistic_waybill_driver_payment_user,logistic.waybill_driver_payment.user,logistic.model_logistic_waybill_driver_payment,logistic.group_user,1,1,1,1
-logistic.access_logistic_waybill_driver_payment_view,logistic.waybill_driver_payment.view,logistic.model_logistic_waybill_driver_payment,logistic.group_view,1,0,0,0
-logistic.access_logistic_waybill_expense_manager,logistic.waybill_expense.manager,logistic.model_logistic_waybill_expense,logistic.group_manager,1,1,1,1
-logistic.access_logistic_waybill_expense_user,logistic.waybill_expense.user,logistic.model_logistic_waybill_expense,logistic.group_user,1,1,1,1
-logistic.access_logistic_waybill_expense_view,logistic.waybill_expense.view,logistic.model_logistic_waybill_expense,logistic.group_view,1,0,0,0
-logistic.access_product_product_manager,product.product.manager,logistic.model_product_product,logistic.group_manager,1,1,1,1
-logistic.access_product_product_user,product.product.user,logistic.model_product_product,logistic.group_user,1,1,1,1
-logistic.access_product_product_view,product.product.view,logistic.model_product_product,logistic.group_view,1,0,0,0
-logistic.access_res_partner_manager,res.partner.manager,logistic.model_res_partner,logistic.group_manager,1,1,1,1
-logistic.access_res_partner_user,res.partner.user,logistic.model_res_partner,logistic.group_user,1,1,1,1
-logistic.access_res_partner_view,res.partner.view,logistic.model_res_partner,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_model_view,fleet_model_fleet_vehicle_model_view,fleet.model_fleet_vehicle_model,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_tag_view,fleet_model_fleet_vehicle_tag_view,fleet.model_fleet_vehicle_tag,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_state_view,fleet_model_fleet_vehicle_state_view,fleet.model_fleet_vehicle_state,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_fleet_model_brand_view,fleet_model_fleet_vehicle_fleet_model_brand_view,fleet.model_fleet_vehicle_model_brand,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_view,fleet_model_fleet_vehicle_view,fleet.model_fleet_vehicle,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_user,fleet_model_fleet_vehicle_user,fleet.model_fleet_vehicle,logistic.group_user,1,1,0,0
-fleet_model_fleet_vehicle_log_services_view,fleet_model_fleet_vehicle_log_services_view,fleet.model_fleet_vehicle_log_services,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_log_contract_view,fleet_model_fleet_vehicle_log_contract_view,fleet.model_fleet_vehicle_log_contract,logistic.group_view,1,0,0,0
-fleet_model_fleet_service_type_view,fleet_model_fleet_service_type_view,fleet.model_fleet_service_type,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_cost_view,fleet_model_fleet_vehicle_cost_view,fleet.model_fleet_vehicle_cost,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_cost_user,fleet_model_fleet_vehicle_cost_user,fleet.model_fleet_vehicle_cost,logistic.group_user,1,1,1,0
-fleet_model_fleet_contract_state_view,fleet_model_fleet_contract_state_view,fleet.model_fleet_contract_state,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_model_manager,fleet_model_fleet_vehicle_model_manager,fleet.model_fleet_vehicle_model,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_tag_manager,fleet_model_fleet_vehicle_tag_manager,fleet.model_fleet_vehicle_tag,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_state_manager,fleet_model_fleet_vehicle_state_manager,fleet.model_fleet_vehicle_state,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_odometer_user,fleet_model_fleet_vehicle_odometer_user,fleet.model_fleet_vehicle_odometer,logistic.group_user,1,1,1,1
-fleet_model_fleet_vehicle_fleet_model_brand_manager,fleet_model_fleet_vehicle_fleet_model_brand_manager,fleet.model_fleet_vehicle_model_brand,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_manager,fleet_model_fleet_vehicle_manager,fleet.model_fleet_vehicle,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_log_fuel_view,fleet_model_fleet_vehicle_log_fuel_view,fleet.model_fleet_vehicle_log_fuel,logistic.group_view,1,0,0,0
-fleet_model_fleet_vehicle_log_fuel_user,fleet_model_fleet_vehicle_log_fuel_user,fleet.model_fleet_vehicle_log_fuel,logistic.group_user,1,1,1,1
-fleet_model_fleet_vehicle_log_services_manager,fleet_model_fleet_vehicle_log_services_manager,fleet.model_fleet_vehicle_log_services,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_log_contract_manager,fleet_model_fleet_vehicle_log_contract_manager,fleet.model_fleet_vehicle_log_contract,logistic.group_manager,1,1,1,1
-fleet_model_fleet_service_type_manager,fleet_model_fleet_service_type_manager,fleet.model_fleet_service_type,logistic.group_manager,1,1,1,1
-fleet_model_fleet_vehicle_cost_manager,fleet_model_fleet_vehicle_cost_manager,fleet.model_fleet_vehicle_cost,logistic.group_manager,1,1,1,1
-fleet_model_fleet_contract_state_manager,fleet_model_fleet_contract_state_manager,fleet.model_fleet_contract_state,logistic.group_manager,1,1,1,1
diff --git a/logistic_x/security/logistic_group.xml b/logistic_x/security/logistic_group.xml
deleted file mode 100644
index acc5aeb..0000000
--- a/logistic_x/security/logistic_group.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/travel.py b/logistic_x/travel.py
deleted file mode 100644
index 2b22dee..0000000
--- a/logistic_x/travel.py
+++ /dev/null
@@ -1,410 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-from openerp import models, fields
-import time
-import datetime
-from openerp.tools.translate import _
-from openerp.exceptions import Warning
-from dateutil.relativedelta import relativedelta
-from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
-
-
-class travel(models.Model):
-
- """"""
-
- _inherit = 'logistic.travel'
-
- def _fnct_line_ordered(self):
- """"""
- res = {}
- # Por ahora no la usamos
- return res
-
- def name_get(self, cr, uid, ids, context=None):
- # always return the full hierarchical name
- res = self._complete_name(
- cr, uid, ids, 'complete_name', None, context=context)
- return res.items()
-
- def _complete_name(self, cr, uid, ids, name, args, context=None):
- """ Forms complete name of location from parent location to child location.
- @return: Dictionary of values
- """
- res = {}
- for line in self.browse(cr, uid, ids):
- name = line.waybill_id.name or '' + ': '
- name += line.location_from_id.name
- name += ' - ' + line.location_to_id.name
- res[line.id] = name
- return res
-
- def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
- if not args:
- args = []
- ids = set()
- if name:
- ids.update(self.search(cr, user, args + [('location_from_id.name', operator, name)], limit=(
- limit and (limit - len(ids)) or False), context=context))
- if not limit or len(ids) < limit:
- ids.update(self.search(
- cr, user, args + [('location_to_id.name', operator, name)], limit=limit, context=context))
- if not limit or len(ids) < limit:
- ids.update(self.search(
- cr, user, args + [('waybill_id.name', operator, name)], limit=limit, context=context))
- ids = list(ids)
- else:
- ids = self.search(cr, user, args, limit=limit, context=context)
- result = self.name_get(cr, user, ids, context=context)
- return result
-
- def _check_dates(self, cr, uid, ids, context=None):
- for leave in self.read(cr, uid, ids, ['to_date', 'from_date'], context=context):
- if leave['to_date'] and leave['from_date']:
- if leave['from_date'] > leave['to_date']:
- return False
- return True
-
- _constraints = [
- (_check_dates, 'Error! From date must be lower then to date.',
- ['to_date', 'from_date'])
- ]
-
- tractor_id = fields.Many2one(
- 'fleet.vehicle',
- related='waybill_id.tractor_id',
- string='Tractor', readonly=True, store=True)
- ordered = fields.Boolean(
- compute='_fnct_line_ordered',
- arg=None,
- fnct_inv_arg=None, obj=None, string='Ordered?', readonly=True)
- driver_id = fields.Many2one(
- 'res.partner',
- related='waybill_id.driver_id',
- string='Driver',
- domain=[('is_driver', '=', True)], readonly=True, store=True)
- invoice_id = fields.Many2one(
- 'account.invoice',
- related='invoice_line_id.invoice_id', string='Invoice', readonly=True)
-
- def get_from_date(self, cr, uid, context=None):
- waybill_id = context.get('waybill_id', False)
- from_date = time.strftime('%Y-%m-%d %H:%M:%S')
- if waybill_id:
- travel_ids = self.search(
- cr, uid, [('waybill_id', '=', waybill_id)], order="id desc", context=context)
- if travel_ids:
- from_date = self.browse(
- cr, uid, travel_ids[0], context=context).to_date
- return from_date
-
- _defaults = {
- 'from_date': get_from_date,
- }
-
- def on_change_location(self, cr, uid, ids, location_from_id, location_to_id, context=None):
- v = {}
- product_id = False
- if location_from_id and location_to_id:
- domain = [('type', '=', 'service'), ('service_subtype', '=', 'travel'), (
- 'location_from_id', '=', location_from_id), ('location_to_id', '=', location_to_id)]
- # domain = [('type','=','service'),('service_subtype','=','travel'),
- # '&',('location_from_id','=',location_from_id),('location_to_id','=',location_to_id),
- # '&',('location_to_id','=',location_from_id),('location_from_id','=',location_to_id)]
- product_ids = self.pool.get('product.product').search(
- cr, uid, domain, context=context)
- if product_ids:
- product_id = product_ids[0]
- v['product_id'] = product_id
- return {'value': v}
-
- def on_change_from_date(self, cr, uid, ids, from_date, context=None):
- v = {}
- if from_date:
- from_date = (datetime.datetime.strptime(from_date, DEFAULT_SERVER_DATETIME_FORMAT) +
- relativedelta(days=1)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
- v['to_date'] = from_date
- else:
- v['to_date'] = False
- return {'value': v}
-
- def on_change_product(self, cr, uid, ids, product_id, partner_id, context=None):
- """"""
- v = {}
- product_obj = self.pool['product.product']
- partner_obj = self.pool['res.partner']
- price = False
- if product_id:
- product = product_obj.browse(cr, uid, product_id, context=context)
- v['location_from_id'] = product.location_from_id.id
- v['location_to_id'] = product.location_to_id.id
- if product_id and partner_id:
- partner = partner_obj.browse(cr, uid, partner_id, context=context)
- if not partner.property_product_pricelist:
- pricelist_id = partner.property_product_pricelist
- else:
- pricelist_ids = self.pool['product.pricelist'].search(
- cr, uid, [('type', '=', 'sale')], context=context)
- if pricelist_ids:
- pricelist_id = pricelist_ids[0]
- else:
- raise Warning(
- _('Error!'), _('There is no sale pricelist!'))
- date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
- price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id],
- product_id, 1.0, partner_id, {
- 'uom': product.uos_id,
- 'date': date_order,
- })[pricelist_id]
- v['price'] = price
- return {'value': v}
-
- def action_invoice_create(self, cr, uid, ids, grouped=False, date_invoice=False, context=None):
- invoice_ids = []
- partner_currency = {}
-
- if context is None:
- context = {}
- # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
- # last day of the last month as invoice date
- if date_invoice:
- context['date_invoice'] = date_invoice
-
- for o in self.browse(cr, uid, ids, context=context):
- pricelist = self.get_pricelist(
- cr, uid, o.partner_id, context=context)
- currency_id = pricelist.currency_id.id
- if not o.partner_id or not o.product_id:
- raise Warning(
- _('Warning!'), _('To create invoice travels must have partner and product'))
- if (o.partner_id.id in partner_currency) and (partner_currency[o.partner_id.id] <> currency_id):
- raise Warning(
- _('Error!'),
- _('You cannot group travels having different currencies for the same partner.'))
-
- partner_currency[o.partner_id.id] = currency_id
- if grouped:
- for partner_id in partner_currency:
- travel_ids = self.search(
- cr, uid, [('id', 'in', ids), ('partner_id', '=', partner_id)], context=context)
- invoice_ids.append(
- self._invoice_create(cr, uid, travel_ids, context=context))
- else:
- for travel_id in ids:
- invoice_ids.append(
- self._invoice_create(cr, uid, [travel_id], context=context))
- return invoice_ids
-
- def _invoice_create(self, cr, uid, ids, context=None):
- inv_obj = self.pool.get('account.invoice')
- if context is None:
- context = {}
- # TODO
- # self.check_travel_one_partner
- # Just to make clear that all ids should be from the same partner
- partner_travel_ids = ids
- invoice_line_ids = self.invoice_line_create(
- cr, uid, partner_travel_ids, context=context)
-
- invoice_vals = self._prepare_invoice(
- cr, uid, partner_travel_ids, invoice_line_ids, context=context)
- inv_id = inv_obj.create(cr, uid, invoice_vals, context=context)
- data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], invoice_vals[
- 'payment_term'], time.strftime(DEFAULT_SERVER_DATE_FORMAT))
- if data.get('value', False):
- inv_obj.write(cr, uid, [inv_id], data['value'], context=context)
- inv_obj.button_compute(cr, uid, [inv_id])
- return inv_id
-
- def get_pricelist(self, cr, uid, partner, context=None):
- if partner.property_product_pricelist:
- return partner.property_product_pricelist
- else:
- pricelist_ids = self.pool['product.pricelist'].search(
- cr, uid, [('type', '=', 'sale')], context=context)
- if pricelist_ids:
- pricelist_id = pricelist_ids[0]
- else:
- raise Warning(
- _('Error!'), _('Order cannot be created because not sale pricelist exists!'))
- return self.pool['product.pricelist'].browse(cr, uid, pricelist_id, context=context)
-
- def invoice_line_create(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- create_ids = []
- if context.get('grouped_line'):
- product_ids = [x.product_id.id for x in self.browse(
- cr, uid, ids, context=context) if x.product_id]
- for product_id in list(set(product_ids)):
- travel_ids = self.search(
- cr, uid, [('id', 'in', ids), ('product_id', '=', product_id)], context=context)
- travels = self.browse(cr, uid, travel_ids, context=context)
- vals = self._prepare_order_line_invoice_line(
- cr, uid, travels, context=context)
- if vals:
- inv_line_id = self.pool.get('account.invoice.line').create(
- cr, uid, vals, context=context)
- self.write(
- cr, uid, travel_ids, {'invoice_line_id': inv_line_id}, context=context)
- create_ids.append(inv_line_id)
- else:
- for travel in self.browse(cr, uid, ids, context=context):
- vals = self._prepare_order_line_invoice_line(
- cr, uid, travel, context=context)
- if vals:
- inv_line_id = self.pool.get('account.invoice.line').create(
- cr, uid, vals, context=context)
- self.write(
- cr, uid, [travel.id], {'invoice_line_id': inv_line_id}, context=context)
- create_ids.append(inv_line_id)
- return create_ids
-
- def _prepare_order_line_invoice_line(self, cr, uid, travel, context=None):
- """Prepare the dict of values to create the new invoice line for a
- sales order line. This method may be overridden to implement custom
- invoice generation (making sure to call super() to establish
- a clean extension chain).
-
- :param browse_record line: sale.order.line record to invoice
- :param int account_id: optional ID of a G/L account to force
- (this is used for returning products including service)
- :return: dict of values to create() the invoice line
- """
- res = {}
- if context.get('grouped_line'):
- if not travel[0].invoice_line_id:
- if travel[0].product_id:
- account_id = travel[
- 0].product_id.property_account_income.id
- if not account_id:
- account_id = travel[
- 0].product_id.categ_id.property_account_income_categ.id
- if not account_id:
- raise Warning(_('Error!'),
- _('Please define income account for this product: "%s" (id:%d).') %
- (travel.product_id.name, travel.product_id.id,))
- fpos = travel[0].partner_id.property_account_position.id or False
- account_id = self.pool.get('account.fiscal.position').map_account(
- cr, uid, fpos, account_id)
- tax_ids = self.pool.get('account.fiscal.position').map_tax(
- cr, uid, fpos, travel[0].product_id.taxes_id)
- name = travel[0].product_id.name
- name += ', Hoja de Ruta: '
- name += ", ".join(
- [x.waybill_id.reference for x in travel if x.waybill_id.reference])
- refs = [x.reference for x in travel if x.reference]
- name += refs and ". Refs: " + ", ".join(refs) or ""
- pu = 0.0
- for travel_id in travel:
- uosqty = 1.0
- if uosqty:
- pu = pu + round(travel_id.price,
- self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
- if not account_id:
- raise Warning(_('Error!'),
- _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
- res = {
- 'name': name,
- 'account_id': account_id,
- 'price_unit': pu,
- 'quantity': uosqty,
- 'uos_id': travel[0].product_id and travel[0].product_id.uom_id.id or False,
- 'product_id': travel[0].product_id.id or False,
- 'invoice_line_tax_id': [(6, 0, tax_ids)],
- }
-
- else:
- if not travel.invoice_line_id:
- if travel.product_id:
- account_id = travel.product_id.property_account_income.id
- if not account_id:
- account_id = travel.product_id.categ_id.property_account_income_categ.id
- if not account_id:
- raise Warning(_('Error!'),
- _('Please define income account for this product: "%s" (id:%d).') %
- (travel.product_id.name, travel.product_id.id,))
- uosqty = self._get_line_qty(cr, uid, travel, context=context)
- uos_id = self._get_line_uom(cr, uid, travel, context=context)
- pu = 0.0
- if uosqty:
- pu = round(travel.price,
- self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
- fpos = travel.partner_id.property_account_position.id or False
- account_id = self.pool.get('account.fiscal.position').map_account(
- cr, uid, fpos, account_id)
- if not account_id:
- raise Warning(_('Error!'),
- _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
- tax_ids = self.pool.get('account.fiscal.position').map_tax(
- cr, uid, fpos, travel.product_id.taxes_id)
- name = travel.product_id.name
- name += ', Hoja de Ruta: '
- name += travel.waybill_id.reference or ''
- name += travel.reference and '. Refs: ' + \
- travel.reference or ''
- res = {
- 'name': name,
- 'account_id': account_id,
- 'price_unit': pu,
- 'quantity': uosqty,
- # 'discount': line.discount,
- 'uos_id': uos_id,
- 'product_id': travel.product_id.id or False,
- 'invoice_line_tax_id': [(6, 0, tax_ids)],
- }
-
- return res
-
- def _get_line_qty(self, cr, uid, travel, context=None):
-
- return 1.0
-
- def _get_line_uom(self, cr, uid, travel, context=None):
- return travel.product_id and travel.product_id.uom_id.id or False
-
- def _prepare_invoice(self, cr, uid, partner_travel_ids, lines, context=None):
- """Prepare the dict of values to create the new invoice for a
- sales order. This method may be overridden to implement custom
- invoice generation (making sure to call super() to establish
- a clean extension chain).
-
- :param browse_record order: sale.order record to invoice
- :param list(int) line: list of invoice line IDs that must be
- attached to the invoice
- :return: dict of value to create() the invoice
- """
- travel = self.browse(cr, uid, partner_travel_ids[0], context=context)
- partner = travel.partner_id
- waybill = self.browse(
- cr, uid, partner_travel_ids[0], context=context).waybill_id
- company = waybill.company_id
- if context is None:
- context = {}
- journal_ids = self.pool.get('account.journal').search(cr, uid,
- [('type', '=', 'sale'),
- ('company_id', '=', company.id)],
- limit=1)
- if not journal_ids:
- raise Warning(_('Error!'),
- _('Please define sales journal for this company: "%s" (id:%d).') % (company.name, company.id))
- # Don know why but it does not take the translation
- # origin = _('Waybill')
- origin = _('Hoja de Ruta')
- invoice_vals = {
- 'origin': origin,
- 'type': 'out_invoice',
- 'account_id': partner.property_account_receivable.id,
- 'partner_id': partner.id,
- 'journal_id': journal_ids[0],
- 'invoice_line': [(6, 0, lines)],
- 'currency_id': self.get_pricelist(cr, uid, partner, context=context).currency_id.id,
- 'payment_term': partner.property_payment_term and partner.property_payment_term.id or False,
- 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
- 'date_invoice': context.get('date_invoice', False),
- 'company_id': company.id,
- }
- return invoice_vals
diff --git a/logistic_x/vehicle.py b/logistic_x/vehicle.py
deleted file mode 100644
index 2b2b83e..0000000
--- a/logistic_x/vehicle.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-
-from openerp import models, fields, api
-
-
-class vehicle(models.Model):
-
- """"""
-
- _inherit = 'fleet.vehicle'
-
- _requirement_states = [
- # State machine: requirement_basic
- ('ok', 'OK'),
- ('next_to_renew', 'Next To Renew'),
- ('need_renew', 'Need Renew'),
- ]
-
- @api.one
- def _get_requirement_state(self):
- self.requirement_state = 'ok'
- if self.env['logistic.requirement'].search(
- [('vehicle_id', '=', self.id), ('state', '=', 'need_renew')]):
- self.requirement_state = 'need_renew'
- elif self.env['logistic.requirement'].search(
- [('vehicle_id', '=', self.id), ('state', '=', 'next_to_renew')]):
- self.requirement_state = 'next_to_renew'
-
- length = fields.Float(string='Length (mts)')
- width = fields.Float(string='Width (mts)')
- capacity = fields.Integer('Capacity (pallets)')
- name = fields.Char('Name', required=True)
- maintenance_ids = fields.One2many(
- 'logistic.requirement', 'vehicle_id',
- context={'default_type': 'maintenance'},
- domain=[('type', '=', 'maintenance'),
- ('state', 'not in', ['renewed', 'cancelled'])],
- string='Maintenances',)
- document_ids = fields.One2many(
- 'logistic.requirement', 'vehicle_id',
- context={'default_type': 'document'},
- domain=[('type', '=', 'document'),
- ('state', 'not in', ['renewed', 'cancelled'])],
- string='Documents',)
- requirement_state = fields.Selection(
- selection=_requirement_states,
- string="Requirements State", compute='_get_requirement_state')
diff --git a/logistic_x/view/logistic_menuitem.xml b/logistic_x/view/logistic_menuitem.xml
deleted file mode 100644
index f34e20f..0000000
--- a/logistic_x/view/logistic_menuitem.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
- Expenses to Invoice By Products
- logistic.waybill_expense
- form
- tree,form
-
-
- []
- {'search_default_to_invoice':1,'search_default_group_by_product':1}
-
-
-
-
-
-
diff --git a/logistic_x/view/partner_view.xml b/logistic_x/view/partner_view.xml
deleted file mode 100644
index 7253211..0000000
--- a/logistic_x/view/partner_view.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
- kanban,tree,form
-
-
-
-
-
-
-
- logistic.partner.select
- res.partner
-
-
-
-
-
-
-
-
-
- logistic.partner.form
- res.partner
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.partner.tree
- res.partner
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/view/product_view.xml b/logistic_x/view/product_view.xml
deleted file mode 100644
index 3818a46..0000000
--- a/logistic_x/view/product_view.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
- kanban,tree,form
-
-
-
-
-
-
-
- logistic.product.select
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.product.form
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/view/requirement_view.xml b/logistic_x/view/requirement_view.xml
deleted file mode 100644
index 41ec3d6..0000000
--- a/logistic_x/view/requirement_view.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
- {'default_type':'document','related_model':'res.partner','search_default_active':1}
-
-
-
-
- {'default_type':'document','related_model':'fleet.vehicle','search_default_active':1}
-
-
-
-
- {'default_type':'maintenance','related_model':'fleet.vehicle','search_default_active':1}
-
-
-
- logistic.requirement.select
- logistic.requirement
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.requirement.form
- logistic.requirement
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.requirement.tree
- logistic.requirement
-
-
-
- grey:state in ('cancelled','renewed');green:state in ('ok');violet:state in ('next_to_renew',); red:state in ('need_renew'); black:state=='renewal_requested'
-
-
-
-
-
-
-
diff --git a/logistic_x/view/travel_view.xml b/logistic_x/view/travel_view.xml
deleted file mode 100644
index e398c29..0000000
--- a/logistic_x/view/travel_view.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
- logistic.travel.calendar
- logistic.travel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- calendar,tree,form
-
-
-
-
-
-
-
- logistic.travel.select
- logistic.travel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {'search_default_to_invoice':1,'search_default_group_by_date':1}
-
-
-
-
- logistic.travel.form
- logistic.travel
-
-
-
-
-
- base.group_sale_salesman,account.group_account_invoice
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
-
- logistic.travel.tree
- logistic.travel
-
-
-
- false
-
-
- base.group_sale_salesman,account.group_account_invoice
- Total
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
-
diff --git a/logistic_x/view/waybill_driver_payment_view.xml b/logistic_x/view/waybill_driver_payment_view.xml
deleted file mode 100644
index 8f0ce71..0000000
--- a/logistic_x/view/waybill_driver_payment_view.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
- logistic.waybill_driver_payment.form
- logistic.waybill_driver_payment
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/view/waybill_expense_view.xml b/logistic_x/view/waybill_expense_view.xml
deleted file mode 100644
index 8305451..0000000
--- a/logistic_x/view/waybill_expense_view.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
- logistic.waybill_expense.select
- logistic.waybill_expense
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {'search_default_to_invoice':1,'search_default_group_by_partner':1}
-
-
-
-
- logistic.waybill_expense.form
- logistic.waybill_expense
-
-
-
-
-
-
-
-
-
- logistic.waybill_expense.tree
- logistic.waybill_expense
-
-
-
- false
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/view/waybill_view.xml b/logistic_x/view/waybill_view.xml
deleted file mode 100644
index 3e921b9..0000000
--- a/logistic_x/view/waybill_view.xml
+++ /dev/null
@@ -1,185 +0,0 @@
-
-
-
-
-
-
- {'search_default_active':True}
-
-
-
-
- logistic.waybill.select
- logistic.waybill
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.waybill.form
- logistic.waybill
-
-
-
-
-
-
-
-
-
-
-
- /
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- logistic.waybill.tree
- logistic.waybill
-
-
-
- Total
-
-
-
-
-
-
-
diff --git a/logistic_x/waybill.py b/logistic_x/waybill.py
deleted file mode 100644
index 216ee0a..0000000
--- a/logistic_x/waybill.py
+++ /dev/null
@@ -1,300 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-
-
-from openerp import models, fields, api
-from openerp.exceptions import Warning
-from openerp.tools.translate import _
-
-
-class waybill(models.Model):
-
- """"""
-
- _inherit = 'logistic.waybill'
-
- def _get_initial_odometer(self, cr, uid, ids, initial_odometer_id, arg, context):
- res = dict.fromkeys(ids, False)
- for record in self.browse(cr, uid, ids, context=context):
- if record.initial_odometer_id:
- res[record.id] = record.initial_odometer_id.value
- return res
-
- def _set_initial_odometer(self, cr, uid, id, name, value, args=None, context=None):
- if not value:
- # raise except_orm(_('Operation not allowed!'), _('Emptying the odometer value of a vehicle is not allowed.'))
- return True
- date = self.browse(cr, uid, id, context=context).date
- if not(date):
- date = fields.date.context_today(self, cr, uid, context=context)
- vehicle_id = self.browse(cr, uid, id, context=context).tractor_id
- data = {'value': value, 'date': date, 'vehicle_id': vehicle_id.id}
- odometer_id = self.pool.get('fleet.vehicle.odometer').create(
- cr, uid, data, context=context)
- return self.write(cr, uid, id, {'initial_odometer_id': odometer_id}, context=context)
-
- @api.one
- def _get_final_odometer(self):
- if self.final_odometer_id:
- self.final_odometer = self.final_odometer_id.value
-
- def _set_final_odometer(self, cr, uid, id, name, value, args=None, context=None):
- if not value:
- # raise except_orm(_('Operation not allowed!'), _('Emptying the odometer value of a vehicle is not allowed.'))
- return True
- date = self.browse(cr, uid, id, context=context).date
- if not(date):
- date = fields.date.context_today(self, cr, uid, context=context)
- vehicle_id = self.browse(cr, uid, id, context=context).tractor_id
- data = {'value': value, 'date': date, 'vehicle_id': vehicle_id.id}
- odometer_id = self.pool.get('fleet.vehicle.odometer').create(
- cr, uid, data, context=context)
- return self.write(cr, uid, id, {'final_odometer_id': odometer_id}, context=context)
-
- # WAGON
-
- def _get_wagon_initial_odometer(self):
- if self.wagon_initial_odometer_id:
- self.wagon_initial_odometer = self.wagon_initial_odometer_id.value
-
- def _set_wagon_initial_odometer(self, cr, uid, id, name, value, args=None, context=None):
- if not value:
- # raise except_orm(_('Operation not allowed!'), _('Emptying the odometer value of a vehicle is not allowed.'))
- return True
- date = self.browse(cr, uid, id, context=context).date
- if not(date):
- date = fields.date.context_today(self, cr, uid, context=context)
- vehicle_id = self.browse(cr, uid, id, context=context).wagon_id
- data = {'value': value, 'date': date, 'vehicle_id': vehicle_id.id}
- odometer_id = self.pool.get('fleet.vehicle.odometer').create(
- cr, uid, data, context=context)
- return self.write(cr, uid, id, {'wagon_initial_odometer_id': odometer_id}, context=context)
-
- @api.one
- def _get_wagon_final_odometer(self):
- if self.wagon_final_odometer_id:
- self.wagon_final_odometer = self.wagon_final_odometer_id.value
-
- def _set_wagon_final_odometer(self, cr, uid, id, name, value, args=None, context=None):
- if not value:
- # raise except_orm(_('Operation not allowed!'), _('Emptying the odometer value of a vehicle is not allowed.'))
- return True
- date = self.browse(cr, uid, id, context=context).date
- if not(date):
- date = fields.date.context_today(self, cr, uid, context=context)
- vehicle_id = self.browse(cr, uid, id, context=context).wagon_id
- data = {'value': value, 'date': date, 'vehicle_id': vehicle_id.id}
- odometer_id = self.pool.get('fleet.vehicle.odometer').create(
- cr, uid, data, context=context)
- return self.write(cr, uid, id, {'wagon_final_odometer_id': odometer_id}, context=context)
-
- @api.one
- @api.depends('initial_odometer', 'final_odometer')
- def _get_distance(self):
- if self.initial_odometer and self.final_odometer:
- self.distance = self.final_odometer - \
- self.initial_odometer
-
- def _get_amounts(self):
- # for record in self.browse(cr, uid, ids, context=context):
- self.driver_total = False
- if self.driver_unit_price and self.distance:
- self.driver_total = self.driver_unit_price * self.distance
-
- @api.one
- @api.depends(
- 'consumption',
- 'initial_liters',
- 'final_liters',
- 'waybill_expense_ids',
- 'waybill_expense_ids.product_uom_qty',
- 'state',
- 'initial_odometer',
- 'final_odometer'
- )
- def _get_fuel_data(self):
- expense_obj = self.env['logistic.waybill_expense']
- charged_liters = 0.0
- fuel_charge_ids = expense_obj.search([(
- 'waybill_id', '=', self.id), ('product_id.is_fuel', '=', True)])
- for fuel_charge in expense_obj.browse(fuel_charge_ids):
- charged_liters += fuel_charge.product_uom_qty
- consumed_liters = self.initial_liters + \
- charged_liters - self.final_liters
- if self.distance != 0:
- consumption = consumed_liters / self.distance
- else:
- consumption = 0
-
- self.charged_liters = charged_liters
- self.consumed_liters = consumed_liters
- self.consumption = consumption
- self.consumption_copy = consumption
-
- charged_liters = fields.Float(
- string='Charged', compute='_get_fuel_data', multi="fuel_data")
- consumed_liters = fields.Float(
- string='Consumed', compute='_get_fuel_data', multi="fuel_data")
- consumption = fields.Float(
- string='Consumption (l/km)', compute='_get_fuel_data', multi="fuel_data")
- consumption_copy = fields.Float(
- string='Consumption (l/km)',
- compute='_get_fuel_data',
- multi="fuel_data", store=True, group_operator="avg")
- initial_odometer_id = fields.Many2one(
- 'fleet.vehicle.odometer', 'Initial Odometer',
- help='Odometer measure of the vehicle at the moment of this log',
- readonly=True, states={'active': [('readonly', False)]})
- initial_odometer = fields.Float(
- fnct_inv=_set_initial_odometer,
- compute='_get_initial_odometer',
- string='Initial Odometer',
- readonly=True, states={'active': [('readonly', False)]})
- final_odometer_id = fields.Many2one(
- 'fleet.vehicle.odometer', 'Final Odometer',
- help='Odometer measure of the vehicle at the moment of this log',
- readonly=True, states={'active': [('readonly', False)]})
- final_odometer = fields.Float(
- fnct_inv=_set_final_odometer,
- compute='_get_final_odometer',
- string='Final Odometer',
- readonly=True, states={'active': [('readonly', False)]})
- distance = fields.Float(
- compute='_get_distance', string='Distance', store=True)
- driver_total = fields.Float(
- compute='_get_amounts', string='Driver Total', multi="_get_amounts")
- wagon_initial_odometer_id = fields.Many2one(
- 'fleet.vehicle.odometer', 'Initial Odometer',
- help='Odometer measure of the vehicle at the moment of this log',
- readonly=True, states={'active': [('readonly', False)]})
- wagon_initial_odometer = fields.Float(
- fnct_inv=_set_wagon_initial_odometer,
- compute='_get_wagon_initial_odometer',
- string='Initial Odometer', readonly=True,
- states={'active': [('readonly', False)]})
- wagon_final_odometer_id = fields.Many2one(
- 'fleet.vehicle.odometer', 'Final Odometer',
- help='Odometer measure of the vehicle at the moment of this log',
- readonly=True, states={'active': [('readonly', False)]})
- wagon_final_odometer = fields.Float(
- fnct_inv=_set_wagon_final_odometer,
- compute='_get_wagon_final_odometer',
- string='Final Odometer', readonly=True,
- states={'active': [('readonly', False)]})
- tractor_status = fields.Selection(
- related='tractor_id.requirement_state', string='Tractor Status')
- wagon_status = fields.Selection(
- related='wagon_id.requirement_state', string='Wagon Status')
- driver_status = fields.Selection(
- related='driver_id.requirement_state', string='Driver Status')
-
- def on_change_tractor_final_odometer(self, cr, uid, ids, initial_odometer, final_odometer, wagon_initial_odometer, context=None):
- v = {}
- if initial_odometer and final_odometer and wagon_initial_odometer:
- v['wagon_final_odometer'] = final_odometer - \
- initial_odometer + wagon_initial_odometer
- return {'value': v}
-
- def on_change_wagon(self, cr, uid, ids, wagon_id, context=None):
- v = {}
- if wagon_id:
- wagon = self.pool.get('fleet.vehicle').browse(
- cr, uid, wagon_id, context=context)
- v['wagon_initial_odometer'] = wagon.odometer
- else:
- v['wagon_initial_odometer'] = False
- return {'value': v}
-
- def on_change_driver(self, cr, uid, ids, driver_id, context=None):
- v = {}
- if driver_id:
- driver = self.pool.get('res.partner').browse(
- cr, uid, driver_id, context=context)
- v['driver_product_id'] = driver.driver_product_id.id
- else:
- v['driver_product_id'] = False
- return {'value': v}
-
- def on_change_product(self, cr, uid, ids, product_id, context=None):
- v = {}
- if product_id:
- product = self.pool.get('product.product').browse(
- cr, uid, product_id, context=context)
- v['driver_unit_price'] = product.list_price
- else:
- v['driver_unit_price'] = False
- return {'value': v}
-
- def on_change_tractor(self, cr, uid, ids, tractor_id, context=None):
- v = {}
- if tractor_id:
- vehicle = self.pool.get('fleet.vehicle').browse(
- cr, uid, tractor_id, context=context)
- v['initial_odometer'] = vehicle.odometer
- if vehicle.wagon_id.id:
- v['wagon_id'] = vehicle.wagon_id.id
- else:
- v['wagon_id'] = False
- v['wagon_initial_odometer'] = False
- if vehicle.driver_id.id:
- v['driver_id'] = vehicle.driver_id.id
- else:
- v['driver_id'] = False
- else:
- v['initial_odometer'] = False
- v['wagon_initial_odometer'] = False
- v['wagon_id'] = False
- v['driver_id'] = False
- return {'value': v}
-
- def create(self, cr, uid, vals, context=None):
- if vals.get('name', '/') == '/':
- vals['name'] = self.pool.get('ir.sequence').get(
- cr, uid, 'logistic.waybill') or '/'
- return super(waybill, self).create(cr, uid, vals, context=context)
-
- def copy(self, cr, uid, id, default=None, context=None):
- if not default:
- default = {}
- default.update({
- 'date': fields.date.context_today(self, cr, uid, context=context),
- 'travel_ids': [],
- 'waybill_expense_ids': [],
- 'initial_odometer_id': False,
- 'initial_odometer': self.browse(cr, uid, id, context=context).tractor_id.odometer,
- 'final_odometer_id': False,
- 'wagon_initial_odometer_id': False,
- 'wagon_initial_odometer': self.browse(cr, uid, id, context=context).wagon_id.odometer,
- 'wagon_final_odometer_id': False,
- 'name': self.pool.get('ir.sequence').get(cr, uid, 'logistic.waybill'),
- })
- return super(waybill, self).copy(cr, uid, id, default, context=context)
-
- def check_closure(self, cr, uid, ids, context=None):
- travel_obj = self.pool['logistic.travel']
- for record in self.browse(cr, uid, ids, context=context):
- if not record.final_odometer or record.initial_odometer >= record.final_odometer:
- raise Warning(
- _('Error!'), _('Tractor Final odometer must be greater than initial odometer!'))
- if not record.wagon_final_odometer or record.wagon_initial_odometer >= record.wagon_final_odometer:
- raise Warning(
- _('Error!'), _('Wagon Final odometer must be greater than initial odometer!'))
- if not record.date_start:
- travel_ids = travel_obj.search(
- cr, uid, [('waybill_id', '=', record.id)], order='from_date', context=context)
- if travel_ids and not record.date_start:
- date_start = travel_obj.browse(
- cr, uid, travel_ids[0], context=context).from_date
- self.write(
- cr, uid, [record.id], {'date_start': date_start}, context=context)
- if not record.date_finish:
- travel_ids = travel_obj.search(
- cr, uid, [('waybill_id', '=', record.id)], order='to_date desc', context=context)
- if travel_ids and not record.date_finish:
- date_finish = travel_obj.browse(
- cr, uid, travel_ids[0], context=context).to_date
- self.write(
- cr, uid, [record.id], {'date_finish': date_finish}, context=context)
diff --git a/logistic_x/waybill_expense.py b/logistic_x/waybill_expense.py
deleted file mode 100644
index f44cead..0000000
--- a/logistic_x/waybill_expense.py
+++ /dev/null
@@ -1,281 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-
-from openerp import models, fields, api, _
-import time
-from openerp.exceptions import Warning
-from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
-import openerp.addons.decimal_precision as dp
-
-
-class waybill_expense(models.Model):
-
- """"""
-
- _inherit = 'logistic.waybill_expense'
-
- @api.one
- @api.depends('price_unit', 'product_uom_qty')
- def _amount_line(self):
- # tax_obj = self.pool.get('account.tax')
- # cur_obj = self.pool.get('res.currency')
- self.price_subtotal = self.price_unit * self.product_uom_qty
- # taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
- # cur = line.order_id.pricelist_id.currency_id
- # res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
-
- price_subtotal = fields.Float(
- compute='_amount_line',
- string='Subtotal', digits_compute=dp.get_precision('Account'))
- date = fields.Date(
- related='waybill_id.date', string='Date', store=True)
-
- def action_invoice_create(self, cr, uid, ids, grouped=False, date_invoice=False, context=None):
- invoice_ids = []
- partner_currency = {}
-
- if context is None:
- context = {}
- # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
- # last day of the last month as invoice date
- if date_invoice:
- context['date_invoice'] = date_invoice
-
- for o in self.browse(cr, uid, ids, context=context):
- pricelist = self.get_pricelist(
- cr, uid, o.supplier_id, context=context)
- currency_id = pricelist.currency_id.id
- if not o.supplier_id or not o.product_id:
- raise Warning(
- _('Warning!'), _('To create invoice expenses must have supplier and product'))
- if (o.supplier_id.id in partner_currency) and (partner_currency[o.supplier_id.id] <> currency_id):
- raise Warning(
- _('Error!'),
- _('You cannot group expenses having different currencies for the same supplier.'))
-
- partner_currency[o.supplier_id.id] = currency_id
- if grouped:
- for supplier_id in partner_currency:
- expense_ids = self.search(
- cr, uid, [('id', 'in', ids), ('supplier_id', '=', supplier_id)], context=context)
- invoice_ids.append(
- self._invoice_create(cr, uid, expense_ids, context=context))
- else:
- for expense_id in ids:
- invoice_ids.append(
- self._invoice_create(cr, uid, [expense_id], context=context))
- return invoice_ids
-
- def _invoice_create(self, cr, uid, ids, context=None):
- inv_obj = self.pool.get('account.invoice')
- if context is None:
- context = {}
- # TODO
- # self.check_travel_one_partner
- # Just to make clear that all ids should be from the same partner
- partner_expense_ids = ids
- invoice_line_ids = self.invoice_line_create(
- cr, uid, partner_expense_ids, context=context)
-
- invoice_vals = self._prepare_invoice(
- cr, uid, partner_expense_ids, invoice_line_ids, context=context)
- inv_id = inv_obj.create(cr, uid, invoice_vals, context=context)
- data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], invoice_vals[
- 'payment_term'], time.strftime(DEFAULT_SERVER_DATE_FORMAT))
- if data.get('value', False):
- inv_obj.write(cr, uid, [inv_id], data['value'], context=context)
- inv_obj.button_compute(cr, uid, [inv_id])
- print 'expe', inv_id
- return inv_id
-
- def get_pricelist(self, cr, uid, partner, context=None):
- if partner.property_product_pricelist:
- return partner.property_product_pricelist
- else:
- pricelist_ids = self.pool['product.pricelist'].search(
- cr, uid, [('type', '=', 'purchase')], context=context)
- if pricelist_ids:
- pricelist_id = pricelist_ids[0]
- else:
- raise Warning(
- _('Error!'), _('Order cannot be created because no purchase pricelist exists!'))
- return self.pool['product.pricelist'].browse(cr, uid, pricelist_id, context=context)
-
- def invoice_line_create(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
-
- create_ids = []
- if context.get('grouped_line'):
- product_ids = [x.product_id.id for x in self.browse(
- cr, uid, ids, context=context) if x.product_id]
- for product_id in list(set(product_ids)):
- expense_ids = self.search(
- cr, uid,
- [('id', 'in', ids), ('product_id', '=', product_id)],
- context=context)
- if expense_ids == []:
- expense_ids = ids
- expenses = self.browse(cr, uid, expense_ids, context=context)
- vals = self._prepare_order_line_invoice_line(
- cr, uid, expenses, context=context)
- if vals:
- inv_line_id = self.pool.get('account.invoice.line').create(
- cr, uid, vals, context=context)
- self.write(
- cr, uid, expense_ids, {'invoice_line_id': inv_line_id}, context=context)
- create_ids.append(inv_line_id)
- else:
- for expense in self.browse(cr, uid, ids, context=context):
- vals = self._prepare_order_line_invoice_line(
- cr, uid, expense, context=context)
- if vals:
- inv_line_id = self.pool.get('account.invoice.line').create(
- cr, uid, vals, context=context)
- self.write(
- cr, uid, [expense.id], {'invoice_line_id': inv_line_id}, context=context)
- create_ids.append(inv_line_id)
- return create_ids
-
- def _prepare_order_line_invoice_line(self, cr, uid, expense, context=None):
- """Prepare the dict of values to create the new invoice line for a
- sales order line. This method may be overridden to implement custom
- invoice generation (making sure to call super() to establish
- a clean extension chain).
-
- :param browse_record line: sale.order.line record to invoice
- :param int account_id: optional ID of a G/L account to force
- (this is used for returning products including service)
- :return: dict of values to create() the invoice line
- """
- res = {}
- if context.get('grouped_line'):
- if not expense[0].invoice_line_id:
- if expense[0].product_id:
- account_id = expense[
- 0].product_id.property_account_income.id
- if not account_id:
- account_id = expense[
- 0].product_id.categ_id.property_account_income_categ.id
- if not account_id:
- raise Warning(_('Error!'),
- _('Please define income account for this product: "%s" (id:%d).') %
- (expense.product_id.name, expense.product_id.id,))
- fpos = expense[0].supplier_id.property_account_position.id or False
- account_id = self.pool.get('account.fiscal.position').map_account(
- cr, uid, fpos, account_id)
- tax_ids = self.pool.get('account.fiscal.position').map_tax(
- cr, uid, fpos, expense[0].product_id.taxes_id)
- name = expense[0].product_id.name
- name += ', Hoja de Ruta: '
- name += ", ".join(
- [x.waybill_id.reference for x in expense if x.waybill_id.reference])
- pu = 0.0
- uosqty = 0.0
- for expense_id in expense:
- uosqty = uosqty + expense_id.product_uom_qty
- if uosqty:
- pu = round(expense_id.price_unit,
- self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
- if not account_id:
- raise Warning(_('Error!'),
- _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
- res = {
- 'name': name,
- 'account_id': account_id,
- 'price_unit': pu,
- 'quantity': uosqty,
- 'uos_id': expense[0].product_id and expense[0].product_id.uom_id.id or False,
- 'product_id': expense[0].product_id.id or False,
- 'invoice_line_tax_id': [(6, 0, tax_ids)],
- }
-
- else:
- if not expense.invoice_line_id:
- if expense.product_id:
- account_id = expense.product_id.property_account_income.id
- if not account_id:
- account_id = expense.product_id.categ_id.property_account_income_categ.id
- if not account_id:
- raise Warning(_('Error!'),
- _('Please define income account for this product: "%s" (id:%d).') %
- (expense.product_id.name, expense.product_id.id,))
- uosqty = self._get_line_qty(cr, uid, expense, context=context)
- uos_id = self._get_line_uom(cr, uid, expense, context=context)
- pu = 0.0
- if uosqty:
- pu = round(expense.price_unit,
- self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
- fpos = expense.supplier_id.property_account_position.id or False
- account_id = self.pool.get('account.fiscal.position').map_account(
- cr, uid, fpos, account_id)
- if not account_id:
- raise Warning(_('Error!'),
- _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
- tax_ids = self.pool.get('account.fiscal.position').map_tax(
- cr, uid, fpos, expense.product_id.taxes_id)
- res = {
- 'name': expense.product_id.name,
- 'account_id': account_id,
- 'price_unit': pu,
- 'quantity': uosqty,
- # 'discount': line.discount,
- 'uos_id': uos_id,
- 'product_id': expense.product_id.id or False,
- # TODO: add tax
- 'invoice_line_tax_id': [(6, 0, tax_ids)],
- }
-
- return res
-
- def _get_line_qty(self, cr, uid, expense, context=None):
- return expense.product_uom_qty
-
- def _get_line_uom(self, cr, uid, expense, context=None):
- return expense.product_id and expense.product_id.uom_id.id or False
-
- def _prepare_invoice(self, cr, uid, partner_expense_ids, lines, context=None):
- """Prepare the dict of values to create the new invoice for a
- sales order. This method may be overridden to implement custom
- invoice generation (making sure to call super() to establish
- a clean extension chain).
-
- :param browse_record order: sale.order record to invoice
- :param list(int) line: list of invoice line IDs that must be
- attached to the invoice
- :return: dict of value to create() the invoice
- """
- expense = self.browse(cr, uid, partner_expense_ids[0], context=context)
- partner = expense.supplier_id
- waybill = self.browse(
- cr, uid, partner_expense_ids[0], context=context).waybill_id
- company = waybill.company_id
- if context is None:
- context = {}
- journal_ids = self.pool.get('account.journal').search(cr, uid,
- [('type', '=', 'purchase'),
- ('company_id', '=', company.id)],
- limit=1)
- if not journal_ids:
- raise Warning(_('Error!'),
- _('Please define purchases journal for this company: "%s" (id:%d).') % (company.name, company.id))
- origin = _('Gastos de Hoja de Ruta')
- invoice_vals = {
- 'origin': origin,
- 'type': 'in_invoice',
- 'account_id': partner.property_account_payable.id,
- 'partner_id': partner.id,
- 'journal_id': journal_ids[0],
- 'invoice_line': [(6, 0, lines)],
- 'currency_id': self.get_pricelist(cr, uid, partner, context=context).currency_id.id,
- 'payment_term': partner.property_supplier_payment_term and partner.property_supplier_payment_term.id or False,
- 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
- 'date_invoice': context.get('date_invoice', False),
- 'company_id': company.id,
- }
- return invoice_vals
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/logistic_x/wizard/README b/logistic_x/wizard/README
deleted file mode 100644
index e69de29..0000000
diff --git a/logistic_x/wizard/__init__.py b/logistic_x/wizard/__init__.py
deleted file mode 100644
index 733f952..0000000
--- a/logistic_x/wizard/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-# For copyright and license notices, see __openerp__.py file in module root
-# directory
-##############################################################################
-
-# import travel_sale_order
-import travel_make_invoice
-import expense_make_invoice
diff --git a/logistic_x/workflow/requirement_workflow.xml b/logistic_x/workflow/requirement_workflow.xml
deleted file mode 100644
index d005f75..0000000
--- a/logistic_x/workflow/requirement_workflow.xml
+++ /dev/null
@@ -1,184 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- set_ok()
- write({'state':'ok'})
-
-
-
-
-
-
-
-
- request_renew()
- write({'state':'renewal_requested'})
-
-
-
-
-
-
-
-
-
- action_cancel()
- write({'state':'cancelled'})
-
-
-
-
-
-
-
-
-
diff --git a/logistic_x/workflow/waybill_workflow.xml b/logistic_x/workflow/waybill_workflow.xml
deleted file mode 100644
index 7e11d45..0000000
--- a/logistic_x/workflow/waybill_workflow.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- check_closure()
- write({'state':'closed'})
-
-
-
-
-
-
-
-
-
-
-