[Merge] branch merged with lp:~openerp-dev/openobject-addons/sbh-dev-addons1

bzr revid: mso@mso-20100519073112-kdsybs0vglo8n9kx
This commit is contained in:
mso 2010-05-19 13:01:12 +05:30
commit 4a78836f9e
10 changed files with 127 additions and 102 deletions

View File

@ -47,6 +47,7 @@
'update_xml': [
'wizard/sale_make_invoice_advance.xml',
'wizard/sale_line_invoice.xml',
'wizard/sale_make_invoice.xml',
'security/sale_security.xml',
'security/ir.model.access.csv',
'company_view.xml',

View File

@ -19,8 +19,9 @@
#
##############################################################################
#remaining make_invoice
import sale_make_invoice
import sale_line_invoice
import sale_make_invoice_advance
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,96 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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/>.
#
##############################################################################
import wizard
import netsvc
import pooler
invoice_form = """<?xml version="1.0"?>
<form string="Create invoices">
<separator colspan="4" string="Do you really want to create the invoices ?" />
<field name="grouped" />
<field name="invoice_date" />
</form>
"""
invoice_fields = {
'grouped' : {'string':'Group the invoices', 'type':'boolean', 'default': lambda x,y,z: False},
'invoice_date': {'string': 'Invoiced date', 'type':'date' }
}
ack_form = """<?xml version="1.0"?>
<form string="Create invoices">
<separator string="Invoices created" />
</form>"""
ack_fields = {}
def _makeInvoices(self, cr, uid, data, context):
pool_obj = pooler.get_pool(cr.dbname)
mod_obj = pool_obj.get('ir.model.data')
order_obj = pool_obj.get('sale.order')
newinv = []
order_obj.action_invoice_create(cr, uid, data['ids'], data['form']['grouped'], date_inv = data['form']['invoice_date'])
for id in data['ids']:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
for o in order_obj.browse(cr, uid, data['ids'], context):
for i in o.invoice_ids:
newinv.append(i.id)
act_obj = pool_obj.get('ir.actions.act_window')
xml_id='action_invoice_tree5'
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
result = act_obj.read(cr, uid, id)
result['domain'] ="[('id','in', ["+','.join(map(str,newinv))+"])]"
return result
#return {
# 'domain': "[('id','in', ["+','.join(map(str,newinv))+"])]",
# 'name': 'Invoices',
# 'view_type': 'form',
# 'view_mode': 'tree,form',
# 'res_model': 'account.invoice',
# 'view_id': False,
# 'context': "{'type':'out_refund'}",
# 'type': 'ir.actions.act_window'
#}
#return {}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]}
},
'invoice' : {
'actions' : [_makeInvoices],
'result' : {'type': 'state', 'state': 'end'}
},
}
make_invoice("sale.order.make_invoice")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,74 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 osv import fields, osv
from service import web_services
from tools.translate import _
import ir
import netsvc
class sale_make_invoice(osv.osv_memory):
_name = "sale.make.invoice"
_description = "Sale Make Invoice"
_columns = {
'grouped': fields.boolean('Group the invoices'),
'invoice_date':fields.date('Invoice Date'),
}
_default = {
'grouped' : lambda *a: False
}
def view_init(self, cr, uid, fields_list, context=None):
record_id = context and context.get('active_id', False)
order = self.pool.get('sale.order').browse(cr, uid, record_id)
if order.state=='draft':
raise osv.except_osv(_('Warning !'),'You can not create invoice when sale order is not confirmed.')
return False
def make_invoices(self, cr, uid, ids, context={}):
order_obj = self.pool.get('sale.order')
newinv = []
data=self.read(cr,uid,ids)[0]
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'),[]), data['grouped'],date_inv = data['invoice_date'])
wf_service = netsvc.LocalService("workflow")
for id in context.get(('active_ids'),[]):
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
for o in order_obj.browse(cr, uid, context.get(('active_ids'),[]), context):
for i in o.invoice_ids:
newinv.append(i.id)
mod_obj =self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'domain': "[('id','in', ["+','.join(map(str,newinv))+"])]",
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['id']
}
sale_make_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_order_make_invoice" model="ir.ui.view">
<field name="name">Create invoices</field>
<field name="model">sale.make.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create invoices">
<separator colspan="4" string="Do you really want to create the invoices ?" />
<field name="grouped" />
<field name="invoice_date"/>
<separator string="" colspan="6" />
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="make_invoices" string="Create Invoices" type="object" icon="gtk-ok"/>
</form>
</field>
</record>
<act_window name="Make Invoices"
res_model="sale.make.invoice"
src_model="sale.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_sale_order_make_invoice"/>
</data>
</openerp>

View File

@ -24,7 +24,7 @@ from tools.translate import _
import ir
import netsvc
import pooler
import wizard
class sale_advance_payment_inv(osv.osv_memory):

View File

