[MERGE] merged latest improvements from Warehouse development branch
bzr revid: odo@openerp.com-20101015134714-hvoj969qygiicrqu
This commit is contained in:
commit
8dfe323a4d
|
@ -122,36 +122,23 @@
|
|||
I check that an entry gets created related to stock move.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
from tools.translate import _
|
||||
pur_id1=self.browse(cr, uid, ref("purchase_order_po2"))
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
|
||||
pick_id = picking_obj.browse(cr, uid, ids)[0]
|
||||
move_obj = self.pool.get('stock.move')
|
||||
search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
|
||||
assert search_id, _('No Incoming Product!')
|
||||
-
|
||||
I check that Traceability moves are created.
|
||||
assert search_id, 'No Incoming Product!'
|
||||
-
|
||||
Then I create an invoice from picking by clicking on "Create Invoice" wizard
|
||||
-
|
||||
I create stock invoice on shipping entry.
|
||||
-
|
||||
!record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_0}:
|
||||
invoice_date: '2010-05-11'
|
||||
journal_id: account.bank_journal
|
||||
type: in_invoice
|
||||
-
|
||||
I create Invoice.
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
pur_obj=self.pool.get('purchase.order')
|
||||
pur_obj=self.pool.get('purchase.order')
|
||||
pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2"))
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
|
||||
self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_0")], {"lang": "en_US",
|
||||
"tz": False, "search_default_approved": 1, "active_model": "stock.picking",
|
||||
"active_ids": ids, "active_id": ids[0], })
|
||||
pick_ids = [x.id for x in pur_id1.picking_ids]
|
||||
id = self.create(cr, uid, {'invoice_date': '2010-05-11', 'journal_id': ref('account.expenses_journal')},
|
||||
{'active_ids': pick_ids})
|
||||
self.create_invoice(cr, uid, [id], {"active_ids": pick_ids})
|
||||
-
|
||||
I check that an invoice_id field of Delivery&Invoices gets bind with the value.
|
||||
-
|
||||
|
|
|
@ -65,24 +65,16 @@
|
|||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
self.do_partial(cr, uid, [pick.id],partial_datas)
|
||||
-
|
||||
Then I create the invoice from the two partial picking
|
||||
-
|
||||
!record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_6}:
|
||||
invoice_date: '2010-07-17'
|
||||
journal_id: account.sales_journal
|
||||
type: out_invoice
|
||||
-
|
||||
Then I click on 'Create Invoices' button
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
sale_obj = self.pool.get('sale.order')
|
||||
sale_id = sale_obj.browse(cr, uid, ref("sale_order_so6"))
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
ids = picking_obj.search(cr, uid, [('origin', '=', sale_id.name)])
|
||||
self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_6")], {"lang": "en_US",
|
||||
"search_default_available": 1, "tz": False, "active_model": "stock.picking",
|
||||
"contact_display": "partner", "active_ids": ids, "active_id": ids[0]})
|
||||
ids = [x.id for x in sale_id.picking_ids]
|
||||
wiz_id = self.create(cr, uid, {'invoice_date': '2010-07-17', 'journal_id': ref('account.sales_journal')},
|
||||
{'active_ids': ids})
|
||||
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids})
|
||||
-
|
||||
I verify whether the invoice has been generated for SO
|
||||
-
|
||||
|
|
|
@ -58,24 +58,16 @@
|
|||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
self.do_partial(cr, uid, [pick.id],partial_datas)
|
||||
-
|
||||
Then I create invoice from picking
|
||||
-
|
||||
!record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_0}:
|
||||
invoice_date: '2010-07-15'
|
||||
journal_id: account.sales_journal
|
||||
type: out_invoice
|
||||
-
|
||||
Then I click on 'Create Invoices' button
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
sale_obj=self.pool.get('sale.order')
|
||||
sale_id=sale_obj.browse(cr, uid, ref("sale_order_so7"))
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
ids = picking_obj.search(cr, uid, [('origin', '=', sale_id.name)])
|
||||
self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_0")], {"lang": "en_US",
|
||||
"search_default_available": 1, "tz": False, "active_model": "stock.picking",
|
||||
"contact_display": "partner", "active_ids": ids, "active_id": ids[0]})
|
||||
ids = [x.id for x in sale_id.picking_ids]
|
||||
wiz_id = self.create(cr, uid, {'invoice_date': '2010-07-15', 'journal_id': ref('account.sales_journal')},
|
||||
{'active_ids': ids})
|
||||
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids})
|
||||
-
|
||||
I check that an invoice has been created.
|
||||
-
|
||||
|
|
|
@ -781,7 +781,7 @@
|
|||
<field name="model">stock.picking</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state in ('draft');grey:state in ('cancel');red:state not in ('cancel', 'done') and date < current_date" string="Picking list">
|
||||
<tree colors="blue:state in ('draft');grey:state in ('cancel');red:state not in ('cancel', 'done') and date < current_date" string="Outgoing Deliveries">
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="origin"/>
|
||||
|
@ -800,7 +800,7 @@
|
|||
<field name="model">stock.picking</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Outgoing Picking list">
|
||||
<form string="Outgoing Deliveries">
|
||||
<group col="6" colspan="4">
|
||||
<group colspan="4" col="4">
|
||||
<field name="name" readonly="1"/>
|
||||
|
@ -939,9 +939,9 @@
|
|||
<field name="arch" type="xml">
|
||||
<search string="Picking list">
|
||||
<group col="8" colspan="4">
|
||||
<filter icon="terp-check" name="available" string="Available" domain="[('state','=','assigned')]" help="Assigned Outgoing Orders"/>
|
||||
<filter icon="terp-camera_test" name="confirmed" string="Confirmed" domain="[('state','=','confirmed')]" help="Confirmed Outgoing Orders"/>
|
||||
<filter icon="terp-dialog-close" name="done" string="Done" domain="[('state','=','done')]" help="Outgoing Orders already processed"/>
|
||||
<filter icon="terp-check" name="available" string="Available" domain="[('state','=','assigned')]" help="Assigned Outgoing Deliveries"/>
|
||||
<filter icon="terp-camera_test" name="confirmed" string="Confirmed" domain="[('state','=','confirmed')]" help="Confirmed Outgoing Deliveries"/>
|
||||
<filter icon="terp-dialog-close" name="done" string="Done" domain="[('state','=','done')]" help="Outgoing Deliveries already processed"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-accessories-archiver-minus" string="Back Orders" domain="[('backorder_id', '!=', False)]" help="Is a Back Order" groups="base.group_extended"/>
|
||||
<separator orientation="vertical"/>
|
||||
|
@ -969,7 +969,7 @@
|
|||
</record>
|
||||
|
||||
<record id="action_picking_tree" model="ir.actions.act_window">
|
||||
<field name="name">Outgoing Orders</field>
|
||||
<field name="name">Outgoing Deliveries</field>
|
||||
<field name="res_model">stock.picking</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
|
|
|
@ -29,95 +29,77 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
_columns = {
|
||||
'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True),
|
||||
'group': fields.boolean("Group by partner"),
|
||||
'type': fields.selection([('out_invoice', 'Customer Invoice'),
|
||||
('in_invoice', 'Supplier Invoice'),
|
||||
('out_refund', 'Customer Refund'),
|
||||
('in_refund', 'Supplier Refund')] , 'Type', required=True),
|
||||
'invoice_date': fields.date('Invoiced date'),
|
||||
}
|
||||
|
||||
def _get_type(self, cr, uid, context=None):
|
||||
""" To get invoice type.
|
||||
@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 if we want more than one
|
||||
@param context: A standard dictionary
|
||||
@return: Invoice type
|
||||
"""
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
res = super(stock_invoice_onshipping, self).view_init(cr, uid, fields_list, context=context)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
count = 0
|
||||
active_ids = context.get('active_ids',[])
|
||||
for pick in pick_obj.browse(cr, uid, active_ids):
|
||||
if pick.invoice_state != '2binvoiced':
|
||||
count += 1
|
||||
if len(active_ids) == 1 and count:
|
||||
raise osv.except_osv(_('Warning !'), _('This picking list does not require invoicing.'))
|
||||
if len(active_ids) == count:
|
||||
raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.'))
|
||||
return res
|
||||
|
||||
def _get_type(self, pick):
|
||||
src_usage = dest_usage = None
|
||||
pick = picking_obj.browse(cr, uid, context['active_id'], context=context)
|
||||
if pick.invoice_state == 'invoiced':
|
||||
raise osv.except_osv(_('UserError'), _('Invoice is already created.'))
|
||||
if pick.invoice_state == 'none':
|
||||
raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.'))
|
||||
if pick.move_lines:
|
||||
src_usage = pick.move_lines[0].location_id.usage
|
||||
dest_usage = pick.move_lines[0].location_dest_id.usage
|
||||
if pick.type == 'out' and dest_usage == 'supplier':
|
||||
type = 'in_refund'
|
||||
elif pick.type == 'out' and dest_usage == 'customer':
|
||||
type = 'out_invoice'
|
||||
elif pick.type == 'in' and src_usage == 'supplier':
|
||||
type = 'in_invoice'
|
||||
elif pick.type == 'in' and src_usage == 'customer':
|
||||
type = 'out_refund'
|
||||
else:
|
||||
type = 'out_invoice'
|
||||
return type
|
||||
pick_type = None
|
||||
if pick.invoice_state=='2binvoiced':
|
||||
if pick.move_lines:
|
||||
src_usage = pick.move_lines[0].location_id.usage
|
||||
dest_usage = pick.move_lines[0].location_dest_id.usage
|
||||
if pick.type == 'out' and dest_usage == 'supplier':
|
||||
pick_type = 'in_refund'
|
||||
elif pick.type == 'out' and dest_usage == 'customer':
|
||||
pick_type = 'out_invoice'
|
||||
elif pick.type == 'in' and src_usage == 'supplier':
|
||||
pick_type = 'in_invoice'
|
||||
elif pick.type == 'in' and src_usage == 'customer':
|
||||
pick_type = 'out_refund'
|
||||
else:
|
||||
pick_type = 'out_invoice'
|
||||
return pick_type
|
||||
|
||||
_defaults = {
|
||||
'type': _get_type,
|
||||
}
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context):
|
||||
""" To create invoice
|
||||
@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 if we want more than one
|
||||
@param context: A standard dictionary
|
||||
@return: Invoice ids
|
||||
"""
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = []
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
act_obj = self.pool.get('ir.actions.act_window')
|
||||
onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', 'invoice_date'])
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
|
||||
for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']):
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj[id] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
context['date_inv'] = onshipdata_obj['invoice_date']
|
||||
invoice_ids = []
|
||||
for picking in picking_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
||||
if picking.invoice_state == '2binvoiced':
|
||||
res = picking_obj.action_invoice_create(cr, uid, [picking.id],
|
||||
journal_id = onshipdata_obj['journal_id'],
|
||||
group=onshipdata_obj['group'],
|
||||
type=self._get_type(picking),
|
||||
context=context)
|
||||
invoice_ids.extend(res.values())
|
||||
|
||||
type = onshipdata_obj['type']
|
||||
context['date_inv'] = onshipdata_obj['invoice_date']
|
||||
res = picking_obj.action_invoice_create(cr, uid,context['active_ids'],
|
||||
journal_id = onshipdata_obj['journal_id'],
|
||||
group=onshipdata_obj['group'],
|
||||
type=type,
|
||||
context=context)
|
||||
invoice_ids = res.values()
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('Invoice is not created'))
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('No invoice were created'))
|
||||
|
||||
if type == 'out_invoice':
|
||||
xml_id = 'action_invoice_tree1'
|
||||
elif type == 'in_invoice':
|
||||
xml_id = 'action_invoice_tree2'
|
||||
elif type == 'out_refund':
|
||||
xml_id = 'action_invoice_tree3'
|
||||
else:
|
||||
xml_id = 'action_invoice_tree4'
|
||||
|
||||
result = mod_obj._get_id(cr, uid, 'account', xml_id)
|
||||
id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
|
||||
result = act_obj.read(cr, uid, id['res_id'], context=context)
|
||||
result['res_id'] = invoice_ids
|
||||
result['context'] = context
|
||||
return result
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str,invoice_ids))+"])]",
|
||||
'name' : _('New picking invoices'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.invoice',
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
|
||||
stock_invoice_onshipping()
|
||||
|
||||
|
|
|
@ -1,36 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_stock_invoice_onshipping" model="ir.ui.view">
|
||||
<record id="view_stock_invoice_onshipping" model="ir.ui.view">
|
||||
<field name="name">Stock Invoice Onshipping</field>
|
||||
<field name="model">stock.invoice.onshipping</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create invoices">
|
||||
<separator colspan="4" string="Create invoices" />
|
||||
<field name="journal_id"/>
|
||||
<newline/>
|
||||
<field name="group"/>
|
||||
<newline/>
|
||||
<field name="type"/>
|
||||
<newline/>
|
||||
<field name="invoice_date" />
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" string="_Cancel" icon='gtk-cancel'/>
|
||||
<button name="create_invoice" string="Create Invoices" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
<form string="Create invoice">
|
||||
<separator colspan="4" string="Create invoice" />
|
||||
<field name="journal_id"/>
|
||||
<newline/>
|
||||
<field name="group"/>
|
||||
<newline/>
|
||||
<field name="invoice_date" />
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" string="_Cancel" icon='gtk-cancel'/>
|
||||
<button name="create_invoice" string="Create" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</record>
|
||||
|
||||
<record id="action_stock_invoice_onshipping" model="ir.actions.act_window">
|
||||
<field name="name">Create Invoice</field>
|
||||
<field name="res_model">stock.invoice.onshipping</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_stock_invoice_onshipping"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
<act_window name="Create invoice"
|
||||
res_model="stock.invoice.onshipping"
|
||||
src_model="stock.picking"
|
||||
key2="client_action_multi"
|
||||
multi="True"
|
||||
view_mode="form"
|
||||
view_type="form"
|
||||
target="new"
|
||||
id="action_stock_invoice_onshipping"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue