Merge pull request #1428 from odoo-dev/sass-5-fixes-chm

[FIX] website_sale and point_of_sale fixes
This commit is contained in:
Christophe Matthieu 2014-08-04 14:43:54 +02:00
commit 8d53c357ba
12 changed files with 113 additions and 92 deletions

View File

@ -1379,16 +1379,4 @@ class product_template(osv.osv):
'available_in_pos': True,
}
def edit_ean(self, cr, uid, ids, context):
return {
'name': _("Assign a Custom EAN"),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.ean_wizard',
'target' : 'new',
'view_id': False,
'context':context,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -523,6 +523,13 @@
<menuitem action="product_pos_category_action" id="menu_product_pos_category" parent="menu_point_of_sale_product" sequence="0" />
<!-- END -->
<record id="action_edit_ean" model="ir.actions.act_window">
<field name="name">Edit Ean</field>
<field name="res_model">pos.ean_wizard</field>
<field name="target">new</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
@ -539,7 +546,7 @@
</group>
</group>
<field name="ean13" position="after">
<button colspan="2" name="edit_ean" type="object" string="Set a Custom EAN" class="oe_link oe_edit_only"/>
<button colspan="2" name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" class="oe_link oe_edit_only"/>
</field>
</field>
</record>

View File

@ -18,18 +18,6 @@ class res_users(osv.osv):
for user in self.browse(cr, uid, ids, context=context)
)
def edit_ean(self, cr, uid, ids, context):
return {
'name': "Edit Ean",
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.ean_wizard',
'target' : 'new',
'view_id': False,
'context':context,
}
_constraints = [
(_check_ean, "Error: Invalid ean code", ['ean13'],),
]

View File

@ -11,7 +11,7 @@
<page string="Point of Sale">
<group>
<field name="ean13" />
<button name="edit_ean" type="object" string="Edit" />
<button name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" />
</group>
</page>
</notebook>

View File

@ -19,18 +19,6 @@ class res_users(osv.osv):
for user in self.browse(cr, uid, ids, context=context)
)
def edit_ean(self, cr, uid, ids, context):
return {
'name': "Edit EAN",
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.ean_wizard',
'target' : 'new',
'view_id': False,
'context':context,
}
_constraints = [
(_check_ean, "Error: Invalid ean code", ['ean13'],),
]

View File

@ -23,7 +23,7 @@
<group>
<field name="pos_config" />
<field name="ean13" />
<button name="edit_ean" type="object" string="Edit EAN" class="oe_edit_only" />
<button name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" class="oe_edit_only" />
</group>
</page>
</notebook>

View File

@ -418,13 +418,7 @@ class product_template(osv.osv):
return self.is_product_variant(cr, uid, ids, name, arg, context=context)
def is_product_variant(self, cr, uid, ids, name, arg, context=None):
prod = self.pool.get('product.product')
res = dict.fromkeys(ids, False)
ctx = dict(context, active_test=True)
for product in self.browse(cr, uid, ids, context=context):
res[product.id] = prod.search(cr, uid, [('product_tmpl_id','=',product.id)], context=ctx, count=True) == 1
return res
return dict.fromkeys(ids, False)
def _product_template_price(self, cr, uid, ids, name, arg, context=None):
plobj = self.pool.get('product.pricelist')

View File

