[IMP] account_voucher_payment: uncecnocile wizard to osv memory (ref: MTR)
bzr revid: mra@mra-laptop-20100623125048-33q5him723jij93g
This commit is contained in:
@@ -790,7 +790,7 @@ class account_move_line(osv.osv):
|
||||
result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu)
|
||||
if view_type != 'tree':
|
||||
return result
|
||||
|
||||
|
||||
fld = []
|
||||
fields = {}
|
||||
flds = []
|
||||
@@ -800,12 +800,12 @@ class account_move_line(osv.osv):
|
||||
|
||||
ids = journal_pool.search(cr, uid, [])
|
||||
journals = journal_pool.browse(cr, uid, ids)
|
||||
all_journal = []
|
||||
all_journal = [None]
|
||||
for journal in journals:
|
||||
all_journal.append(journal.id)
|
||||
for field in journal.view_id.columns_id:
|
||||
if not field.field in fields:
|
||||
fields[field.field] = [journal.id]
|
||||
fields[field.field] = [None, journal.id]
|
||||
fld.append((field.field, field.sequence))
|
||||
flds.append(field.field)
|
||||
else:
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
</group>
|
||||
<newline/>
|
||||
<group col="10" colspan="4">
|
||||
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self or 0}"/>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self or 0, 'normal_view':False}"/>
|
||||
<field name="period_id" widget="selection" context="{'period_id':self}"/>
|
||||
</group>
|
||||
</search>
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
import account_voucher_payment
|
||||
import account_voucher_unreconcile
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -38,8 +38,9 @@
|
||||
|
||||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
"account_voucher_payment_wizard.xml",
|
||||
"account_voucher_payment_view.xml"
|
||||
"wizard/account_voucher_unreconcile_view.xml",
|
||||
"account_voucher_payment_view.xml",
|
||||
|
||||
],
|
||||
"test" : [
|
||||
# "test/account_voucher.yml",
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<field name="inherit_id" ref="view_voucher_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="cancel_to_draft" position="before">
|
||||
<button name="%(wizard_unreconcile_voucher)d" string="Unreconcile" type="action" states="posted" icon="terp-stock_effects-object-colorize"/>
|
||||
<button name="%(action_view_account_voucher_unreconcile)d" string="Unreconcile" type="action" states="posted" icon="terp-stock_effects-object-colorize"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
id="wizard_unreconcile_voucher"
|
||||
menu="False"
|
||||
model="account.voucher"
|
||||
name="account.voucher.unreconcile"
|
||||
string="Unreconcile entries"/>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,56 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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 pooler
|
||||
|
||||
_info_form = '''<?xml version="1.0"?>
|
||||
<form string="Unreconciliation">
|
||||
<separator string="Unreconciliation transactions" colspan="4"/>
|
||||
<image name="gtk-dialog-info" colspan="2"/>
|
||||
<label string="If you unreconciliate transactions, you must also verify all the actions that are linked to those transactions because they will not be disable" colspan="2"/>
|
||||
</form>'''
|
||||
|
||||
def _trans_unrec(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
voucher = pool.get('account.voucher').browse(cr, uid, data.get('id'))
|
||||
recs = []
|
||||
for line in voucher.move_ids:
|
||||
if line.reconcile_id:
|
||||
recs = [line.reconcile_id.id]
|
||||
|
||||
for rec in recs:
|
||||
pool.get('account.move.reconcile').unlink(cr, uid, rec)
|
||||
return {}
|
||||
|
||||
class wiz_unreconcile(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch': _info_form, 'fields': {}, 'state':[('end', 'Cancel'), ('unrec', 'Unreconcile')]}
|
||||
},
|
||||
'unrec': {
|
||||
'actions': [_trans_unrec],
|
||||
'result': {'type': 'state', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wiz_unreconcile('account.voucher.unreconcile')
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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 account_voucher_unreconcile
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,46 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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
|
||||
|
||||
class account_voucher_unreconcile(osv.osv_memory):
|
||||
_name = "account.voucher.unreconcile"
|
||||
_description = "Account voucher unreconcile"
|
||||
|
||||
def trans_unrec(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
obj_voucher = self.pool.get('account.voucher')
|
||||
obj_reconcile = self.pool.get('account.move.reconcile')
|
||||
if context.get('active_id'):
|
||||
voucher = obj_voucher.browse(cr, uid, context.get('active_id'), context=context)
|
||||
recs = []
|
||||
for line in voucher.move_ids:
|
||||
if line.reconcile_id:
|
||||
recs = [line.reconcile_id.id]
|
||||
|
||||
for rec in recs:
|
||||
obj_reconcile.unlink(cr, uid, rec)
|
||||
|
||||
return {}
|
||||
|
||||
account_voucher_unreconcile()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_voucher_unreconcile" model="ir.ui.view">
|
||||
<field name="name">Account voucher unreconcile</field>
|
||||
<field name="model">account.voucher.unreconcile</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Unreconciliation">
|
||||
<separator colspan="4" string="Unreconciliation transactions" />
|
||||
<label string="If you unreconciliate transactions, you must also verify all the actions that are linked to those transactions because they will not be disable" colspan="2"/>
|
||||
<separator colspan="4"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="trans_unrec" default_focus="1" string="Unreconcile" type="object" icon="gtk-ok"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window name="Unreconcile entries"
|
||||
res_model="account.voucher.unreconcile"
|
||||
src_model="account.voucher"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="action_view_account_voucher_unreconcile"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -20,10 +20,11 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from osv import fields,osv
|
||||
from osv import orm
|
||||
import netsvc
|
||||
import time
|
||||
from tools.translate import _
|
||||
|
||||
class purchase_requisition(osv.osv):
|
||||
@@ -43,16 +44,16 @@ class purchase_requisition(osv.osv):
|
||||
'state': fields.selection([('draft','Draft'),('in_progress','In Progress'),('cancel','Cancelled'),('done','Done')], 'State', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'date_start': lambda *args: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'state': lambda *args: 'draft',
|
||||
'exclusive': lambda *args: 'multiple',
|
||||
'date_start': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'state': 'draft',
|
||||
'exclusive': 'multiple',
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
'user_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).id ,
|
||||
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.requisition'),
|
||||
}
|
||||
|
||||
|
||||
def tender_cancel(self, cr, uid, ids, context={}):
|
||||
def tender_cancel(self, cr, uid, ids, context=None):
|
||||
purchase_order_obj = self.pool.get('purchase.order')
|
||||
for purchase in self.browse(cr, uid, ids):
|
||||
for purchase_id in purchase.purchase_ids:
|
||||
@@ -61,32 +62,30 @@ class purchase_requisition(osv.osv):
|
||||
self.write(cr, uid, ids, {'state': 'cancel'})
|
||||
for (id,name) in self.name_get(cr, uid, ids):
|
||||
message = _('Tender') + " '" + name + "' "+ _("is cancelled")
|
||||
self.log(cr, uid, id, message)
|
||||
self.log(cr, uid, id, message)
|
||||
return True
|
||||
def tender_in_progress(self, cr, uid, ids, context={}):
|
||||
def tender_in_progress(self, cr, uid, ids, context=None):
|
||||
for quotations in self.browse(cr, uid, ids):
|
||||
if not quotations.purchase_ids:
|
||||
raise osv.except_osv(_('Purchase order required'),('You should have atleast one purchase order line defined for this tender'))
|
||||
self.write(cr, uid, ids, {'state':'in_progress'} ,context=context)
|
||||
for (id,name) in self.name_get(cr, uid, ids):
|
||||
message = _('Tender') + " '" + name + "' "+ _(" is In Progress")
|
||||
self.log(cr, uid, id, message)
|
||||
self.log(cr, uid, id, message)
|
||||
return True
|
||||
def tender_reset(self, cr, uid, ids, context={}):
|
||||
def tender_reset(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'draft'})
|
||||
for (id,name) in self.name_get(cr, uid, ids):
|
||||
message = _('Tender') + " '" + name + "' "+ _("is in draft state")
|
||||
self.log(cr, uid, id, message)
|
||||
self.log(cr, uid, id, message)
|
||||
return True
|
||||
def tender_done(self, cr, uid, ids, context={}):
|
||||
def tender_done(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
|
||||
for (id,name) in self.name_get(cr, uid, ids):
|
||||
message = _('Tender') + " '" + name + "' "+ _("is done")
|
||||
self.log(cr, uid, id, message)
|
||||
self.log(cr, uid, id, message)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
purchase_requisition()
|
||||
|
||||
class purchase_requisition_line(osv.osv):
|
||||
@@ -102,7 +101,7 @@ class purchase_requisition_line(osv.osv):
|
||||
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade')
|
||||
}
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id,product_uom_id, context={}):
|
||||
def onchange_product_id(self, cr, uid, ids, product_id,product_uom_id, context=None):
|
||||
|
||||
""" Changes UoM and name if product_id changes.
|
||||
@param name: Name of the field
|
||||
@@ -147,7 +146,7 @@ class product_product(osv.osv):
|
||||
'purchase_requisition': fields.boolean('Purchase Requisition', help="Check this box so that requisitions generates purchase requisitions instead of directly requests for quotations.")
|
||||
}
|
||||
_defaults = {
|
||||
'purchase_requisition': lambda *args: False
|
||||
'purchase_requisition': False
|
||||
}
|
||||
product_product()
|
||||
|
||||
@@ -174,3 +173,5 @@ class procurement_order(osv.osv):
|
||||
})
|
||||
return res
|
||||
procurement_order()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,16 +15,17 @@
|
||||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from mx import DateTime
|
||||
|
||||
from osv import fields, osv
|
||||
from service import web_services
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from mx import DateTime
|
||||
from osv.orm import browse_record, browse_null
|
||||
|
||||
class purchase_requisition_partner(osv.osv_memory):
|
||||
@@ -33,38 +34,37 @@ class purchase_requisition_partner(osv.osv_memory):
|
||||
_columns = {
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', required=True,domain=[('supplier', '=', True)]),
|
||||
'partner_address_id':fields.many2one('res.partner.address', 'Address', required=True),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
res = super(purchase_requisition_partner, self).view_init(cr, uid, fields_list, context=context)
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
tender = self.pool.get('purchase.requisition').browse(cr, uid, record_id)
|
||||
if not tender.line_ids:
|
||||
raise osv.except_osv('Error!','No Product in Tender')
|
||||
raise osv.except_osv('Error!','No Product in Tender')
|
||||
True
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id):
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['default'])
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
return {'value':{'partner_address_id': addr['default']}}
|
||||
|
||||
|
||||
def create_order(self, cr, uid, ids, context):
|
||||
"""
|
||||
"""
|
||||
To Create a purchase orders .
|
||||
|
||||
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: the ID or list of IDs
|
||||
@param context: A standard dictionary
|
||||
@param ids: the ID or list of IDs
|
||||
@param context: A standard dictionary
|
||||
@return: {}
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
record_ids = context and context.get('active_ids', False)
|
||||
if record_ids:
|
||||
data = self.read(cr, uid, ids)
|
||||
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
|
||||
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
|
||||
order_obj = self.pool.get('purchase.order')
|
||||
order_line_obj = self.pool.get('purchase.order.line')
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
@@ -72,29 +72,29 @@ class purchase_requisition_partner(osv.osv_memory):
|
||||
pricelist_obj = self.pool.get('product.pricelist')
|
||||
prod_obj = self.pool.get('product.product')
|
||||
tender_obj = self.pool.get('purchase.requisition')
|
||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||
partner_id = data[0]['partner_id']
|
||||
|
||||
|
||||
supplier_data = partner_obj.browse(cr, uid,[ partner_id])[0]
|
||||
|
||||
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
|
||||
list_line=[]
|
||||
purchase_order_line={}
|
||||
for tender in tender_obj.browse(cr, uid, record_ids):
|
||||
for line in tender.line_ids:
|
||||
for line in tender.line_ids:
|
||||
partner_list = sorted([(partner.sequence, partner) for partner in line.product_id.seller_ids if partner])
|
||||
partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False
|
||||
uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False
|
||||
uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False
|
||||
newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S')
|
||||
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
|
||||
delay = partner_rec and partner_rec.delay or False
|
||||
newdate = newdate -(delay or DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
|
||||
partner = partner_rec and partner_rec.name or supplier_data
|
||||
pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id or False
|
||||
pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id or False
|
||||
price = pricelist_obj.price_get(cr, uid, [pricelist_id], line.product_id.id, line.product_qty, False, {'uom': uom_id})[pricelist_id]
|
||||
product = prod_obj.browse(cr, uid, line.product_id.id, context=context)
|
||||
|
||||
|
||||
|
||||
|
||||
purchase_order_line= {
|
||||
'name': product.partner_ref,
|
||||
'product_qty': line.product_qty,
|
||||
@@ -108,14 +108,14 @@ class purchase_requisition_partner(osv.osv_memory):
|
||||
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
|
||||
purchase_order_line.update({
|
||||
'taxes_id': [(6,0,taxes)]
|
||||
})
|
||||
})
|
||||
list_line.append(purchase_order_line)
|
||||
purchase_id = order_obj.create(cr, uid, {
|
||||
'origin': tender.purchase_ids and tender.purchase_ids[0].origin or tender.name,
|
||||
'partner_id': partner_id,
|
||||
'partner_address_id': address_id,
|
||||
'pricelist_id': pricelist_id,
|
||||
'location_id': tender.purchase_ids and tender.purchase_ids[0].location_id.id or line.product_id.product_tmpl_id.property_stock_production.id,
|
||||
'location_id': tender.purchase_ids and tender.purchase_ids[0].location_id.id or line.product_id.product_tmpl_id.property_stock_production.id,
|
||||
'company_id': tender.company_id.id,
|
||||
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
|
||||
'requisition_id':tender.id,
|
||||
@@ -124,9 +124,11 @@ class purchase_requisition_partner(osv.osv_memory):
|
||||
for order_line in list_line:
|
||||
order_line.update({
|
||||
'order_id': purchase_id
|
||||
})
|
||||
})
|
||||
order_line_obj.create(cr,uid,order_line)
|
||||
return {}
|
||||
return {}
|
||||
|
||||
purchase_requisition_partner()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user