bzr revid: stw@openerp.com-20110915085925-hs86f0w3ptyynxjh
This commit is contained in:
Stephane Wirtel
2011-09-15 10:59:25 +02:00
9 changed files with 73 additions and 33 deletions
+10 -1
View File
@@ -188,7 +188,7 @@ class purchase_order(osv.osv):
'shipped_rate': fields.function(_shipped_rate, string='Received', type='float'),
'invoiced': fields.function(_invoiced, string='Invoiced & Paid', type='boolean', help="It indicates that an invoice has been paid"),
'invoiced_rate': fields.function(_invoiced_rate, string='Invoiced', type='float'),
'invoice_method': fields.selection([('manual','Manual'),('order','From Order'),('picking','From Reception')], 'Invoicing Control', required=True,
'invoice_method': fields.selection([('manual','From PO/PO lines'),('order','Draft invoices pre-generated'),('picking','From receptions')], 'Invoicing Control', required=True,
help="From Order: a draft invoice will be generated based on the purchase order. The accountant " \
"will just have to validate this invoice for control.\n" \
"From Reception: a draft invoice will be generated based on validated receptions.\n" \
@@ -612,6 +612,14 @@ class purchase_order_line(osv.osv):
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
return res
def _get_uom_id(self, cr, uid, context=None):
try:
proxy = self.pool.get('ir.model.data')
result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')
return result[1]
except Exception, ex:
return False
_columns = {
'name': fields.char('Description', size=256, required=True),
'product_qty': fields.float('Quantity', required=True, digits=(16,2)),
@@ -639,6 +647,7 @@ class purchase_order_line(osv.osv):
}
_defaults = {
'product_uom' : _get_uom_id,
'product_qty': lambda *a: 1.0,
'state': lambda *args: 'draft',
'invoiced': lambda *a: 0,
+4 -4
View File
@@ -70,11 +70,11 @@
domain="[('state','=','assigned')]" help="Incoming Shipments Available"/>
<filter icon="terp-dialog-close" name="done" string="Done"
domain="[('state','=','done')]" help="Incoming Shipments already processed"/>
<filter string="To invoice" name="to_invoice" icon="terp-dolar"
domain="[('invoice_state', '=', '2binvoiced')]"/>
<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"/>
<filter string="To invoice" name="to_invoice" icon="terp-dolar"
domain="[('invoice_state', '=', '2binvoiced')]"/>
<separator orientation="vertical"/>
<field name="name"/>
<field name="partner_id"/>
@@ -103,13 +103,13 @@
</record>
<record id="action_picking_tree4_picking_to_invoice" model="ir.actions.act_window">
<field name="name">Pickings to Invoice</field>
<field name="name">On Incoming Shipments</field>
<field name="res_model">stock.picking</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar</field>
<field name="domain">[('type','=','in')]</field>
<field name="context">{'search_default_done':1,'search_default_to_invoice':1}</field>
<field name="context">{'contact_display': 'partner_address',"search_default_available":1}</field>
<field name="search_view_id" ref="view_picking_in_search_picking_to_invoice"/>
<field name="help">Create invoice from reception of products. If you selected this invoice control method in the purchase order, all receptions done are available here to be invoiced.</field>
</record>
@@ -55,18 +55,6 @@ class purchase_line_invoice(osv.osv_memory):
invoice_line_obj=self.pool.get('account.invoice.line')
account_jrnl_obj=self.pool.get('account.journal')
def multiple_order_invoice_name(orders):
name = "PO";
for order in orders:
name += "-%d" % order.id
return name
def multiple_order_invoice_reference(partner, orders):
reference = "P%dPO" % partner.id
for order in orders:
reference += "-%d" % order.id
return reference
def multiple_order_invoice_notes(orders):
notes = ""
for order in orders:
@@ -82,6 +70,7 @@ class purchase_line_invoice(osv.osv_memory):
@param orders : The set of orders to add in the invoice
@param lines : The list of line's id
"""
name = orders and orders[0].name or ''
journal_id = account_jrnl_obj.search(cr, uid, [('type', '=', 'purchase')], context=None)
journal_id = journal_id and journal_id[0] or False
a = partner.property_account_payable.id
@@ -90,11 +79,11 @@ class purchase_line_invoice(osv.osv_memory):
else:
pay_term = False
inv = {
'name': multiple_order_invoice_name(orders),
'origin': multiple_order_invoice_name(orders),
'name': name,
'origin': name,
'type': 'in_invoice',
'journal_id':journal_id,
'reference': multiple_order_invoice_reference(partner, orders),
'reference' : partner.ref,
'account_id': a,
'partner_id': partner.id,
'address_invoice_id': orders[0].partner_address_id.id,
+9
View File
@@ -838,6 +838,14 @@ class sale_order_line(osv.osv):
res[line.id] = 1
return res
def _get_uom_id(self, cr, uid, *args):
try:
proxy = self.pool.get('ir.model.data')
result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')
return result[1]
except Exception, ex:
return False
_name = 'sale.order.line'
_description = 'Sales Order Line'
_columns = {
@@ -877,6 +885,7 @@ class sale_order_line(osv.osv):
}
_order = 'sequence, id'
_defaults = {
'product_uom' : _get_uom_id,
'discount': 0.0,
'delay': 0.0,
'product_uom_qty': 1,
+5 -6
View File
@@ -698,6 +698,7 @@
<field name="name" readonly="1"/>
<field name="origin"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="invoice_state" string="Invoice Control" groups="base.group_extended"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
</group>
<group colspan="2" col="2">
@@ -708,7 +709,7 @@
</group>
<notebook colspan="4">
<page string="Products">
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines}">
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines, 'address_in_id': address_id}">
<tree colors="grey:scrapped == True" string="Stock Moves">
<field name="product_id"/>
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
@@ -737,7 +738,6 @@
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_expected" string="Date Expected"/>
<field name="state"/>
@@ -760,7 +760,7 @@
<group colspan="2" col="2">
<separator string="Locations" colspan="2" />
<field name="location_id" domain="[('usage','=','internal')]" />
<field name="location_id" domain="[('usage','&lt;&gt;','view')]" />
<field name="location_dest_id" domain="[('usage','=','internal')]" />
</group>
@@ -810,7 +810,6 @@
</page>
<page string="Additional info" groups="base.group_extended,base.group_multi_company">
<field name="auto_picking" groups="base.group_extended"/>
<field name="invoice_state" groups="base.group_extended"/>
<field name="date_done" groups="base.group_extended"/>
<field name="move_type" groups="base.group_extended"/>
<field name="type" groups="base.group_extended"/>
@@ -1112,7 +1111,7 @@
<group colspan="4" col="4">
<field name="name" readonly="1"/>
<field name="origin"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" domain="[('partner_id','&lt;&gt;',False)]" colspan="4"/>
<field name="invoice_state" string="Invoice Control"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
</group>
@@ -1573,7 +1572,7 @@
<field name="date"/>
<field name="state"/>
<button name="action_assign" states="confirmed" string="Set Available" type="object" icon="gtk-yes"/>
<button name="%(action_partial_move_server)d" string="Process" type="action" states="confirmed,assigned" icon="gtk-go-forward"/>
<button name="action_done" string="Process" type="object" states="confirmed,assigned" icon="gtk-go-forward"/>
</tree>
</field>
</record>
@@ -25,6 +25,12 @@ from 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:
return res[0]
return False
def _get_journal_id(self, cr, uid, context=None):
if context is None:
context = {}
@@ -61,7 +67,6 @@ class stock_invoice_onshipping(osv.osv_memory):
vals.append(t1)
return vals
_name = "stock.invoice.onshipping"
_description = "Stock Invoice Onshipping"
@@ -70,7 +75,11 @@ class stock_invoice_onshipping(osv.osv_memory):
'group': fields.boolean("Group by partner"),
'invoice_date': fields.date('Invoiced date'),
}
_defaults = {
'journal_id' : _get_journal,
}
def view_init(self, cr, uid, fields_list, context=None):
if context is None:
context = {}
@@ -32,6 +32,8 @@ class stock_partial_move_memory_out(osv.osv_memory):
'quantity' : fields.float("Quantity", required=True),
'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True),
'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'),
'location_id': fields.many2one('stock.location', 'Location', required=True),
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', required=True),
'move_id' : fields.many2one('stock.move', "Move"),
'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"),
'cost' : fields.float("Cost", help="Unit Cost for this product line"),
@@ -30,6 +30,8 @@
<field name="product_id" />
<field name="quantity" />
<field name="product_uom" />
<field name="location_id" />
<field name="location_dest_id" />
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
<field name="cost" />
<field name="currency" />
@@ -46,6 +48,8 @@
<field name="product_id" />
<field name="quantity" />
<field name="product_uom" />
<field name="location_id" />
<field name="location_dest_id" />
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
<field name="cost" />
<field name="currency" />
@@ -62,6 +66,8 @@
<field name="product_id" />
<field name="quantity" />
<field name="product_uom" />
<field name="location_id" />
<field name="location_dest_id" />
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
</tree>
</field>
@@ -76,6 +82,8 @@
<field name="product_id" />
<field name="quantity" />
<field name="product_uom" />
<field name="location_id" />
<field name="location_dest_id" />
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
</form>
</field>
+20 -5
View File
@@ -122,7 +122,9 @@ class stock_partial_picking(osv.osv_memory):
'quantity' : picking.product_qty,
'product_uom' : picking.product_uom.id,
'prodlot_id' : picking.prodlot_id.id,
'move_id' : picking.id,
'move_id' : picking.id,
'location_id' : picking.location_id.id,
'location_dest_id' : picking.location_dest_id.id,
}
if pick_type == 'in':
@@ -142,19 +144,32 @@ class stock_partial_picking(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
pick_obj = self.pool.get('stock.picking')
stock_move_obj = self.pool.get('stock.move')
picking_ids = context.get('active_ids', False)
partial = self.browse(cr, uid, ids[0], context=context)
partial_datas = {
'delivery_date' : partial.date
}
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
picking_type = self.get_picking_type(cr, uid, pick, context=context)
moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
for move in moves_list:
partial_datas['move%s' % (move.move_id.id)] = {
if not move.move_id.id:
seq_obj_name = 'stock.picking.' + picking_type
move_id = stock_move_obj.create(cr,uid,{'name' : self.pool.get('ir.sequence').get(cr, uid, seq_obj_name),
'product_id': move.product_id.id,
'product_qty': move.quantity,
'product_uom': move.product_uom.id,
'prodlot_id': move.prodlot_id.id,
'location_id' : move.location_id.id,
'location_dest_id' : move.location_dest_id.id,
'picking_id': pick.id
},context=context)
stock_move_obj.action_done(cr, uid, [move_id], context)
else:
move_id = move.move_id.id
partial_datas['move%s' % (move_id)] = {
'product_id': move.id,
'product_qty': move.quantity,
'product_uom': move.product_uom.id,