[ImP] Improved typo's AND searched the section_id direct from the xml id AND directly inserted the state on the 2nd position in sale.order rather than declaring the states again.
This commit is contained in:
parent
be8a180bc5
commit
97711ed282
|
@ -74,7 +74,7 @@ class sale_order(osv.Model):
|
|||
if not grid_id:
|
||||
raise osv.except_osv(_('No Grid Available!'), _('No grid matching for this carrier!'))
|
||||
|
||||
if order.state not in ['draft', context.get('shopping_cart', False)]:
|
||||
if order.state in ['sent', 'cancel', 'progress', 'manual', 'done']:
|
||||
raise osv.except_osv(_('Order not in Draft State!'), _('The order state have to be draft to add delivery lines.'))
|
||||
|
||||
grid = grid_obj.browse(cr, uid, grid_id, context=context)
|
||||
|
|
|
@ -28,6 +28,17 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FO
|
|||
import openerp.addons.decimal_precision as dp
|
||||
from openerp import workflow
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft', 'Draft Quotation'),
|
||||
('sent', 'Quotation Sent'),
|
||||
('cancel', 'Cancelled'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('progress', 'Sales Order'),
|
||||
('manual', 'Sale to Invoice'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
]
|
||||
|
||||
class sale_order(osv.osv):
|
||||
_name = "sale.order"
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||
|
@ -168,16 +179,7 @@ class sale_order(osv.osv):
|
|||
readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
|
||||
'origin': fields.char('Source Document', size=64, help="Reference of the document that generated this sales order request."),
|
||||
'client_order_ref': fields.char('Reference/Description', size=64),
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft Quotation'),
|
||||
('sent', 'Quotation Sent'),
|
||||
('cancel', 'Cancelled'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('progress', 'Sales Order'),
|
||||
('manual', 'Sale to Invoice'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
], 'Status', readonly=True, track_visibility='onchange',
|
||||
'state': fields.selection(AVAILABLE_STATES , 'Status', readonly=True, track_visibility='onchange',
|
||||
help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
|
||||
'date_order': fields.date('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
|
||||
'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which sales order is created."),
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
<field name="html_class">oe_image_full</field>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="crm_case_section_shopping_carts">
|
||||
<field name="name">Shopping Carts</field>
|
||||
<record model="crm.case.section" id="crm_case_section_shopping_cart">
|
||||
<field name="name">Shopping Cart</field>
|
||||
<field name="code">SPC</field>
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
|
|
@ -548,7 +548,7 @@ Weight: 1.1 ounces</field>
|
|||
<field name="sequence">1</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_section_shopping_carts" model="crm.case.section">
|
||||
<record id="crm_case_section_shopping_cart" model="crm.case.section">
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'), ref('base.user_demo'))]"/>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.sale import sale
|
||||
|
||||
sale.AVAILABLE_STATES.insert(1,('shopping_cart', 'Shopping Cart'))
|
||||
|
||||
class SaleOrder(osv.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
_columns = {
|
||||
'state': fields.selection(sale.AVAILABLE_STATES, 'Status'),
|
||||
'website_session_id': fields.char('Session UUID4'),
|
||||
'website_order_line': fields.one2many(
|
||||
'sale.order.line', 'order_id',
|
||||
|
|
|
@ -146,7 +146,7 @@ class Website(orm.Model):
|
|||
SaleOrder = self.pool.get('sale.order')
|
||||
quotation_values = self._ecommerce_get_quotation_values(cr, uid, context=context)
|
||||
quotation_values['user_id'] = False
|
||||
quotation_values['section_id'] = self.pool.get('crm.case.section').search(cr, SUPERUSER_ID, [('code', '=', 'SPC')], context=context)[0]
|
||||
quotation_values['section_id'] = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'website_sale', 'crm_case_section_shopping_cart')[1]
|
||||
quotation_values['state'] = 'shopping_cart'
|
||||
return SaleOrder.create(cr, SUPERUSER_ID, quotation_values, context=context)
|
||||
|
||||
|
@ -222,21 +222,3 @@ class Website(orm.Model):
|
|||
|
||||
def ecommerce_get_product_domain(self):
|
||||
return [("sale_ok", "=", True),("product_variant_ids","!=",False)]
|
||||
|
||||
class sale_order(osv.osv):
|
||||
_inherit = "sale.order"
|
||||
|
||||
_columns = {
|
||||
'state': fields.selection([
|
||||
('draft', 'Draft Quotation'),
|
||||
('shopping_cart', 'Shopping Cart'),
|
||||
('sent', 'Quotation Sent'),
|
||||
('cancel', 'Cancelled'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('progress', 'Sales Order'),
|
||||
('manual', 'Sale to Invoice'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
], 'Status', readonly=True,
|
||||
help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue