[merge] ftp deactivation branch, thanks greg-apieum
bzr revid: xmo@tinyerp.com-20100224111124-bjnvavci8a6vpxlk
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,7 +15,7 @@
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
@@ -36,7 +36,7 @@ class account_invoice(osv.osv):
|
||||
_defaults = {
|
||||
'price_type': lambda *a: 'tax_excluded',
|
||||
}
|
||||
|
||||
|
||||
def refund(self, cr, uid, ids, date=None, period_id=None, description=None):
|
||||
map_old_new = {}
|
||||
refund_ids = []
|
||||
@@ -44,12 +44,12 @@ class account_invoice(osv.osv):
|
||||
new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description)
|
||||
refund_ids += new_id
|
||||
map_old_new[old_inv_id] = new_id[0]
|
||||
|
||||
|
||||
for old_inv_id in map_old_new.keys():
|
||||
old_inv_record = self.read(cr, uid, [old_inv_id], ['price_type'])[0]['price_type']
|
||||
self.write(cr, uid, [map_old_new[old_inv_id]], {'price_type' : old_inv_record})
|
||||
return refund_ids
|
||||
|
||||
|
||||
account_invoice()
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
@@ -156,16 +156,16 @@ class account_invoice_line(osv.osv):
|
||||
else:
|
||||
return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None):
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
|
||||
# note: will call product_id_change_unit_price_inv with context...
|
||||
|
||||
# Temporary trap, for bad context that came from koo:
|
||||
# Temporary trap, for bad context that came from koo:
|
||||
# if isinstance(context, str):
|
||||
# print "str context:", context
|
||||
|
||||
ctx = (context and context.copy()) or {}
|
||||
ctx.update({'price_type': ctx.get('price_type','tax_excluded')})
|
||||
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context=ctx)
|
||||
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=ctx)
|
||||
account_invoice_line()
|
||||
|
||||
class account_invoice_tax(osv.osv):
|
||||
@@ -180,7 +180,7 @@ class account_invoice_tax(osv.osv):
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
cur = inv.currency_id
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
|
||||
|
||||
for line in inv.invoice_line:
|
||||
data = self.pool.get('account.invoice.line')._amount_line2(cr, uid, [line.id], [], [], context)[line.id]
|
||||
for tax in data['data']:
|
||||
@@ -218,7 +218,7 @@ class account_invoice_tax(osv.osv):
|
||||
t['amount'] = cur_obj.round(cr, uid, cur, t['amount'])
|
||||
t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount'])
|
||||
t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount'])
|
||||
|
||||
|
||||
return tax_grouped
|
||||
account_invoice_tax()
|
||||
|
||||
|
||||
@@ -2,5 +2,16 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard name="wizard.invoice.membership.unpaid"
|
||||
id="invoice_membership_unpaid"
|
||||
model="res.partner"
|
||||
keyword="client_action_multi"
|
||||
string="List Unpaid Partners"
|
||||
menu="False" />
|
||||
|
||||
<menuitem name="List Unpaid Partners" id="menu_unpaid_membership"
|
||||
action="invoice_membership_unpaid" type="wizard"
|
||||
parent="menu_member" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,10 +15,11 @@
|
||||
# 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 invoice_membership
|
||||
import unpaid_partner_invoice
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# -*- 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 pooler
|
||||
|
||||
wizard_arch= """<?xml version="1.0"?>
|
||||
<form string="Choose invoice details">
|
||||
<field
|
||||
name="product"
|
||||
domain="[('membership','=','True')]"
|
||||
context="product='membership_product'"
|
||||
/>
|
||||
</form>"""
|
||||
|
||||
def _invoice_membership(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
partners = []
|
||||
cr.execute('''select p.id from res_partner as p \
|
||||
left join account_invoice as i on p.id=i.partner_id \
|
||||
left join account_invoice_line as il on i.id=il.invoice_id \
|
||||
left join product_product as pr on pr.id=il.product_id \
|
||||
where i.state = 'open' and pr.id=%s \
|
||||
group by p.id''' % (data['form']['product']))
|
||||
map(lambda x: partners.append(x[0]),cr.fetchall())
|
||||
result = pool.get('ir.model.data')._get_id(cr, uid, 'base', 'view_res_partner_filter')
|
||||
res = pool.get('ir.model.data').read(cr, uid, result, ['res_id'])
|
||||
value = {
|
||||
'domain': [('id', 'in', partners)],
|
||||
'name': 'Unpaid Partners',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'res.partner',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id' : partners,
|
||||
'search_view_id' : res['res_id']
|
||||
}
|
||||
return value
|
||||
|
||||
class wizard_unpaid_inv(wizard.interface):
|
||||
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result' : {
|
||||
'type' : 'form',
|
||||
'arch' : wizard_arch,
|
||||
'fields' : {
|
||||
'product': {
|
||||
'string': 'Membership product',
|
||||
'type': 'many2one',
|
||||
'relation': 'product.product',
|
||||
'help': 'Select Membership product',
|
||||
'required': True
|
||||
},
|
||||
},
|
||||
'state' : [('end', 'Cancel'),('ok', 'Unpaid Partners') ]}
|
||||
},
|
||||
'ok' : {
|
||||
'actions' : [],
|
||||
'result' : {'type' : 'action', 'action': _invoice_membership, 'state' : 'end'},
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
wizard_unpaid_inv("wizard.invoice.membership.unpaid")
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
+41
-29
@@ -1432,26 +1432,27 @@ class stock_move(osv.osv):
|
||||
return super(stock_move, self).unlink(
|
||||
cr, uid, ids, context=context)
|
||||
|
||||
def split_lines(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):
|
||||
def _create_lot(self, cr, uid, ids, product_id, prefix=False):
|
||||
prodlot_obj = self.pool.get('stock.production.lot')
|
||||
ir_sequence_obj = self.pool.get('ir.sequence')
|
||||
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
|
||||
if not sequence:
|
||||
raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
ref = ','.join(map(lambda x:str(x),ids))
|
||||
if prodlot.ref:
|
||||
ref = '%s, %s' % (prodlot.ref, ref)
|
||||
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
|
||||
return prodlot_id
|
||||
|
||||
def split_lines(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):
|
||||
|
||||
|
||||
if quantity <= 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
|
||||
|
||||
res = []
|
||||
|
||||
def _create_lot(move_id, product_id):
|
||||
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
|
||||
if not sequence:
|
||||
raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
ref = '%d' % (move_id)
|
||||
if prodlot.ref:
|
||||
ref = '%s, %s' % (prodlot.ref, ref)
|
||||
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
|
||||
return prodlot_id
|
||||
res = []
|
||||
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if split_by_qty <= 0 or quantity == 0:
|
||||
@@ -1466,24 +1467,32 @@ class stock_move(osv.osv):
|
||||
'product_qty': split_by_qty,
|
||||
'product_uos_qty': uos_qty,
|
||||
}
|
||||
for idx in range(int(quantity//split_by_qty)):
|
||||
current_move = self.copy(cr, uid, move.id, {'state': move.state})
|
||||
for idx in range(int(quantity//split_by_qty)):
|
||||
if not idx and move.product_qty<=quantity:
|
||||
current_move = move.id
|
||||
else:
|
||||
current_move = self.copy(cr, uid, move.id, {'state': move.state})
|
||||
res.append(current_move)
|
||||
if with_lot:
|
||||
update_val['prodlot_id'] = _create_lot(current_move, move.product_id.id)
|
||||
update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id)
|
||||
|
||||
self.write(cr, uid, [current_move], update_val)
|
||||
|
||||
|
||||
if quantity_rest > 0:
|
||||
if quantity_rest > 0:
|
||||
idx = int(quantity//split_by_qty)
|
||||
update_val['product_qty'] = quantity_rest
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
current_move = self.copy(cr, uid, move.id, {'state': move.state})
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
if not idx and move.product_qty<=quantity:
|
||||
current_move = move.id
|
||||
else:
|
||||
current_move = self.copy(cr, uid, move.id, {'state': move.state})
|
||||
|
||||
res.append(current_move)
|
||||
|
||||
|
||||
if with_lot:
|
||||
update_val['prodlot_id'] = _create_lot(current_move, move.product_id.id)
|
||||
update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id)
|
||||
|
||||
self.write(cr, uid, [current_move], update_val)
|
||||
return res
|
||||
@@ -1519,7 +1528,7 @@ class stock_move(osv.osv):
|
||||
default_val.update({'location_dest_id':location_dest_id})
|
||||
if location_id:
|
||||
default_val.update({'location_id':location_id})
|
||||
|
||||
|
||||
if move.product_id.track_production and location_id:
|
||||
res += self.split_lines(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
|
||||
else:
|
||||
@@ -1533,13 +1542,16 @@ class stock_move(osv.osv):
|
||||
|
||||
else:
|
||||
quantity_rest = quantity
|
||||
uos_qty_rest = uos_qty
|
||||
res += [move.id]
|
||||
|
||||
update_val = {}
|
||||
update_val['product_qty'] = quantity_rest
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
self.write(cr, uid, [move.id], update_val)
|
||||
uos_qty_rest = uos_qty
|
||||
|
||||
if move.product_id.track_production and location_id:
|
||||
res += self.split_lines(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
|
||||
else:
|
||||
res += [move.id]
|
||||
update_val = {}
|
||||
update_val['product_qty'] = quantity_rest
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
self.write(cr, uid, [move.id], update_val)
|
||||
|
||||
if consume:
|
||||
self.action_done(cr, uid, res)
|
||||
|
||||
Reference in New Issue
Block a user