avanzosc team mailing list archive
-
avanzosc team
-
Mailing list archive
-
Message #00537
Re: [Merge] lp:~oihanecruce/avanzosc/nayar_seur_logistica into lp:~avanzosc-security-team/avanzosc/72horas
Comentario acerca de lo del ID
Diff comments:
> === modified file 'nayar_seur_logistica/__init__.py'
> --- nayar_seur_logistica/__init__.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/__init__.py 2014-07-02 10:11:55 +0000
> @@ -19,11 +19,4 @@
> #
> ##############################################################################
>
> -import automation
> -import carrier
> -import lot
> -import product
> -import refund
> -import sale
> -
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
> +from . import models
> \ No newline at end of file
>
> === modified file 'nayar_seur_logistica/__openerp__.py'
> --- nayar_seur_logistica/__openerp__.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/__openerp__.py 2014-07-02 10:11:55 +0000
> @@ -24,22 +24,23 @@
> "version": "1.0",
> "author": "Nayar Systems",
> "category": "Enterprise Specific Modules",
> - "description": "Procesamiento de pedidos a través del sistema de Seur Logística",
> - "depends": ["nayar_dos_contracts"],
> - "init_xml": [],
> - "demo_xml": [],
> - "update_xml": [
> + "description": """
> + Procesamiento de pedidos a través del sistema de Seur Logística
> + """,
> + "depends": [
> + "nayar_dos_contracts",
> + ],
> + "data": [
> "security/nayar_automation.xml",
> "security/ir.model.access.csv",
> - "automation_view.xml",
> - "automation_data.xml",
> - "lot_view.xml",
> - "product_view.xml",
> - "sale_view.xml",
> - "refund_view.xml",
> - ],
> + "views/automation_view.xml",
> + "data/automation_data.xml",
> + "views/lot_view.xml",
> + "views/product_view.xml",
> + "views/sale_view.xml",
> + "views/refund_view.xml",
> + ],
> "website": 'http://www.72horas.net/',
> "active": False,
> "installable": True
> }
> -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
>
> === added directory 'nayar_seur_logistica/data'
> === renamed file 'nayar_seur_logistica/automation_data.xml' => 'nayar_seur_logistica/data/automation_data.xml'
> --- nayar_seur_logistica/automation_data.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/data/automation_data.xml 2014-07-02 10:11:55 +0000
> @@ -1,15 +1,15 @@
> <?xml version="1.0" encoding="utf-8"?>
> <openerp>
> - <data noupdate="1">
> - <record id="ir_cron_sale_order_automation_action" model="ir.cron">
> - <field name="name">Sale Order Automation Service</field>
> - <field name="interval_number">1</field>
> - <field name="interval_type">minutes</field>
> - <field name="numbercall">-1</field>
> - <field name="doall" eval="False"/>
> - <field name="model" eval="'sale.order.automation'"/>
> - <field name="function" eval="'send_orders'"/>
> - <field name="args" eval="False"/>
> - </record>
> - </data>
> + <data noupdate="1">
> + <record id="ir_cron_sale_order_automation_action" model="ir.cron">
> + <field name="name">Sale Order Automation Service</field>
> + <field name="interval_number">1</field>
> + <field name="interval_type">minutes</field>
> + <field name="numbercall">-1</field>
> + <field name="doall" eval="False" />
> + <field name="model" eval="'sale.order.automation'" />
> + <field name="function" eval="'send_orders'" />
> + <field name="args" eval="False" />
> + </record>
> + </data>
> </openerp>
>
> === added directory 'nayar_seur_logistica/models'
> === added file 'nayar_seur_logistica/models/__init__.py'
> --- nayar_seur_logistica/models/__init__.py 1970-01-01 00:00:00 +0000
> +++ nayar_seur_logistica/models/__init__.py 2014-07-02 10:11:55 +0000
> @@ -0,0 +1,27 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +# OpenERP, Open Source Management Solution
> +# Copyright (C) 2013 Nayar Systems (<http://www.72horas.net/>)
> +#
> +# 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 <http://www.gnu.org/licenses/>.
> +#
> +##############################################################################
> +
> +from . import automation
> +from . import carrier
> +from . import lot
> +from . import product
> +from . import refund
> +from . import sale
>
> === renamed file 'nayar_seur_logistica/automation.py' => 'nayar_seur_logistica/models/automation.py'
> --- nayar_seur_logistica/automation.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/automation.py 2014-07-02 10:11:55 +0000
> @@ -19,12 +19,12 @@
> #
> ##############################################################################
>
> -from osv import osv, fields
> +from openerp.osv import orm, fields
> import re
> import time
>
>
> -class sale_order_automation(osv.osv):
> +class SaleOrderAutomation(orm.Model):
> _name = 'sale.order.automation'
> _description = "Rules for managing orders in a automatic way"
>
> @@ -32,57 +32,93 @@
> 'name': fields.char('Name', size=64, required=True),
> 'active_automation': fields.boolean('Active'),
> 'all_partners': fields.boolean('All Partners'),
> - 'schedule_ids': fields.one2many('sale.order.automation.schedule', 'automation_id', 'Schedules'),
> - 'partner_ids': fields.one2many('sale.order.automation.partner', 'automation_id', 'Partners'),
> - 'except_partner_ids': fields.many2many('res.partner', 'sale_order_automation_except_partner', 'automation_except_partner_id', 'partner_id', 'Partner Exceptions'),
> - 'product_ids': fields.many2many('product.product', 'sale_order_automation_product', 'automation_id', 'product_id', 'Products'),
> - }
> + 'schedule_ids': fields.one2many('sale.order.automation.schedule',
> + 'automation_id', 'Schedules'),
> + 'partner_ids': fields.one2many('sale.order.automation.partner',
> + 'automation_id', 'Partners'),
> + 'except_partner_ids': fields.many2many(
> + 'res.partner', 'sale_order_automation_except_partner',
> + 'automation_except_partner_id', 'partner_id',
> + 'Partner Exceptions'),
> + 'product_ids': fields.many2many('product.product',
> + 'sale_order_automation_product',
> + 'automation_id', 'product_id',
> + 'Products'),
> + }
>
> _default = {
> 'active_automation': True,
> 'all_partners': False,
> - }
> + }
>
> - def send_orders(self, cr, uid):
> - order_obj = self.pool.get('sale.order')
> + def send_orders(self, cr, uid, context=None):
> + order_obj = self.pool['sale.order']
> schedule_obj = self.pool.get('sale.order.automation.schedule')
>
> now = time.localtime()
> now_time = "%02d:%02d" % (now.tm_hour, now.tm_min)
>
> - order_ids = order_obj.search(cr, uid, [('state', '=', 'draft'), ('seur_state', '=', 'none')])
> + order_ids = order_obj.search(cr, uid, [('state', '=', 'draft'),
> + ('seur_state', '=', 'none')],
> + context=context)
> if not order_ids:
> return True
>
> for order in order_obj.browse(cr, uid, order_ids):
> # Branches or customers with automation
> automation_ids = set().union(
> - self.search(cr, uid, [('partner_ids.address_ids', '=', order.partner_shipping_id.id), ('active_automation', '=', True)]),
> - self.search(cr, uid, [('partner_ids.partner_id', '=', order.elevator_partner_id.id), ('partner_ids.all_branches', '=', True), ('active_automation', '=', True)]),
> - self.search(cr, uid, [('all_partners', '=', True), ('active_automation', '=', True)])
> - )
> + self.search(
> + cr, uid, [('partner_ids.address_ids', '=',
> + order.partner_shipping_id.id),
> + ('active_automation', '=', True)],
> + context=context),
> + self.search(
> + cr, uid, [('partner_ids.partner_id', '=',
> + order.elevator_partner_id.id),
> + ('partner_ids.all_branches', '=', True),
> + ('active_automation', '=', True)],
> + context=context),
> + self.search(
> + cr, uid, [('all_partners', '=', True),
> + ('active_automation', '=', True)],
> + context=context)
> + )
> automation_ids = list(automation_ids)
>
> # Customers exceptions
> - automation_ids = self.search(cr, uid, [('id', 'in', automation_ids), '!', ('except_partner_ids', '=', order.elevator_partner_id.id)])
> + automation_ids = self.search(
> + cr, uid,
> + [('id', 'in', automation_ids), '!',
> + ('except_partner_ids', '=', order.elevator_partner_id.id)],
> + context=context)
>
> # Products
> - product_ids = list(set([line.product_id and line.product_id.id or False for line in order.order_line]))
> - conds = [('product_ids', '=', product_id) for product_id in product_ids]
> + product_ids = list(set([line.product_id and
> + line.product_id.id or
> + False for line in order.order_line]))
> + conds = [('product_ids', '=', product_id)
> + for product_id in product_ids]
> conds.append(('id', 'in', automation_ids))
> - automation_ids = self.search(cr, uid, conds)
> + automation_ids = self.search(cr, uid, conds, context=context)
>
> if not automation_ids:
> continue
>
> # Schedules
> - schedule_ids = schedule_obj.search(cr, uid, [('from_time', '<=', now_time), ('to_time', '>=', now_time), ('automation_id', 'in', list(automation_ids))])
> + schedule_ids = schedule_obj.search(cr, uid,
> + [('from_time', '<=', now_time),
> + ('to_time', '>=', now_time),
> + ('automation_id', 'in',
> + list(automation_ids))],
> + context=context)
> if not schedule_ids:
> continue
>
> # Send orders
> - order_time = time.mktime(time.strptime(order.create_date, '%Y-%m-%d %H:%M:%S'))
> - for schedule in schedule_obj.browse(cr, uid, schedule_ids):
> + order_time = time.mktime(time.strptime(order.create_date,
> + '%Y-%m-%d %H:%M:%S'))
> + for schedule in schedule_obj.browse(cr, uid, schedule_ids,
> + context=context):
> waiting_time = schedule.waiting
> if schedule.waiting_unit == 'hour':
> waiting_time *= 60
> @@ -90,22 +126,22 @@
> if time.mktime(now) - order_time > waiting_time:
> order_obj.send_to_seur(cr, uid, [order.id])
> break
> -
> -
> -sale_order_automation()
> -
> -
> -class sale_order_automation_schedule(osv.osv):
> +
> +
> +class SaleOrderAutomationSchedule(orm.Model):
> _name = 'sale.order.automation.schedule'
> _description = "Schedule for the sale orders automation"
>
> _columns = {
> - 'automation_id': fields.many2one('sale.order.automation', 'Automation', select=True, required=True, ondelete="cascade"),
> + 'automation_id': fields.many2one('sale.order.automation', 'Automation',
> + select=True, required=True,
> + ondelete="cascade"),
> 'from_time': fields.char('From time', size=5, required=True),
> 'to_time': fields.char('To time', size=5, required=True),
> 'waiting': fields.integer('Waiting Time', required=True),
> - 'waiting_unit': fields.selection([('minute', 'Minute'), ('hour', 'Hour')], 'Time Unit'),
> - }
> + 'waiting_unit': fields.selection([('minute', 'Minute'),
> + ('hour', 'Hour')], 'Time Unit'),
> + }
>
> def _check_time(self, cr, uid, ids, context=None):
> if context is None:
> @@ -113,30 +149,33 @@
> schedules = self.browse(cr, uid, ids, context=context)
> r = re.compile('\d\d:\d\d')
> for schedule in schedules:
> - if r.match(schedule.from_time) is None or r.match(schedule.to_time) is None:
> + if (r.match(schedule.from_time) is None
> + or r.match(schedule.to_time) is None):
> return False
> return True
>
> _constraints = [
> - (_check_time, 'Error! Time must have hh:mm format.', ['from_time', 'to_time']),
> - ]
> -
> -sale_order_automation_schedule()
> -
> -
> -class sale_order_automation_partner(osv.osv):
> + (_check_time, 'Error! Time must have hh:mm format.',
> + ['from_time', 'to_time']),
> + ]
> +
> +
> +class SaleOrderAutomationPartner(orm.Model):
> _name = 'sale.order.automation.partner'
> _description = 'Partner with sale orders automated'
>
> _columns = {
> - 'automation_id': fields.many2one('sale.order.automation', 'Automation', select=True, required=True, ondelete='cascade'),
> - 'partner_id': fields.many2one('res.partner', 'Partner', select=True, required=True),
> + 'automation_id': fields.many2one('sale.order.automation', 'Automation',
> + select=True, required=True,
> + ondelete='cascade'),
> + 'partner_id': fields.many2one('res.partner', 'Partner', select=True,
> + required=True),
> 'all_branches': fields.boolean('All Branches'),
> - 'address_ids': fields.many2many('res.partner.address', 'sale_order_automation_partner_address', 'automation_partner_id', 'address_id', 'Branches'),
> - }
> +# 'address_ids': fields.many2many(
> +# 'res.partner.address', 'sale_order_automation_partner_address',
> +# 'automation_partner_id', 'address_id', 'Branches'),
> + }
>
> _default = {
> 'all_branches': False,
> - }
> -
> -sale_order_automation_partner()
> + }
>
> === renamed file 'nayar_seur_logistica/carrier.py' => 'nayar_seur_logistica/models/carrier.py'
> --- nayar_seur_logistica/carrier.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/carrier.py 2014-07-02 10:11:55 +0000
> @@ -20,25 +20,28 @@
> ##############################################################################
>
> import logging
> -from osv import osv
> import platform
> import seur_ftp
> import time
> -from tools import config
> -
> -
> -class delivery_carrier(osv.osv):
> +from openerp.osv import orm
> +from openerp.tools import config
> +
> +
> +class DeliveryCarrier(orm.Model):
> _inherit = 'delivery.carrier'
>
> _delivery_objects = [
> 'sale.order',
> 'refund.products',
> - ]
> + ]
>
> def ftp_to_seur(self, cr, uid):
> - """ Envía los pedidos preparados al sistema informático de Seur Logística. """
> + """
> + Envía los pedidos preparados al sistema informático de Seur Logística.
> + """
>
> - deliveries = [self.pool.get(obj).get_delivery(cr, uid) for obj in self._delivery_objects]
> + deliveries = [self.pool[obj].get_delivery(cr, uid)
> + for obj in self._delivery_objects]
> headers = []
> lines = []
> for delivery in deliveries:
> @@ -70,7 +73,6 @@
> if config.get('seur_email'):
> self.send_email(cr, uid, to=config.get('seur_email').split(";"), subject="Pedidos de ventas Nayar - " + time.strftime("%d/%m/%Y - %H:%M:%S", time.localtime()), body="".join([delivery['object'].delivery_email_body(cr, uid, delivery['ids']) for delivery in deliveries]))
>
> -
> errors_body = ""
> for delivery in deliveries:
> if delivery.get('errors'):
> @@ -85,11 +87,14 @@
> def send_email(self, cr, uid, to, subject="", body="", check_node=True):
> """ Envia información de pedidos por correo electrónico. """
>
> - if check_node and (platform.node() != config.get('prod_host') or cr.dbname != config.get('prod_db')):
> + if check_node and (platform.node() != config.get('prod_host') or
> + cr.dbname != config.get('prod_db')):
> return False
>
> smtp_obj = self.pool.get('email.smtpclient')
> - smtpserver_id = smtp_obj.search(cr, uid, [('type', '=', 'default'), ('state', '=', 'confirm'), ('active', '=', True)])
> + smtpserver_id = smtp_obj.search(cr, uid, [('type', '=', 'default'),
> + ('state', '=', 'confirm'),
> + ('active', '=', True)])
> if smtpserver_id:
> smtpserver_id = smtpserver_id[0]
> else:
> @@ -99,7 +104,6 @@
> state = smtp_obj.send_email(cr, uid, smtpserver_id, to, subject, body)
> return state
>
> -
> def receive_from_seur(self, cr, uid, files=[]):
> """ Recibe pedidos desde el sistema informático de Seur Logística. """
>
> @@ -129,21 +133,25 @@
> elif prodlot['order_ref'].startswith("RF"):
> obj = self.pool.get('refund.products')
> else:
> - logger.error("Order type not supported: %s" % prodlot['order_ref'])
> + logger.error("Order type not supported: %s" %
> + prodlot['order_ref'])
> continue
>
> obj.lot_delivered(cr, uid, prodlot)
> order_refs.add(prodlot['order_ref'])
> - logger.info("%s %s assigned to %s order, line %s" % (prodlot['product_code'], prodlot['lot_ref'], prodlot['order_ref'], prodlot['partial_line_id']))
> + logger.info("%s %s assigned to %s order, line %s" %
> + (prodlot['product_code'], prodlot['lot_ref'],
> + prodlot['order_ref'],
> + prodlot['partial_line_id']))
>
> f.close()
>
> if order_refs:
> logger.info("Preparing orders")
> - self.pool.get('sale.order').process_deliveries(cr, uid, filter(lambda x: x.startswith("SO"), order_refs))
> - self.pool.get('refund.products').process_deliveries(cr, uid, filter(lambda x: x.startswith("RF"), order_refs))
> + self.pool['sale.order'].process_deliveries(
> + cr, uid, filter(lambda x: x.startswith("SO"), order_refs))
> + self.pool['refund.products'].process_deliveries(
> + cr, uid, filter(lambda x: x.startswith("RF"), order_refs))
> logger.info("Sale orders prepared")
>
> return True
> -
> -delivery_carrier()
>
> === renamed file 'nayar_seur_logistica/config.py' => 'nayar_seur_logistica/models/config.py'
> === renamed file 'nayar_seur_logistica/lot.py' => 'nayar_seur_logistica/models/lot.py'
> --- nayar_seur_logistica/lot.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/lot.py 2014-07-02 10:11:55 +0000
> @@ -21,13 +21,14 @@
>
> import os.path
> from osv import osv
> -import seur_ftp
> import time
> from tools import config
> from tools.translate import _
>
> -
> -class stock_production_lot(osv.osv):
> +from . import seur_ftp
> +
> +
> +class StockProductionLot(orm.Model):
> _inherit ="stock.production.lot"
>
> def send_to_seur(self, cr, uid, ids, context=None):
> @@ -59,5 +60,3 @@
> for id in ids:
> self.log(cr, uid, id, _('Stock production lot sent to SEUR'))
> return {}
> -
> -stock_production_lot()
>
> === renamed file 'nayar_seur_logistica/product.py' => 'nayar_seur_logistica/models/product.py'
> --- nayar_seur_logistica/product.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/product.py 2014-07-02 10:11:55 +0000
> @@ -20,18 +20,21 @@
> ##############################################################################
>
> import os.path
> -from osv import osv
> -import seur_ftp
> +from openerp.osv import orm
> +from . import seur_ftp
> import time
> -from tools import config
> -from tools.translate import _
> -
> -
> -class product(osv.osv):
> - _inherit ="product.product"
> +from openerp.tools import config
> +from openerp.tools.translate import _
> +
> +
> +class Product(orm.Model):
> + _inherit = "product.product"
>
> def send_to_seur(self, cr, uid, ids, context=None):
> - """ Envía los productos seleccionados al sistema informático de Seur Logística. """
> + """
> + Envía los productos seleccionados al sistema informático de
> + Seur Logística.
> + """
>
> localtime = time.localtime()
> filename = "sia" + time.strftime("%d%m%Y%H%M", localtime) + ".dat"
> @@ -39,16 +42,20 @@
> i = 0
> while os.path.exists(full_filename):
> i += 1
> - filename = "sia" + time.strftime("%d%m%Y%H%M", localtime) + "-%s.dat" % i
> + filename = ("sia" + time.strftime("%d%m%Y%H%M", localtime) +
> + "-%s.dat" % i)
> full_filename = "%s/%s" % (config.get('seur_path'), filename)
>
> - text = "CC%s%06dPPPPNET %s\n" % (filename, int(config.get('seur_customer_id')), time.strftime("%d/%m/%Y %H:%M", localtime))
> + text = ("CC%s%06dPPPPNET %s\n" %
> + (filename, int(config.get('seur_customer_id')),
> + time.strftime("%d/%m/%Y %H:%M", localtime)))
> text += "CF%s%s\n" % (filename, len(context['active_ids']))
>
> for prod in self.browse(cr, uid, context['active_ids']):
> description = prod.name
> if prod.bom_ids:
> - components = ";".join([l.name for l in prod.bom_ids[0].bom_lines])
> + components = ";".join([l.name
> + for l in prod.bom_ids[0].bom_lines])
> for l in prod.bom_ids[0].bom_lines:
> if l.product_id.categ_id.id == 3:
> description = l.name
>
> === renamed file 'nayar_seur_logistica/refund.py' => 'nayar_seur_logistica/models/refund.py'
> --- nayar_seur_logistica/refund.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/refund.py 2014-07-02 10:11:55 +0000
> @@ -20,19 +20,24 @@
> ##############################################################################
>
> import logging
> -from osv import osv, fields
> +from openerp.osv import orm, fields
> import time
> from tools import config
> from tools import tb
> from tools.translate import _
>
>
> -class refund_products(osv.osv):
> +class RefundProducts(orm.Model):
> _inherit = "refund.products"
>
> _columns = {
> - 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('done','Done'), ('cancel', 'Cancelled')], readonly=True),
> - 'seur_state': fields.selection([('none', 'None'), ('prepared', 'Prepared'), ('sent', 'Sent'), ('received', 'Received')]),
> + 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'),
> + ('done', 'Done'), ('cancel', 'Cancelled')],
> + readonly=True),
> + 'seur_state': fields.selection([('none', 'None'),
> + ('prepared', 'Prepared'),
> + ('sent', 'Sent'),
> + ('received', 'Received')]),
> 'seur_picking_number': fields.char('Picking Number', size=15),
> 'seur_date': fields.datetime('Seur Date'),
> }
> @@ -41,73 +46,94 @@
> 'seur_state': 'none',
> }
>
> -
> def action_cancel_draft(self, cr, uid, ids, context=None):
> if len(ids) == 0:
> return False
> - ids = self.search(cr, uid, [('id', 'in', ids), ('state', '=', 'cancel')])
> - self.write(cr, uid, ids, {'state': 'draft'})
> + ids = self.search(cr, uid, [('id', 'in', ids),
> + ('state', '=', 'cancel')], context=context)
> + self.write(cr, uid, ids, {'state': 'draft'}, context=context)
> return True
>
> -
> def send_to_seur(self, cr, uid, ids, context=None):
> - """ Prepara la reposición para mandarla al sistema informático de Seur Logística. """
> + """
> + Prepara la reposición para mandarla al sistema informático de
> + Seur Logística.
> + """
>
> - sequence_obj = self.pool.get('ir.sequence')
> + sequence_obj = self.pool['ir.sequence']
>
> for refund in self.browse(cr, uid, ids):
> - num_stock_picking = sequence_obj.get(cr, uid, 'stock.picking.out')
> - self.write(cr, uid, [refund.id], {'state': 'waiting',
> - 'seur_state': 'prepared',
> - 'seur_picking_number': num_stock_picking,
> - 'seur_date': time.strftime("%Y-%m-%d %H:%M:%S")})
> + num_stock_picking = sequence_obj.get(cr, uid, 'stock.picking.out',
> + context=context)
> + self.write(cr, uid, [refund.id],
> + {'state': 'waiting', 'seur_state': 'prepared',
> + 'seur_picking_number': num_stock_picking,
> + 'seur_date': time.strftime("%Y-%m-%d %H:%M:%S")},
> + context=context)
> self.log(cr, uid, refund.id, _('Refund sent to SEUR'))
>
> return True
>
> -
> - def get_first_annexe(self, cr, uid, refund):
> - annexe_obj = self.pool.get('contract.annexe')
> + def get_first_annexe(self, cr, uid, refund, context=None):
> + annexe_obj = self.pool['contract.annexe']
> lot_id = refund.refund_product_ids[0].refund_prodlot_id.id
> - annexe_ids = annexe_obj.search(cr, uid, ['|', ('pack_production_lot_id', '=', lot_id), '|', ('production_lot_id', '=', lot_id), ('production_lot_2_id', '=', lot_id)])
> - annexe = annexe_obj.browse(cr, uid, annexe_ids[0])
> + annexe_ids = annexe_obj.search(
> + cr, uid, ['|', ('pack_production_lot_id', '=', lot_id),
> + '|', ('production_lot_id', '=', lot_id),
> + ('production_lot_2_id', '=', lot_id)],
> + context=context)
> + annexe = annexe_obj.browse(cr, uid, annexe_ids[0], context=context)
> return annexe
>
> -
> def get_partner_contact(self, cr, uid, annexe):
> """ Devuelve el nombre del contacto del destinatario """
>
> - contact = annexe.stock_move_id and annexe.stock_move_id.picking_id and annexe.stock_move_id.picking_id.sale_id and annexe.stock_move_id.picking_id.sale_id.contact_id and annexe.stock_move_id.picking_id.sale_id.contact_id.contact_id or None
> + contact = (
> + annexe.stock_move_id and annexe.stock_move_id.picking_id and
> + annexe.stock_move_id.picking_id.sale_id and
> + annexe.stock_move_id.picking_id.sale_id.contact_id and
> + annexe.stock_move_id.picking_id.sale_id.contact_id.contact_id or
> + None)
> if not contact:
> address = self.get_shipping_address(cr, uid, annexe)
> - contact = address and address.job_id and address.job_id.contact_id or None
> + contact = (address and address.job_id and
> + address.job_id.contact_id or None)
>
> if contact:
> - return ((contact.first_name if contact.first_name else '') + ' ' + contact.name).strip()
> + return ((contact.first_name if contact.first_name else '') + ' ' +
> + contact.name).strip()
> else:
> return '.'
>
> -
> def get_shipping_address(self, cr, uid, annexe):
> - address = annexe.stock_move_id and annexe.stock_move_id.picking_id and annexe.stock_move_id.picking_id.address_id or None
> + address = (
> + annexe.stock_move_id and annexe.stock_move_id.picking_id and
> + annexe.stock_move_id.picking_id.address_id or None)
> if not address:
> - addr = self.pool.get('res.partner').address_get(cr, uid, [annexe.contract_id.elevator_id.id], ['delivery'])
> - address = addr['delivery'] and self.pool.get('res.partner.address').browse(cr, uid, addr['delivery']) or None
> + addr = self.pool['res.partner'].address_get(
> + cr, uid, [annexe.contract_id.elevator_id.id], ['delivery'])
> + address = (addr['delivery'] and
> + self.pool['res.partner.address'].browse(
> + cr, uid, addr['delivery']) or None)
> return address
>
> -
> - def get_email_contact (self, cr, uid, annexe):
> - contact = annexe.stock_move_id and annexe.stock_move_id.picking_id and annexe.stock_move_id.picking_id.sale_id and annexe.stock_move_id.picking_id.sale_id.contact_id and annexe.stock_move_id.picking_id.sale_id.contact_id.contact_id or None
> + def get_email_contact(self, cr, uid, annexe):
> + contact = (
> + annexe.stock_move_id and annexe.stock_move_id.picking_id and
> + annexe.stock_move_id.picking_id.sale_id and
> + annexe.stock_move_id.picking_id.sale_id.contact_id and
> + annexe.stock_move_id.picking_id.sale_id.contact_id.contact_id or
> + None)
> if not contact:
> address = self.get_shipping_address(cr, uid, annexe)
> - contact = address and address.job_id and address.job_id.contact_id or None
> + contact = (address and address.job_id and
> + address.job_id.contact_id or None)
>
> if contact and contact.email:
> return contact.email
> else:
> shipping_address = self.get_shipping_address(cr, uid, annexe)
> - return shipping_address and shipping_address.email or ''
> -
> + return shipping_address and shipping_address.email or ''
>
> def _refund_txt_header(self, cr, uid, refund):
> annexe = self.get_first_annexe(cr, uid, refund)
> @@ -120,7 +146,7 @@
> time.strftime("%d/%m/%Y %H:%M:%S", time.strptime(refund.date, "%Y-%m-%d %H:%M:%S")),
> '{:<30}'.format(annexe.contract_id.customer_id.vat),
> '{:<40}'.format(annexe.contract_id.elevator_id.name[:40].encode("iso-8859-15")),
> - '{:<30}'.format(self.get_partner_contact(cr, uid, annexe)[:30].encode("iso-8859-15")),
> + '{:<30}'.format(self.get_partner_contact(cr, uid, annexe)[:30].encode("iso-8859-15")),
> '{:<40}'.format(shipping_address.street[:40].encode("iso-8859-15")),
> '{:<24}'.format(shipping_address.street[:24].encode("iso-8859-15")),
> '{:<15}'.format((shipping_address.phone or "")[:15]),
> @@ -137,8 +163,7 @@
> )
> return text
>
> -
> - def _refund_txt_line(self, cr, uid, line):
> + def _refund_txt_line(self, cr, uid, line):
> text = "RD%s%s000001000001%s%03d%s0 0 0 %06d 0 %s\n" % (
> 'RF'+'{:<13}'.format(line.refund_id.id),
> '{:<3}'.format(config.get('seur_customer_id')),
> @@ -150,20 +175,25 @@
> )
> return text
>
> -
> - def get_delivery(self, cr, uid):
> - """ Busca reposiciones preparadas para servir por los distribuidores externos """
> + def get_delivery(self, cr, uid, context=None):
> + """
> + Busca reposiciones preparadas para servir por los distribuidores
> + externos
> + """
>
> ids = []
> headers = []
> lines = []
> errors = []
>
> - refund_ids = self.search(cr, uid, [('state', '=', 'waiting'), ('seur_state', '=', 'prepared')])
> - for refund in self.browse(cr, uid, refund_ids):
> + refund_ids = self.search(cr, uid, [('state', '=', 'waiting'),
> + ('seur_state', '=', 'prepared')],
> + context=context)
> + for refund in self.browse(cr, uid, refund_ids, context=context):
> try:
> txt_header = self._refund_txt_header(cr, uid, refund)
> - txt_lines = [self._refund_txt_line(cr, uid, line) for line in refund.refund_product_ids]
> + txt_lines = [self._refund_txt_line(cr, uid, line)
> + for line in refund.refund_product_ids]
>
> ids.append(refund.id)
> headers.append(txt_header)
> @@ -172,79 +202,94 @@
> error_trace = tb.get_traceback()
> errors.append([refund.id, error_trace])
> logging.getLogger(self._name).error(error_trace)
> -
> -
> - return {'object': self, 'ids': ids, 'headers': headers, 'lines': lines, 'errors': errors}
> -
> -
> - def confirm_delivery(self, cr, uid, ids):
> - self.write(cr, uid, ids, {'seur_state': 'sent'})
> -
> -
> - def cancel_delivery(self, cr, uid, ids):
> - self.write(cr, uid, ids, {'state': 'cancel', 'seur_state': 'none'})
> -
> -
> - def delivery_email_body(self, cr, uid, ids):
> +
> + return {'object': self, 'ids': ids, 'headers': headers,
> + 'lines': lines, 'errors': errors}
> +
> + def confirm_delivery(self, cr, uid, ids, context=None):
> + self.write(cr, uid, ids, {'seur_state': 'sent'}, context=context)
> +
> + def cancel_delivery(self, cr, uid, ids, context=None):
> + self.write(cr, uid, ids, {'state': 'cancel', 'seur_state': 'none'},
> + context=context)
> +
> + def delivery_email_body(self, cr, uid, ids, context=None):
> text = ""
> - for refund in self.browse(cr, uid, ids):
> + for refund in self.browse(cr, uid, ids, context=context):
> annexe = self.get_first_annexe(cr, uid, refund)
> shipping_address = self.get_shipping_address(cr, uid, annexe)
> - text += "RF%s - %s - %s<br \>" % (refund.id, annexe.contract_id.elevator_id.name, shipping_address.state_id.name)
> + text += ("RF%s - %s - %s<br \>" %
> + (refund.id, annexe.contract_id.elevator_id.name,
> + shipping_address.state_id.name))
> return text
>
> -
> - def delivery_email_error(self, cr, uid, ids, error_description=""):
> + def delivery_email_error(self, cr, uid, ids, error_description="",
> + context=None):
> text = ""
> - for refund in self.browse(cr, uid, ids):
> - text += "RF%s - %s<br \>%s<br \><br \>" % (refund.id, refund.date, error_description)
> + for refund in self.browse(cr, uid, ids, context=context):
> + text += "RF%s - %s<br \>%s<br \><br \>" % (refund.id, refund.date,
> + error_description)
> return text
>
> -
> - def lot_delivered(self, cr, uid, prodlot):
> - line_obj = self.pool.get('refund.product')
> - product_obj = self.pool.get('product.product')
> - lot_obj = self.pool.get('stock.production.lot')
> -
> - refund_id = self.search(cr, uid, [('id', '=', int(prodlot['order_ref'][2:])), ('seur_state', '=', 'sent')])[0]
> - line_id = line_obj.search(cr, uid, [('refund_id', '=', refund_id), ('id%%1000', '=', prodlot['partial_line_id'])])
> - product_id = product_obj.search(cr, uid, [('default_code', '=', prodlot['product_code'])])[0]
> - lot_id = lot_obj.search(cr, uid, [('name', '=', prodlot['lot_ref']), ('product_id', '=', product_id)])[0]
> - line_obj.write(cr, uid, line_id, {'prodlot_id': lot_id})
> -
> -
> - def process_deliveries(self, cr, uid, order_refs):
> + def lot_delivered(self, cr, uid, prodlot, context=None):
> + line_obj = self.pool['refund.product']
> + product_obj = self.pool['product.product']
> + lot_obj = self.pool['stock.production.lot']
> +
> + refund_id = self.search(cr, uid,
> + [('id', '=', int(prodlot['order_ref'][2:])),
> + ('seur_state', '=', 'sent')],
> + context=context)[0]
> + line_id = line_obj.search(
> + cr, uid, [('refund_id', '=', refund_id),
> + ('id%%1000', '=', prodlot['partial_line_id'])],
> + context=context)
> + product_id = product_obj.search(
> + cr, uid, [('default_code', '=', prodlot['product_code'])],
Se coge de un archivo que llega desde SEUR
> + context=context)[0]
> + lot_id = lot_obj.search(cr, uid, [('name', '=', prodlot['lot_ref']),
> + ('product_id', '=', product_id)],
> + context=context)[0]
> + line_obj.write(cr, uid, line_id, {'prodlot_id': lot_id},
> + context=context)
> +
> + def process_deliveries(self, cr, uid, order_refs, context=None):
> logger = logging.getLogger(self._name)
>
> - refund_ids = self.search(cr, uid, [('id', 'in', [ref[2:] for ref in order_refs])])
> + refund_ids = self.search(cr, uid, [('id', 'in',
> + [ref[2:] for ref in order_refs])],
> + context=context)
>
> # Processing refunds
> logger.info("*** Processing refunds")
> - self.write(cr, uid, refund_ids, {'state': 'draft', 'seur_state': 'received'})
> + self.write(cr, uid, refund_ids,
> + {'state': 'draft', 'seur_state': 'received'},
> + context=context)
> for refund_id in refund_ids:
> - refund = self.browse(cr, uid, refund_id)
> + refund = self.browse(cr, uid, refund_id, context=context)
> self.button_done(cr, uid, [refund_id])
> - refunds = self.browse(cr, uid, refund_ids)
> + refunds = self.browse(cr, uid, refund_ids, context=context)
>
> # Repairing pickings and stock moves
> logger.info("*** Repairing pickings and stock moves")
> - picking_obj = self.pool.get('stock.picking')
> - move_obj = self.pool.get('stock.move')
> + picking_obj = self.pool['stock.picking']
> + move_obj = self.pool['stock.move']
> for refund in refunds:
> - picking_obj.write(cr, uid, [refund.picking_out_id.id], {'name': refund.seur_picking_number,
> - 'date': refund.seur_date})
> - move_ids = move_obj.search(cr, uid, [('picking_id', '=', refund.picking_out_id.id)])
> - move_obj.write(cr, uid, move_ids, {'date': refund.seur_date})
> -
> -
> -refund_products()
> -
> -
> -class refund_product(osv.osv):
> + picking_obj.write(
> + cr, uid, [refund.picking_out_id.id],
> + {'name': refund.seur_picking_number,
> + 'date': refund.seur_date}, context=context)
> + move_ids = move_obj.search(
> + cr, uid, [('picking_id', '=', refund.picking_out_id.id)],
> + context=context)
> + move_obj.write(cr, uid, move_ids, {'date': refund.seur_date},
> + context=context)
> +
> +
> +class RefundProduct(orm.Model):
> _inherit = "refund.product"
>
> _columns = {
> - 'prodlot_id': fields.many2one('stock.production.lot', 'Substitution Product Lot', select=True),
> - }
> -
> -refund_product()
> + 'prodlot_id': fields.many2one('stock.production.lot',
> + 'Substitution Product Lot', select=True),
> + }
>
> === renamed file 'nayar_seur_logistica/sale.py' => 'nayar_seur_logistica/models/sale.py'
> --- nayar_seur_logistica/sale.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/sale.py 2014-07-02 10:11:55 +0000
> @@ -23,71 +23,78 @@
> from dateutil.relativedelta import relativedelta
> import logging
> import netsvc
> -from osv import osv, fields
> +from openerp.osv import orm, fields
> import time
> from tools import config
> from tools import tb
> from tools.translate import _
>
>
> -class sale_order(osv.osv):
> +class SaleOrder(orm.Model):
> _inherit = "sale.order"
>
> _columns = {
> - 'seur_state': fields.selection([('none', 'None'), ('prepared', 'Prepared'), ('sent', 'Sent'), ('received', 'Received')], 'Seur State'),
> + 'seur_state': fields.selection([('none', 'None'),
> + ('prepared', 'Prepared'),
> + ('sent', 'Sent'),
> + ('received', 'Received')],
> + 'Seur State'),
> 'seur_picking_number': fields.char('Picking Number', size=15),
> 'seur_annexe_ship_number': fields.char('Shipping number', size=15),
> 'seur_date': fields.datetime('Seur Date'),
> - }
> + }
>
> _defaults = {
> 'seur_state': 'none',
> - }
> + }
>
> def send_to_seur(self, cr, uid, ids, context=None):
> - """ Prepara el pedido para mandarlo al sistema informático de Seur Logística. """
> + """
> + Prepara el pedido para mandarlo al sistema informático de
> + Seur Logística.
> + """
>
> - sequence_obj = self.pool.get('ir.sequence')
> + sequence_obj = self.pool['ir.sequence']
>
> for order in self.browse(cr, uid, ids):
> num_annexe_ship = sequence_obj.get(cr, uid, 'contract.annexe.ship')
> num_stock_picking = sequence_obj.get(cr, uid, 'stock.picking.out')
> - self.write(cr, uid, [order.id], {'state': 'waiting_date',
> - 'seur_state': 'prepared',
> - 'seur_picking_number': num_stock_picking,
> - 'seur_annexe_ship_number': num_annexe_ship,
> - 'seur_date': time.strftime("%Y-%m-%d %H:%M:%S")})
> + self.write(cr, uid, [order.id],
> + {'state': 'waiting_date',
> + 'seur_state': 'prepared',
> + 'seur_picking_number': num_stock_picking,
> + 'seur_annexe_ship_number': num_annexe_ship,
> + 'seur_date': time.strftime("%Y-%m-%d %H:%M:%S")
> + }, context=context)
> self.log(cr, uid, order.id, _('Sale order sent to SEUR'))
>
> return True
>
> -
> def get_partner_contact(self, order):
> """ Devuelve el nombre del contacto del destinatario """
>
> contact = order.contact_id and order.contact_id.contact_id or None
> if contact:
> - return ((contact.first_name if contact.first_name else '') + ' ' + contact.name).strip()
> + return ((contact.first_name if contact.first_name else '') +
> + ' ' + contact.name).strip()
> else:
> return '.'
>
> -
> - def get_email_contact (self, order):
> + def get_email_contact(self, order):
> email = ""
> if order.contact_id and order.contact_id.email:
> email = order.contact_id.email
> else:
> - email = order.partner_shipping_id and order.partner_shipping_id.email or ''
> + email = (order.partner_shipping_id and
> + order.partner_shipping_id.email or '')
> return email.strip()
>
> -
> def get_shipping_service(self, order):
> shipping_service = "40 "
> if order.partner_shipping_id.country_id.code != "ES":
> shipping_service = "8 "
> return shipping_service
>
> -
> def _order_txt_header(self, cr, uid, order):
> shipping_phone = order.partner_shipping_id.phone or ""
>
> @@ -117,7 +124,6 @@
> )
> return text
>
> -
> def _order_txt_line(self, cr, uid, line):
> text = "RD%s%s000001000001%s%03d%s0 0 0 %06d 0 %s\n" % (
> '{:<15}'.format(line.order_id.name),
> @@ -126,15 +132,18 @@
> line.id % 1000,
> '{:<35}'.format(line.product_id.default_code),
> line.product_uom_qty,
> - '{:<255}'.format((line.client_order_ref or "").encode("iso-8859-15")),
> + '{:<255}'.format((line.client_order_ref or
> + "").encode("iso-8859-15")),
> )
> return text
>
> -
> - def get_delivery(self, cr, uid):
> - """ Busca pedidos preparados para servir por los distribuidores externos """
> -
> - ids = self.search(cr, uid, [('state', '=', 'waiting_date'), ('seur_state', '=', 'prepared')])
> + def get_delivery(self, cr, uid, context=None):
> + """
> + Busca pedidos preparados para servir por los distribuidores externos
> + """
> +
> + ids = self.search(cr, uid, [('state', '=', 'waiting_date'),
> + ('seur_state', '=', 'prepared')])
>
> order_ids = []
> headers = []
> @@ -145,8 +154,14 @@
> for order in self.browse(cr, uid, ids):
> try:
> txt_header = self._order_txt_header(cr, uid, order)
> - line_ids = line_obj.search(cr, uid, [('order_id', '=', order.id), ('product_uom_qty', '>', 0), ('product_id.categ_id', 'in', [2, 3, 5, 7])])
> - txt_lines = [self._order_txt_line(cr, uid, line) for line in line_obj.browse(cr, uid, line_ids)]
> + line_ids = line_obj.search(cr, uid,
> + [('order_id', '=', order.id),
> + ('product_uom_qty', '>', 0),
> + ('product_id.categ_id', 'in',
> + [2, 3, 5, 7])],
> + context=context)
> + txt_lines = [self._order_txt_line(cr, uid, line)
> + for line in line_obj.browse(cr, uid, line_ids)]
>
> order_ids.append(order.id)
> headers.append(txt_header)
> @@ -154,108 +169,149 @@
> except:
> errors.append([order.id, tb.get_traceback()])
>
> - return {'object': self, 'ids': order_ids, 'headers': headers, 'lines': lines, 'errors': errors}
> -
> -
> - def confirm_delivery(self, cr, uid, ids):
> - self.write(cr, uid, ids, {'seur_state': 'sent'})
> -
> -
> - def cancel_delivery(self, cr, uid, ids):
> - self.write(cr, uid, ids, {'state': 'cancel', 'seur_state': 'none'})
> -
> + return {'object': self, 'ids': order_ids, 'headers': headers,
> + 'lines': lines, 'errors': errors}
> +
> + def confirm_delivery(self, cr, uid, ids, context=None):
> + self.write(cr, uid, ids, {'seur_state': 'sent'}, context=context)
> +
> + def cancel_delivery(self, cr, uid, ids, context=None):
> + self.write(cr, uid, ids, {'state': 'cancel', 'seur_state': 'none'},
> + context=context)
>
> def delivery_email_body(self, cr, uid, ids):
> text = ""
> for order in self.browse(cr, uid, ids):
> - text += "%s - %s - %s<br \>" % (order.name, order.elevator_partner_id.name, order.partner_shipping_id.state_id.name)
> + text += ("%s - %s - %s<br \>" %
> + (order.name, order.elevator_partner_id.name,
> + order.partner_shipping_id.state_id.name))
> return text
>
> -
> def delivery_email_error(self, cr, uid, ids, error_description=""):
> text = ""
> for order in self.browse(cr, uid, ids):
> - text += "%s - %s - %s<br \>%s<br \><br \>" % (order.name, order.elevator_partner_id.name, order.partner_shipping_id.state_id.name, error_description)
> + text += ("%s - %s - %s<br \>%s<br \><br \>" %
> + (order.name, order.elevator_partner_id.name,
> + order.partner_shipping_id.state_id.name,
> + error_description))
> return text
>
> -
> - def lot_delivered(self, cr, uid, prodlot):
> - line_obj = self.pool.get('sale.order.line')
> - product_obj = self.pool.get('product.product')
> - lot_obj = self.pool.get('stock.production.lot')
> -
> - order_id = self.search(cr, uid, [('name', '=', prodlot['order_ref']), ('seur_state', '=', 'sent')])[0]
> - line_id = line_obj.search(cr, uid, [('order_id', '=', order_id), ('id%%1000', '=', prodlot['partial_line_id'])])
> - product_id = product_obj.search(cr, uid, [('default_code', '=', prodlot['product_code'])])[0]
> - lot_id = lot_obj.search(cr, uid, [('name', '=', prodlot['lot_ref']), ('product_id', '=', product_id)])[0]
> - line_obj.write(cr, uid, line_id, {'prodlot_id': lot_id})
> -
> + def lot_delivered(self, cr, uid, prodlot, context=None):
> + line_obj = self.pool['sale.order.line']
> + product_obj = self.pool['product.product']
> + lot_obj = self.pool['stock.production.lot']
> +
> + order_id = self.search(cr, uid, [('name', '=', prodlot['order_ref']),
> + ('seur_state', '=', 'sent')],
> + context=context)[0]
> + line_id = line_obj.search(cr, uid, [('order_id', '=', order_id),
> + ('id%%1000', '=',
> + prodlot['partial_line_id'])],
> + context=context)
> + product_id = product_obj.search(
> + cr, uid, [('default_code', '=', prodlot['product_code'])],
> + context=context)[0]
> + lot_id = lot_obj.search(cr, uid, [('name', '=', prodlot['lot_ref']),
> + ('product_id', '=', product_id)],
> + context=context)[0]
> + line_obj.write(cr, uid, line_id, {'prodlot_id': lot_id},
> + context=context)
>
> def process_deliveries(self, cr, uid, order_refs, context=None):
> wf_service = netsvc.LocalService('workflow')
> logger = logging.getLogger(self._name)
>
> - order_ids = self.search(cr, uid, [('name', 'in', order_refs)])
> + order_ids = self.search(cr, uid, [('name', 'in', order_refs)],
> + context=context)
>
> # Processing orders
> logger.info("*** Processing orders")
> - self.write(cr, uid, order_ids, {'state': 'draft', 'seur_state': 'received'})
> + self.write(cr, uid, order_ids, {'state': 'draft',
> + 'seur_state': 'received'},
> + context=context)
> for order_id in order_ids:
> - wf_service.trg_validate(uid, 'sale.order', order_id, 'order_confirm', cr)
> - orders = self.browse(cr, uid, order_ids)
> + wf_service.trg_validate(uid, 'sale.order', order_id,
> + 'order_confirm', cr)
> + orders = self.browse(cr, uid, order_ids, context=context)
>
> # Repairing annexes
> logger.info("*** Repairing annexes")
> - annexe_obj = self.pool.get('contract.annexe')
> + annexe_obj = self.pool['contract.annexe']
> for order in orders:
> - annexe_ids = annexe_obj.search(cr, uid, [('sale_order_id', '=', order.id)])
> - start_billing_date = datetime.strptime(order.seur_date, '%Y-%m-%d %H:%M:%S') + relativedelta(days=+order.contract_id.start_billing_days)
> - annexe_obj.write(cr, uid, annexe_ids, {'num_annexe_ship': order.seur_annexe_ship_number,
> - 'annexe_date': order.seur_date,
> - 'shipping_date': order.seur_date,
> - 'start_billing_date': start_billing_date.strftime('%Y-%m-%d')})
> + annexe_ids = annexe_obj.search(
> + cr, uid, [('sale_order_id', '=', order.id)], context=context)
> + start_billing_date = (
> + datetime.strptime(order.seur_date, '%Y-%m-%d %H:%M:%S') +
> + relativedelta(days=+order.contract_id.start_billing_days))
> + annexe_obj.write(cr, uid, annexe_ids,
> + {'num_annexe_ship': order.seur_annexe_ship_number,
> + 'annexe_date': order.seur_date,
> + 'shipping_date': order.seur_date,
> + 'start_billing_date':
> + start_billing_date.strftime('%Y-%m-%d')},
> + context=context)
>
> # Repairing pickings
> logger.info("*** Repairing pickings")
> - picking_obj = self.pool.get('stock.picking')
> + picking_obj = self.pool['stock.picking']
> for order in orders:
> - picking_ids = picking_obj.search(cr, uid, [('origin', '=', order.name), ('type', '=', 'out')])
> - picking_obj.write(cr, uid, picking_ids, {'name': order.seur_picking_number,
> - 'date': order.seur_date})
> + picking_ids = picking_obj.search(
> + cr, uid, [('origin', '=', order.name), ('type', '=', 'out')],
> + context=context)
> + picking_obj.write(cr, uid, picking_ids, {'name':
> + order.seur_picking_number,
> + 'date': order.seur_date},
> + context=context)
>
> # Processing pickings
> logger.info("*** Processing pickings")
> - partial_obj = self.pool.get("stock.partial.picking")
> - picking_ids = picking_obj.search(cr, uid, [('origin', 'in', [o.name for o in orders]), ('type', '=', 'out')])
> - picking_obj.write(cr, uid, picking_ids, {'carrier_id': int(config.get('seur_carrier_id'))})
> + partial_obj = self.pool["stock.partial.picking"]
> + picking_ids = picking_obj.search(
> + cr, uid, [('origin', 'in', [o.name for o in orders]),
> + ('type', '=', 'out')], context=context)
> + picking_obj.write(cr, uid, picking_ids,
> + {'carrier_id': int(config.get('seur_carrier_id'))},
> + context=context)
> picking_obj.action_done(cr, uid, picking_ids)
> - partial_id = partial_obj.create(cr, uid, {}, context={'active_ids': picking_ids})
> - partial_obj.do_partial(cr, uid, [partial_id], context={'active_ids': picking_ids})
> + partial_id = partial_obj.create(cr, uid, {},
> + context={'active_ids': picking_ids})
> + partial_obj.do_partial(cr, uid, [partial_id],
> + context={'active_ids': picking_ids})
>
> # Repairing stock moves
> logger.info("*** Repairing stock moves")
> - move_obj = self.pool.get('stock.move')
> - pickings = picking_obj.browse(cr, uid, picking_ids)
> + move_obj = self.pool['stock.move']
> + pickings = picking_obj.browse(cr, uid, picking_ids, context=context)
> for picking in pickings:
> - move_ids = move_obj.search(cr, uid, [('picking_id', '=', picking.id)])
> - move_obj.write(cr, uid, move_ids, {'date': picking.date})
> + move_ids = move_obj.search(cr, uid,
> + [('picking_id', '=', picking.id)],
> + context=context)
> + move_obj.write(cr, uid, move_ids, {'date': picking.date},
> + context=context)
>
> # Invoicing pickings
> logger.info("*** Invoicing pickings")
> - onshipping_obj = self.pool.get('stock.invoice.onshipping')
> - journal_id = self.pool.get('account.journal').search(cr, uid, [('code', '=', 'SAJ')])[0]
> + onshipping_obj = self.pool['stock.invoice.onshipping']
> + journal_id = self.pool['account.journal'].search(
> + cr, uid, [('code', '=', 'SAJ')], context=context)[0]
> for picking_id in picking_ids:
> - onshipping_id = onshipping_obj.create(cr, uid, {'journal_id': journal_id}, context={'active_ids': [picking_id], 'active_id': picking_id})
> - onshipping_obj.open_invoice(cr, uid, [onshipping_id], context={'active_ids': [picking_id], 'active_id': picking_id})
> -
> + onshipping_id = onshipping_obj.create(
> + cr, uid, {'journal_id': journal_id},
> + context={'active_ids': [picking_id],
> + 'active_id': picking_id})
> + onshipping_obj.open_invoice(cr, uid, [onshipping_id],
> + context={'active_ids': [picking_id],
> + 'active_id': picking_id})
> +
> # Validating invoices
> logger.info("*** Validating invoices")
> - invoice_obj = self.pool.get('account.invoice')
> - pickings = picking_obj.read(cr, uid, picking_ids, ['name'])
> + invoice_obj = self.pool['account.invoice']
> + pickings = picking_obj.read(cr, uid, picking_ids, ['name'],
> + context=context)
> for picking in pickings:
> - invoice_ids = invoice_obj.search(cr, uid, [('origin', 'like', "%s:%%" % picking['name'])])
> + invoice_ids = invoice_obj.search(
> + cr, uid, [('origin', 'like', "%s:%%" % picking['name'])],
> + context=context)
> for invoice_id in invoice_ids:
> - wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
> -
> -
> -sale_order()
> + wf_service.trg_validate(uid, 'account.invoice', invoice_id,
> + 'invoice_open', cr)
>
> === renamed file 'nayar_seur_logistica/seur_ftp.py' => 'nayar_seur_logistica/models/seur_ftp.py'
> --- nayar_seur_logistica/seur_ftp.py 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/models/seur_ftp.py 2014-07-02 10:11:55 +0000
> @@ -26,15 +26,18 @@
> from tools import config
>
>
> -def put(cr, uid, files = []):
> - if platform.node() != config.get('prod_host') or cr.dbname != config.get('prod_db'):
> +def put(cr, uid, files=[]):
> + if (platform.node() != config.get('prod_host') or
> + cr.dbname != config.get('prod_db')):
> return False
>
> if type(files) != list:
> files = [files]
>
> logger = logging.getLogger('seur.logistica')
> - ftp_obj = FTP(config.get('seur_ftp_server'), config.get('seur_ftp_user'), config.get('seur_ftp_password'))
> + ftp_obj = FTP(config.get('seur_ftp_server'),
> + config.get('seur_ftp_user'),
> + config.get('seur_ftp_password'))
> ftp_obj.cwd('in')
>
> for file in files:
> @@ -49,12 +52,15 @@
> return True
>
>
> -def get(cr, uid, mask = ""):
> - if platform.node() != config.get('prod_host') or cr.dbname != config.get('prod_db'):
> +def get(cr, uid, mask=""):
> + if (platform.node() != config.get('prod_host') or
> + cr.dbname != config.get('prod_db')):
> return False
>
> logger = logging.getLogger('seur.logistica')
> - ftp_obj = FTP(config.get('seur_ftp_server'), config.get('seur_ftp_user'), config.get('seur_ftp_password'))
> + ftp_obj = FTP(config.get('seur_ftp_server'),
> + config.get('seur_ftp_user'),
> + config.get('seur_ftp_password'))
> ftp_obj.cwd('out')
> os.chdir(config.get('seur_path'))
>
>
> === added directory 'nayar_seur_logistica/views'
> === renamed file 'nayar_seur_logistica/automation_view.xml' => 'nayar_seur_logistica/views/automation_view.xml'
> --- nayar_seur_logistica/automation_view.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/views/automation_view.xml 2014-07-02 10:11:55 +0000
> @@ -1,100 +1,104 @@
> <?xml version="1.0" encoding="utf-8"?>
> <openerp>
> - <data>
> - <!-- Automation Search View -->
> - <record id="view_sale_order_automation_search" model="ir.ui.view">
> - <field name="name">view.sale.order.automation.search</field>
> - <field name="model">sale.order.automation</field>
> - <field name="type">search</field>
> - <field name="arch" type="xml">
> - <search string="Search Automations">
> - <field name="name"/>
> - </search>
> - </field>
> - </record>
> -
> - <!-- Automation Tree View -->
> - <record id="view_sale_order_automation_view" model="ir.ui.view">
> - <field name="name">view.sale.order.automation.tree</field>
> - <field name="model">sale.order.automation</field>
> - <field name="type">tree</field>
> - <field name="priority">1</field>
> - <field name="arch" type="xml">
> - <tree string="Automations">
> - <field name="name" />
> - </tree>
> - </field>
> - </record>
> -
> - <!-- Automation Form View-->
> - <record id="view_sale_order_automation_form" model="ir.ui.view">
> - <field name="name">view.sale.order.automation.form</field>
> - <field name="model">sale.order.automation</field>
> - <field name="type">form</field>
> - <field name="arch" type="xml">
> - <form string="Automation">
> - <group col="4" colspan="2">
> - <field name="name"/>
> - <field name="active_automation"/>
> - <field name="all_partners"/>
> - </group>
> - <notebook colspan="4">
> - <page string="Schedule">
> - <field name="schedule_ids" nolabel="1">
> - <tree editable="bottom" string="Schedule Lines">
> - <field name="from_time"/>
> - <field name="to_time"/>
> - <field name="waiting"/>
> - <field name="waiting_unit"/>
> - </tree>
> - </field>
> - </page>
> - <page string="Partners">
> - <field name="partner_ids" nolabel="1" colspan="4">
> - <tree string="Partners">
> - <field name="partner_id"/>
> - </tree>
> - </field>
> - <separator string="Partner Exceptions" colspan="4"/>
> - <field name="except_partner_ids" nolabel="1" colspan="4"/>
> - </page>
> - <page string="Products">
> - <field name="product_ids" nolabel="1"/>
> - </page>
> - </notebook>
> - </form>
> - </field>
> - </record>
> -
> - <!-- Partners Automation Form View -->
> - <record id="view_sale_order_automation_partner_form" model="ir.ui.view">
> - <field name="name">view.sale.order.automation.partner.form</field>
> - <field name="model">sale.order.automation.partner</field>
> - <field name="type">form</field>
> - <field name="arch" type="xml">
> - <form string="Partner Automation">
> - <group col="4" colspan="2">
> - <field name="partner_id"/>
> - <field name="all_branches"/>
> - </group>
> - <notebook colspan="4">
> - <page string="Branches">
> - <field domain="[('partner_id', '=', partner_id)]" name="address_ids" nolabel="1"/>
> - </page>
> - </notebook>
> - </form>
> - </field>
> - </record>
> -
> - <record id="action_sale_order_automation_form" model="ir.actions.act_window">
> - <field name="name">Sales Automation</field>
> - <field name="type">ir.actions.act_window</field>
> - <field name="res_model">sale.order.automation</field>
> - <field name="view_type">form</field>
> - <field name="view_mode">tree,form</field>
> - <field name="search_view_id" ref="view_sale_order_automation_search"/>
> - </record>
> -
> - <menuitem action="action_sale_order_automation_form" id="menu_sales_automation" parent="base.menu_sales" sequence="5"/>
> - </data>
> + <data>
> + <!-- Automation Search View -->
> + <record id="view_sale_order_automation_search" model="ir.ui.view">
> + <field name="name">view.sale.order.automation.search</field>
> + <field name="model">sale.order.automation</field>
> + <field name="arch" type="xml">
> + <search string="Search Automations">
> + <field name="name" />
> + </search>
> + </field>
> + </record>
> +
> + <!-- Automation Tree View -->
> + <record id="view_sale_order_automation_view" model="ir.ui.view">
> + <field name="name">view.sale.order.automation.tree</field>
> + <field name="model">sale.order.automation</field>
> + <field name="priority">1</field>
> + <field name="arch" type="xml">
> + <tree string="Automations">
> + <field name="name" />
> + </tree>
> + </field>
> + </record>
> +
> + <!-- Automation Form View -->
> + <record id="view_sale_order_automation_form" model="ir.ui.view">
> + <field name="name">view.sale.order.automation.form</field>
> + <field name="model">sale.order.automation</field>
> + <field name="arch" type="xml">
> + <form string="Automation">
> + <group col="4" colspan="2">
> + <field name="name" />
> + <field name="active_automation" />
> + <field name="all_partners" />
> + </group>
> + <notebook colspan="4">
> + <page string="Schedule">
> + <field name="schedule_ids" nolabel="1">
> + <tree editable="bottom" string="Schedule Lines">
> + <field name="from_time" />
> + <field name="to_time" />
> + <field name="waiting" />
> + <field name="waiting_unit" />
> + </tree>
> + </field>
> + </page>
> + <page string="Partners">
> + <field name="partner_ids" nolabel="1"
> + colspan="4">
> + <tree string="Partners">
> + <field name="partner_id" />
> + </tree>
> + </field>
> + <separator string="Partner Exceptions"
> + colspan="4" />
> + <field name="except_partner_ids"
> + nolabel="1" colspan="4" />
> + </page>
> + <page string="Products">
> + <field name="product_ids" nolabel="1" />
> + </page>
> + </notebook>
> + </form>
> + </field>
> + </record>
> +
> + <!-- Partners Automation Form View -->
> + <record id="view_sale_order_automation_partner_form"
> + model="ir.ui.view">
> + <field name="name">view.sale.order.automation.partner.form
> + </field>
> + <field name="model">sale.order.automation.partner</field>
> + <field name="arch" type="xml">
> + <form string="Partner Automation">
> + <group col="4" colspan="2">
> + <field name="partner_id" />
> + <field name="all_branches" />
> + </group>
> +<!-- <notebook colspan="4"> -->
> +<!-- <page string="Branches"> -->
> +<!-- <field domain="[('partner_id', '=', partner_id)]" -->
> +<!-- name="address_ids" nolabel="1" /> -->
> +<!-- </page> -->
> +<!-- </notebook> -->
> + </form>
> + </field>
> + </record>
> +
> + <record id="action_sale_order_automation_form" model="ir.actions.act_window">
> + <field name="name">Sales Automation</field>
> + <field name="type">ir.actions.act_window</field>
> + <field name="res_model">sale.order.automation</field>
> + <field name="view_type">form</field>
> + <field name="view_mode">tree,form</field>
> + <field name="search_view_id" ref="view_sale_order_automation_search" />
> + </record>
> +
> + <menuitem action="action_sale_order_automation_form"
> + id="menu_sales_automation" parent="base.menu_sales"
> + sequence="5" />
> + </data>
> </openerp>
>
> === renamed file 'nayar_seur_logistica/lot_view.xml' => 'nayar_seur_logistica/views/lot_view.xml'
> --- nayar_seur_logistica/lot_view.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/views/lot_view.xml 2014-07-02 10:11:55 +0000
> @@ -1,20 +1,22 @@
> <?xml version="1.0"?>
> <openerp>
> - <data>
> - <record model="ir.actions.server" id="action_send_production_lot_seur">
> - <field name="name">Send to SEUR</field>
> - <field name="type">ir.actions.server</field>
> - <field name="model_id" ref="model_stock_production_lot"/>
> - <field name="state">code</field>
> - <field name="code">action = obj.send_to_seur(context=context)</field>
> - </record>
> + <data>
> + <record model="ir.actions.server" id="action_send_production_lot_seur">
> + <field name="name">Send to SEUR</field>
> + <field name="type">ir.actions.server</field>
> + <field name="model_id" ref="model_stock_production_lot" />
> + <field name="state">code</field>
> + <field name="code">action = obj.send_to_seur(context=context)
> + </field>
> + </record>
>
> - <record model="ir.values" id="ir_send_production_lot_seur">
> - <field name="name">Send to SEUR</field>
> - <field name="model">stock.production.lot</field>
> - <field name="key2">client_action_multi</field>
> - <field name="value" eval="'ir.actions.server,%d'%action_send_production_lot_seur" />
> - <field name="object">True</field>
> - </record>
> - </data>
> + <record model="ir.values" id="ir_send_production_lot_seur">
> + <field name="name">Send to SEUR</field>
> + <field name="model">stock.production.lot</field>
> + <field name="key2">client_action_multi</field>
> + <field name="value"
> + eval="'ir.actions.server,%d'%action_send_production_lot_seur" />
> + <field name="object">True</field>
> + </record>
> + </data>
> </openerp>
>
> === renamed file 'nayar_seur_logistica/product_view.xml' => 'nayar_seur_logistica/views/product_view.xml'
> --- nayar_seur_logistica/product_view.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/views/product_view.xml 2014-07-02 10:11:55 +0000
> @@ -1,20 +1,22 @@
> <?xml version="1.0"?>
> <openerp>
> - <data>
> - <record model="ir.actions.server" id="action_send_product_seur">
> - <field name="name">Send to SEUR</field>
> - <field name="type">ir.actions.server</field>
> - <field name="model_id" ref="model_product_product"/>
> - <field name="state">code</field>
> - <field name="code">action = obj.send_to_seur(context=context)</field>
> - </record>
> + <data>
> + <record model="ir.actions.server" id="action_send_product_seur">
> + <field name="name">Send to SEUR</field>
> + <field name="type">ir.actions.server</field>
> + <field name="model_id" ref="model_product_product" />
> + <field name="state">code</field>
> + <field name="code">action = obj.send_to_seur(context=context)
> + </field>
> + </record>
>
> - <record model="ir.values" id="ir_send_product_seur">
> - <field name="name">Send to SEUR</field>
> - <field name="model">product.product</field>
> - <field name="key2">client_action_multi</field>
> - <field name="value" eval="'ir.actions.server,%d'%action_send_product_seur" />
> - <field name="object">True</field>
> - </record>
> - </data>
> + <record model="ir.values" id="ir_send_product_seur">
> + <field name="name">Send to SEUR</field>
> + <field name="model">product.product</field>
> + <field name="key2">client_action_multi</field>
> + <field name="value"
> + eval="'ir.actions.server,%d'%action_send_product_seur" />
> + <field name="object">True</field>
> + </record>
> + </data>
> </openerp>
>
> === renamed file 'nayar_seur_logistica/refund_view.xml' => 'nayar_seur_logistica/views/refund_view.xml'
> --- nayar_seur_logistica/refund_view.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/views/refund_view.xml 2014-07-02 10:11:55 +0000
> @@ -1,34 +1,37 @@
> <?xml version="1.0"?>
> <openerp>
> - <data>
> - <record model="ir.ui.view" id="view_refund_products_tree_seur">
> - <field name="name">refund.products.tree.seur</field>
> - <field name="model">refund.products</field>
> - <field name="inherit_id" ref="dos_refund_products.refund_products_tree_view"/>
> - <field name="type">tree</field>
> - <field name="arch" type="xml">
> - <tree string="Refund Products" position="replace">
> - <tree string="Refund Products" colors="grey:state=='cancel';black:state=='done';blue:state=='waiting';red:state=='draft'">
> - <field name="date"/>
> - <field name="picking_in_id"/>
> - <field name="picking_out_id"/>
> - <field name="state" string="State"/>
> - </tree>
> - </tree>
> - </field>
> - </record>
> + <data>
> + <record model="ir.ui.view" id="view_refund_products_tree_seur">
> + <field name="name">refund.products.tree.seur</field>
> + <field name="model">refund.products</field>
> + <field name="inherit_id"
> + ref="dos_refund_products.refund_products_tree_view" />
> + <field name="arch" type="xml">
> + <tree string="Refund Products" position="replace">
> + <tree string="Refund Products"
> + colors="grey:state=='cancel';black:state=='done';blue:state=='waiting';red:state=='draft'">
> + <field name="date" />
> + <field name="picking_in_id" />
> + <field name="picking_out_id" />
> + <field name="state" string="State" />
> + </tree>
> + </tree>
> + </field>
> + </record>
>
> - <record model="ir.ui.view" id="view_refund_products_form_seur">
> - <field name="name">refund.products.form.seur</field>
> - <field name="model">refund.products</field>
> - <field name="inherit_id" ref="dos_refund_products.refund_products_form_view"/>
> - <field name="type">form</field>
> - <field name="arch" type="xml">
> - <button name="button_done" position="after">
> - <button name="send_to_seur" states="draft" string="Send to SEUR" type="object" icon="gtk-go-forward"/>
> - <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
> - </button>
> - </field>
> - </record>
> - </data>
> + <record model="ir.ui.view" id="view_refund_products_form_seur">
> + <field name="name">refund.products.form.seur</field>
> + <field name="model">refund.products</field>
> + <field name="inherit_id"
> + ref="dos_refund_products.refund_products_form_view" />
> + <field name="arch" type="xml">
> + <button name="button_done" position="after">
> + <button name="send_to_seur" states="draft"
> + string="Send to SEUR" type="object" icon="gtk-go-forward" />
> + <button name="action_cancel_draft" states="cancel"
> + string="Set to Draft" type="object" icon="gtk-convert" />
> + </button>
> + </field>
> + </record>
> + </data>
> </openerp>
>
> === renamed file 'nayar_seur_logistica/sale_view.xml' => 'nayar_seur_logistica/views/sale_view.xml'
> --- nayar_seur_logistica/sale_view.xml 2014-06-11 10:23:47 +0000
> +++ nayar_seur_logistica/views/sale_view.xml 2014-07-02 10:11:55 +0000
> @@ -1,17 +1,17 @@
> <?xml version="1.0"?>
> <openerp>
> - <data>
> - <record model="ir.ui.view" id="view_order_form_seur">
> - <field name="name">sale.order.form.seur</field>
> - <field name="model">sale.order</field>
> - <field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
> - <field name="type">form</field>
> - <field name="priority">1</field>
> - <field name="arch" type="xml">
> - <button string="Advance Invoice" position="after">
> - <button name="send_to_seur" states="draft" string="Send to SEUR" type="object" icon="gtk-go-forward" />
> - </button>
> - </field>
> - </record>
> - </data>
> + <data>
> + <record model="ir.ui.view" id="view_order_form_seur">
> + <field name="name">sale.order.form.seur</field>
> + <field name="model">sale.order</field>
> + <field name="inherit_id" ref="sale_layout.view_order_form_inherit_1" />
> + <field name="priority">1</field>
> + <field name="arch" type="xml">
> + <button string="Advance Invoice" position="after">
> + <button name="send_to_seur" states="draft"
> + string="Send to SEUR" type="object" icon="gtk-go-forward" />
> + </button>
> + </field>
> + </record>
> + </data>
> </openerp>
>
--
https://code.launchpad.net/~oihanecruce/avanzosc/nayar_seur_logistica/+merge/225283
Your team Avanzosc_security is subscribed to branch lp:~avanzosc-security-team/avanzosc/72horas.