[MERGE] Merge mtr branch for sale changes

bzr revid: mra@mra-laptop-20100713035211-6esgdic7dqyzr74d
This commit is contained in:
Mustufa Rangwala 2010-07-13 09:22:11 +05:30
commit 5c9bfc683b
2 changed files with 35 additions and 19 deletions

View File

@ -233,7 +233,7 @@ class sale_order(osv.osv):
'incoterm': fields.selection(_incoterm_get, 'Incoterm', size=3, help="Incoterm which stands for 'International Commercial terms' implies its a series of sales terms which are used in the commercial transaction"),
'picking_policy': fields.selection([('direct', 'Partial Delivery'), ('one', 'Complete Delivery')],
'Picking Policy', required=True, help="""If you don't have enough stock available to deliver all at once, do you accept partial shipments or not?"""),
'Picking Policy', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="""If you don't have enough stock available to deliver all at once, do you accept partial shipments or not?"""),
'order_policy': fields.selection([
('prepaid', 'Payment Before Delivery'),
('manual', 'Shipping & Manual Invoice'),
@ -786,7 +786,7 @@ class sale_order_line(osv.osv):
context = context or {}
for line in self.browse(cr, uid, ids, context=context):
price = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100.0)
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty)
taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty)
cur = line.order_id.pricelist_id.currency_id
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
return res
@ -828,7 +828,7 @@ class sale_order_line(osv.osv):
'discount': fields.float('Discount (%)', digits=(16, 2), readonly=True, states={'draft':[('readonly',False)]}),
'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number Packages'),
'notes': fields.text('Notes'),
'th_weight': fields.float('Weight'),
'th_weight': fields.float('Weight', readonly=True, states={'draft':[('readonly',False)]}),
'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True,
help=' * The \'Draft\' state is set automatically when sale order in draft state. \
\n* The \'Confirmed\' state is set automatically when sale order in confirm state. \
@ -837,7 +837,7 @@ class sale_order_line(osv.osv):
\n* The \'Cancelled\' state is set automatically when user cancel sale order.'),
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'),
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'),
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True, states={'draft':[('readonly',False)]}),
}
_order = 'sequence, id'
_defaults = {
@ -852,9 +852,17 @@ class sale_order_line(osv.osv):
'product_packaging': False
}
def create_sale_order_line_invoice(self, cr, uid, ids, context=None):
if context is None:
context = {}
context.update({'active_ids' : ids,'active_id' : ids})
self.pool.get('sale.order.line.make.invoice').make_invoices(cr, uid, ids, context=context)
return True
def invoice_line_create(self, cr, uid, ids, context=None):
if context is None:
context = {}
def _get_line_qty(line):
if (line.order_id.invoice_quantity=='order') or not line.procurement_id:
if line.product_uos:
@ -919,7 +927,6 @@ class sale_order_line(osv.osv):
sales[line.order_id.id] = True
create_ids.append(inv_id)
# Trigger workflow events
wf_service = netsvc.LocalService("workflow")
for sid in sales.keys():
@ -932,6 +939,10 @@ class sale_order_line(osv.osv):
for line in self.browse(cr, uid, ids, context=context):
if line.invoiced:
raise osv.except_osv(_('Invalid action !'), _('You cannot cancel a sale order line that has already been invoiced !'))
# if line.order_id.picking_ids:
# raise osv.except_osv(
# _('Could not cancel sale order line!'),
# _('You must first cancel stock move attached to this sale order line.'))
message = _('Sale order line') + " '" + line.name + "' "+_("is cancelled")
self.log(cr, uid, id, message)
return self.write(cr, uid, ids, {'state': 'cancel'})

View File

@ -165,10 +165,10 @@
<field name="state"/>
<field name="invoiced"/>
<button colspan="1"
name="%(action_view_sale_order_line_make_invoice)d"
name="create_sale_order_line_invoice"
states="confirmed"
string="Make Invoice"
type="action"
string="Create Invoice"
type="object"
icon="terp-document-new" />
</group>
</page>
@ -396,20 +396,24 @@
<field colspan="4" name="tax_id" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]" nolabel="1"/>
<separator colspan="4" string="States"/>
<field name="state"/>
<button colspan="1"
name="%(action_view_sale_order_line_make_invoice)d"
string="Make Invoice"
type="action"
icon="terp-document-new" />
<group col="2" colspan="2">
<group col="3" colspan="2">
<button colspan="1"
name="create_sale_order_line_invoice"
states="confirmed"
string="Create Invoice"
type="object"
icon="terp-document-new"
attrs="{'invisible': [('invoiced', '=', 1)]}"/>
<button name="button_cancel"
states="confirmed,exception"
string="Cancel" type="object"
icon="gtk-cancel"
attrs="{'invisible': [('invoiced', '=', 1)]}" />
<button name="button_done"
states="confirmed,exception"
string="Done" type="object"
icon="gtk-jump-to" />
<button name="button_cancel"
states="confirmed,exception"
string="Cancel" type="object"
icon="gtk-cancel" />
icon="gtk-jump-to"
attrs="{'invisible': [('invoiced', '=', 0)]}"/>
</group>
</page>
<!-- <page string="Properties" groups="base.group_extended">-->
@ -492,6 +496,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="search_view_id" ref="view_sales_order_uninvoiced_line_filter" />
<field name="context">{"search_default_uninvoiced":1}</field>
<field name="filter" eval="True"/>
</record>