@ -503,12 +503,15 @@ div.media_iframe_video {
div.media_iframe_video iframe {
width: 100%;
height: 100%;
position: absolute;
margin-left: -50%;
}
div.media_iframe_video div {
div.media_iframe_video .css_editable_mode_display {
position: absolute;
width: 100%;
height: 100%;
display: none;
z-index: 2;
}
/* Mobile view */

View File

@ -88,7 +88,7 @@ header
/* ----- EDITOR ----- */
.css_non_editable_mode_hidden
display: none
display: none !important
/* ----- BOOTSTRAP FIX ----- */
@ -413,11 +413,14 @@ div.media_iframe_video
iframe
width: 100%
height: 100%
div
position: absolute
margin-left: -50%
.css_editable_mode_display
position: absolute
width: 100%
height: 100%
display: none
z-index: 2
/* Mobile view */

View File

@ -304,18 +304,17 @@ class website_sale(http.Controller):
countries = orm_country.browse(cr, SUPERUSER_ID, country_ids, context)
states_ids = state_orm.search(cr, SUPERUSER_ID, [], context=context)
states = state_orm.browse(cr, SUPERUSER_ID, states_ids, context)
partner = orm_user.browse(cr, SUPERUSER_ID, request.uid, context).partner_id
order = None
shipping_id = None
shipping_ids = []
checkout = {}
if not data:
if request.uid != request.website.user_id.id:
partner = orm_user.browse(cr, SUPERUSER_ID, request.uid, context).partner_id
checkout.update( self.checkout_parse("billing", partner) )
shipping_ids = orm_partner.search(cr, SUPERUSER_ID, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], limit=1, context=context)
if shipping_ids:
shipping = orm_user.browse(cr, SUPERUSER_ID, request.uid, context)
checkout.update( self.checkout_parse("shipping", shipping) )
checkout['shipping_different'] = True
shipping_ids = orm_partner.search(cr, SUPERUSER_ID, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], context=context)
else:
order = request.website.sale_get_order(force_create=1, context=context)
if order.partner_id:
@ -325,17 +324,47 @@ class website_sale(http.Controller):
checkout.update( self.checkout_parse("billing", order.partner_id) )
else:
checkout = self.checkout_parse('billing', data)
if data.get("shipping_different"):
try:
shipping_id = int(data["shipping_id"])
except ValueError:
pass
if shipping_id == -1:
checkout.update(self.checkout_parse('shipping', data))
checkout["shipping_different"] = True
if shipping_id is None:
if not order:
order = request.website.sale_get_order(context=context)
if order and order.partner_shipping_id:
shipping_id = order.partner_shipping_id.id
shipping_ids = list(set(shipping_ids) - set([partner.id]))
if shipping_id == partner.id:
shipping_id = 0
elif shipping_id > 0 and shipping_id not in shipping_ids:
shipping_ids.append(shipping_id)
elif shipping_id is None and shipping_ids:
shipping_id = shipping_ids[0]
ctx = dict(context, show_address=1)
shippings = []
if shipping_ids:
shippings = shipping_ids and orm_partner.browse(cr, SUPERUSER_ID, list(shipping_ids), ctx) or []
if shipping_id > 0:
shipping = orm_partner.browse(cr, SUPERUSER_ID, shipping_id, ctx)
checkout.update( self.checkout_parse("shipping", shipping) )
checkout['shipping_id'] = shipping_id
values = {
'countries': countries,
'states': states,
'checkout': checkout,
'shipping_different': checkout.get('shipping_different'),
'shipping_id': partner.id != shipping_id and shipping_id or 0,
'shippings': shippings,
'error': {},
}
return values
mandatory_billing_fields = ["name", "phone", "email", "street", "city", "country_id", "zip"]
@ -395,7 +424,7 @@ class website_sale(http.Controller):
if not check_func(cr, uid, vat_country, vat_number, context=None): # simple_vat_check
error["vat"] = 'error'
if data.get("shipping_different"):
if data.get("shipping_id") == -1:
for field_name in self.mandatory_shipping_fields:
field_name = 'shipping_' + field_name
if not data.get(field_name):
@ -431,21 +460,20 @@ class website_sale(http.Controller):
partner_id = orm_partner.create(cr, SUPERUSER_ID, billing_info, context=context)
# create a new shipping partner
shipping_id = None
if checkout.get('shipping_different'):
if checkout.get('shipping_id') == -1:
shipping_info = self.checkout_parse('shipping', checkout, True)
shipping_info['type'] = 'delivery'
shipping_info['parent_id'] = partner_id
shipping_id = orm_partner.create(cr, SUPERUSER_ID, shipping_info, context)
checkout['shipping_id'] = orm_partner.create(cr, SUPERUSER_ID, shipping_info, context)
order_info = {
'partner_id': partner_id,
'message_follower_ids': [(4, partner_id)],
'partner_invoice_id': partner_id,
'partner_shipping_id': shipping_id or partner_id
}
order_info.update(registry.get('sale.order').onchange_partner_id(cr, SUPERUSER_ID, [], partner_id, context=context)['value'])
order_info.pop('user_id')
order_info.update(partner_shipping_id=checkout.get('shipping_id') or partner_id)
order_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context)
@ -482,6 +510,7 @@ class website_sale(http.Controller):
return request.website.render("website_sale.checkout", values)
self.checkout_form_save(values["checkout"])
request.session['sale_last_order_id'] = order.id
return request.redirect("/shop/payment")

View File

