[FIX] invoice on shipping wizard, not finished yet

bzr revid: fp@openerp.com-20130804161035-ds2tsx9its11fusm
This commit is contained in:
Fabien Pinckaers
2013-08-04 18:10:35 +02:00
parent c19419b6b6
commit 934be97ff6
4 changed files with 14 additions and 40 deletions
-2
View File
@@ -685,8 +685,6 @@ class sale_order(osv.osv):
order.write(val)
return True
# TODO add a field price_unit_uos
# - update it on change product and unit price
# - use it in report if there is a uos
+5 -2
View File
@@ -110,9 +110,12 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='do_prepare_partial']" position="after">
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice/Refund" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" class="oe_highlight" groups="base.group_user"/>
<field name="invoice_state" string="Invoice Control" groups="account.group_account_invoice" attrs="{'invisible':[('invoice_state', '=', 'none')]}"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice/Refund" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','&lt;&gt;','2binvoiced')]}" type="action" class="oe_highlight" groups="base.group_user"/>
</xpath>
<xpath expr="//field[@name='move_type']" position="after">
<field name="invoice_state" groups="account.group_account_invoice"/>
</xpath>
</field>
</record>
+4 -1
View File
@@ -51,7 +51,10 @@ class stock_picking(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
], string="Invoice Control", required=True,
store={'procurement.order': (__get_picking_procurement, ['invoice_state'], 10)},
store={
'procurement.order': (__get_picking_procurement, ['invoice_state'], 10),
'stock.picking': (lambda self, cr, uid, ids, c={}: uid, ['state'], 10)
},
),
}
_defaults = {
@@ -20,11 +20,9 @@
##############################################################################
from openerp.osv import fields, osv
from openerp.tools.translate import _
class stock_invoice_onshipping(osv.osv_memory):
def _get_journal(self, cr, uid, context=None):
res = self._get_journal_id(cr, uid, context=context)
if res:
@@ -34,50 +32,22 @@ class stock_invoice_onshipping(osv.osv_memory):
def _get_journal_id(self, cr, uid, context=None):
if context is None:
context = {}
model = context.get('active_model')
if not model or 'stock.picking' not in model:
return []
model_pool = self.pool[model]
journal_obj = self.pool.get('account.journal')
res_ids = context and context.get('active_ids', [])
value = journal_obj.search(cr, uid, [('type', 'in',('sale','sale_Refund'))])
vals = []
browse_picking = model_pool.browse(cr, uid, res_ids, context=context)
for pick in browse_picking:
if not pick.move_lines:
continue
src_usage = pick.move_lines[0].location_id.usage
dest_usage = pick.move_lines[0].location_dest_id.usage
type = pick.type
if type == 'out' and dest_usage == 'supplier':
journal_type = 'purchase_refund'
elif type == 'out' and dest_usage == 'customer':
journal_type = 'sale'
elif type == 'in' and src_usage == 'supplier':
journal_type = 'purchase'
elif type == 'in' and src_usage == 'customer':
journal_type = 'sale_refund'
else:
journal_type = 'sale'
value = journal_obj.search(cr, uid, [('type', '=',journal_type )])
for jr_type in journal_obj.browse(cr, uid, value, context=context):
t1 = jr_type.id,jr_type.name
if t1 not in vals:
vals.append(t1)
for jr_type in journal_obj.browse(cr, uid, value, context=context):
t1 = jr_type.id,jr_type.name
if t1 not in vals:
vals.append(t1)
return vals
_name = "stock.invoice.onshipping"
_description = "Stock Invoice Onshipping"
_columns = {
'journal_id': fields.selection(_get_journal_id, 'Destination Journal',required=True),
'group': fields.boolean("Group by partner"),
'invoice_date': fields.date('Invoiced date'),
}
_defaults = {
'journal_id' : _get_journal,
}