@ -44,7 +44,7 @@ class report_stock_move(osv.osv):
'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
\nThe state is \'Waiting\' if the move is waiting for another one.'),
'day_diff':fields.integer('Expected Performance',readonly=True),
}
def init(self, cr):
@ -56,6 +56,7 @@ class report_stock_move(osv.osv):
to_char(date_trunc('day',m.date_planned), 'YYYY') as year,
to_char(date_trunc('day',m.date_planned), 'MM') as month,
to_char(date_trunc('day',m.date_planned), 'YYYY-MM-DD') as day,
(date(m.date_planned)-date(m.date_expected)) as day_diff,
m.address_id as partner_id,
m.location_id as location_id,
m.location_dest_id as location_dest_id,
@ -69,6 +70,6 @@ class report_stock_move(osv.osv):
m.product_id=pp.id and pp.product_tmpl_id=pt.id
group by
m.id, m.product_id,m.address_id, m.location_id, m.location_dest_id,
m.date_planned, m.state, m.product_uom,pt.standard_price )
m.date_planned, m.state, m.product_uom,pt.standard_price,m.date_expected )
""")
report_stock_move()

View File

@ -8,6 +8,7 @@
<field name="arch" type="xml">
<tree string="Stock Orders Statistics">
<field name="date_planned"/>
<field name="day_diff"/>
<field name="year" invisible="1" />
<field name="month" invisible="1"/>
<field name="day" invisible="1"/>

View File

@ -1191,7 +1191,7 @@ class stock_move(osv.osv):
'date': fields.datetime('Created Date'),
'date_planned': fields.datetime('Date', required=True, help="Scheduled date for the movement of the products or real date if the move is done."),
'date_expected': fields.datetime('Date Expected', readonly=True,required=True, help="Scheduled date for the movement of the products"),
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
'product_qty': fields.float('Quantity', required=True),
@ -1269,7 +1269,8 @@ class stock_move(osv.osv):
'scraped' : lambda *a: False,
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.move', context=c)
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.move', context=c),
'date_expected': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
}
def copy(self, cr, uid, id, default=None, context={}):

View File

@ -318,6 +318,7 @@
<field name="location_dest_id" select="1"/>
<field name="date" select="1"/>
<field name="date_planned" select="1" string="Date"/>
<field name="date_expected" select="1" string="Date Expected"/>
<field name="state"/>
</tree>
</field>
@ -340,6 +341,7 @@
<field name="location_dest_id" select="1"/>
<field name="date" select="1"/>
<field name="date_planned" select="1" string="Date"/>
<field name="date_expected" select="1" string="Date Expected"/>
<field name="state"/>
</tree>
</field>
@ -623,6 +625,7 @@
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
<field name="date_expected" select="1" string="Date Expected"/>
<field name="state"/>
<button
name="%(stock.track_line)d"
@ -649,6 +652,7 @@
<field colspan="4" invisible="1" name="name"/>
<field invisible="1" name="date"/>
<field name="date_planned"/>
<field name="date_expected" select="1" string="Date Expected"/>
<field name="address_id" context="{'contact_display':'partner'}"/>
<field groups="base.group_extended" name="product_packaging"/>
<field name="prodlot_id" groups="base.group_extended"
@ -773,6 +777,7 @@
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
<field name="date_expected" select="1" string="Date Expected"/>
<field name="state"/>
<button
name="%(stock.track_line)d"
@ -799,6 +804,7 @@
<field colspan="4" invisible="1" name="name"/>
<field invisible="1" name="date"/>
<field name="date_planned"/>
<field name="date_expected" string="Date Expected"/>
<field groups="base.group_extended" name="product_packaging"/>
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
@ -951,6 +957,7 @@
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
<field name="date_expected" string="Date Expected"/>
<field name="state"/>
<button
name="%(stock.track_line)d"
@ -977,6 +984,7 @@
<field colspan="4" invisible="1" name="name"/>
<field invisible="1" name="date"/>
<field name="date_planned"/>
<field name="date_expected" string="Date Expected"/>
<field groups="base.group_extended" name="product_packaging"/>
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
@ -1151,6 +1159,7 @@
<field groups="product.group_uos" name="product_uos_qty"/>
<field colspan="4" invisible="1" name="name" />
<field groups="base.group_extended" name="date_planned"/>
<field name="date_expected" groups="base.group_extended" string="Date Expected"/>
<newline/>
<newline/>
<field groups="base.group_extended" name="product_packaging"/>
@ -1314,6 +1323,7 @@
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
<field name="date_expected"/>
<field name="state"/>
</tree>
</field>
@ -1352,6 +1362,7 @@
<separator string="Dates &amp; Priority" colspan="2" />
<field name="date"/>
<field name="date_planned"/>
<field name="date_expected"/>
<field name="priority"/>
</group>
@ -1437,6 +1448,7 @@
<field name="product_uom" string="Uint Of Measure"/>
<field name="prodlot_id" string="Lot" groups="base.group_extended"/>
<field name="date_planned"/>
<field name="date_expected"/>
<field name="backorder_id" groups="base.group_extended"/>
<field name="state"/>
<button name="%(action_partial_move)d" string="Partial" type="action" states="assigned" icon="gtk-justify-fill"/>
@ -1466,6 +1478,7 @@
<field name="date"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="date_planned"/>
<field name="date_expected"/>
<field name="priority"/>
<field name="address_id" context="{'contact_display':'partner'}"/>
<newline/>