@ -1,10 +1,17 @@
$(document).ready(function () {
var $shippingDifferent = $(".oe_website_sale input[name='shipping_different']");
if ($shippingDifferent.is(':checked')) {
$(".oe_website_sale .js_shipping").show();
}
$shippingDifferent.change(function () {
$(".oe_website_sale .js_shipping").toggle();
var $shippingDifferent = $(".oe_website_sale select[name='shipping_id']");
$shippingDifferent.change(function (event) {
var value = +$shippingDifferent.val();
var data = $shippingDifferent.find("option:selected").data();
var $snipping = $(".oe_website_sale .js_shipping");
var $inputs = $snipping.find("input,select");
$snipping.toggle(!!value);
$inputs.attr("readonly", value <= 0 ? null : "readonly" ).prop("readonly", value <= 0 ? null : "readonly" );
$inputs.each(function () {
$(this).val( data[$(this).attr("name")] || "" );
});
});
// change for css

View File

@ -865,7 +865,7 @@
</select>
</div>
<div t-attf-class="form-group #{error.get('country_id') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Country</label>
<label class="control-label" for="country_id">Country</label>
<select name="country_id" class="form-control">
<option value="">Country...</option>
<t t-foreach="countries or []" t-as="country">
@ -876,40 +876,52 @@
<div class="clearfix"/>
<div class="form-group col-lg-6">
<label>
<input type="checkbox" name="shipping_different" t-att-checked="checkout.get('shipping_different')"/>
<span>Ship to a different address</span>
</label>
<div class="form-group col-lg-12">
<label>Shipping</label>
<select name="shipping_id" class="form-control">
<option value="0">Ship to the same address</option>
<t t-foreach="shippings" t-as="shipping">
<option t-att-value="shipping.id" t-att-selected="shipping.id == shipping_id"
t-att-data-shipping_name="shipping.name"
t-att-data-shipping_phone="shipping.phone"
t-att-data-shipping_street="shipping.street"
t-att-data-shipping_city="shipping.city"
t-att-data-shipping_zip="shipping.zip"
t-att-data-shipping_state_id="shipping.state_id and shipping.state_id.id"
t-att-data-shipping_country_id="shipping.country_id and shipping.country_id.id"
><t t-esc="', '.join('\n'.join(shipping.name_get()[0][1].split(',')).split('\n')[1:])"/></option>
</t>
<option value="-1">-- Create a new address --</option>
</select>
</div>
</div>
<div class="js_shipping row mb16" t-att-style="not checkout.get('shipping_different') and 'display:none' or ''">
<div class="js_shipping row mb16" t-att-style="not shipping_id and 'display:none' or ''">
<h3 class="oe_shipping col-lg-12 mt16">Shipping Information</h3>
<div t-attf-class="form-group #{error.get('shipping_name') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Name (Shipping)</label>
<input type="text" name="shipping_name" class="form-control" t-att-value="checkout.get('shipping_name', '')"/>
<label class="control-label" for="shipping_name">Name (Shipping)</label>
<input type="text" name="shipping_name" class="form-control" t-att-value="checkout.get('shipping_name', '')" t-att-readonly="'readonly' if shipping_id &gt;= 0 else ''"/>
</div>
<div t-attf-class="form-group #{error.get('shipping_phone') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Phone</label>
<input type="tel" name="shipping_phone" class="form-control" t-att-value="checkout.get('shipping_phone', '')"/>
<label class="control-label" for="shipping_phone">Phone</label>
<input type="tel" name="shipping_phone" class="form-control" t-att-value="checkout.get('shipping_phone', '')" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''"/>
</div>
<div t-attf-class="form-group #{error.get('shipping_street') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Street</label>
<input type="text" name="shipping_street" class="form-control" t-att-value="checkout.get('shipping_street', '')"/>
<label class="control-label" for="shipping_street">Street</label>
<input type="text" name="shipping_street" class="form-control" t-att-value="checkout.get('shipping_street', '')" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''"/>
</div>
<div class="clearfix"/>
<div t-attf-class="form-group #{error.get('shipping_city') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">City</label>
<input type="text" name="shipping_city" class="form-control" t-att-value="checkout.get('shipping_city', '')"/>
<label class="control-label" for="shipping_city">City</label>
<input type="text" name="shipping_city" class="form-control" t-att-value="checkout.get('shipping_city', '')" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''"/>
</div>
<div t-attf-class="form-group #{error.get('shipping_zip') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Zip / Postal Code</label>
<input type="text" name="shipping_zip" class="form-control" t-att-value="checkout.get('shipping_zip', '')"/>
<label class="control-label" for="shipping_zip">Zip / Postal Code</label>
<input type="text" name="shipping_zip" class="form-control" t-att-value="checkout.get('shipping_zip', '')" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''"/>
</div>
<div t-attf-class="form-group #{error.get('shipping_state_id') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name" style="font-weight: normal">State / Province</label>
<select name="shipping_state_id" class="form-control">
<label class="control-label" for="shipping_state_id" style="font-weight: normal">State / Province</label>
<select name="shipping_state_id" class="form-control" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''">
<option value="">State / Province...</option>
<t t-foreach="states or []" t-as="state">
<option t-att-value="state.id" t-att-selected="state.id == checkout.get('shipping_state_id')"><t t-esc="state.name"/></option>
@ -917,8 +929,8 @@
</select>
</div>
<div t-attf-class="form-group #{error.get('shipping_country_id') and 'has-error' or ''} col-lg-6">
<label class="control-label" for="contact_name">Country</label>
<select name="shipping_country_id" class="form-control">
<label class="control-label" for="shipping_country_id">Country</label>
<select name="shipping_country_id" class="form-control" t-att-readonly=" 'readonly' if shipping_id &gt;= 0 else ''">
<option value="">Country...</option>
<t t-foreach="countries or []" t-as="country">
<option t-att-value="country.id" t-att-selected="country.id == checkout.get('shipping_country_id')"><t t-esc="country.name"/></option>
@ -926,7 +938,9 @@
</select>
</div>
</div>
<a class="btn btn-default btn-primary pull-right mb32 a-submit">Confirm <span class="fa fa-long-arrow-right"/></a>
<div class="clearfix">
<a class="btn btn-default btn-primary pull-right mb32 a-submit">Confirm <span class="fa fa-long-arrow-right"/></a>
</div>
</div>
<div class="col-lg-offset-1 col-lg-3 col-md-3 text-muted">
<h3 class="page-header mt16">Your Order <small><a href="/shop/cart"><span class="fa fa-arrow-right"/> change</a></small></h3>