[MERGE] staging branch
bzr revid: qdp-launchpad@openerp.com-20121126162933-a3c1agw0z72auw0e
This commit is contained in:
commit
90e268d14c
|
@ -958,9 +958,14 @@ class account_invoice(osv.osv):
|
|||
})
|
||||
|
||||
date = inv.date_invoice or time.strftime('%Y-%m-%d')
|
||||
part = inv.partner_id.id
|
||||
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml)
|
||||
#if the chosen partner is not a company and has a parent company, use the parent for the journal entries
|
||||
#because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
|
||||
part = inv.partner_id
|
||||
if part.parent_id and not part.is_company:
|
||||
part = part.parent_id
|
||||
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part.id, date, context=ctx)),iml)
|
||||
|
||||
line = self.group_lines(cr, uid, iml, line, inv)
|
||||
|
||||
|
|
|
@ -166,28 +166,35 @@ class account_move_line(osv.osv):
|
|||
del data[f]
|
||||
return data
|
||||
|
||||
def _prepare_analytic_line(self, cr, uid, obj_line, context=None):
|
||||
"""
|
||||
Prepare the values given at the create() of account.analytic.line upon the validation of a journal item having
|
||||
an analytic account. This method is intended to be extended in other modules.
|
||||
|
||||
:param obj_line: browse record of the account.move.line that triggered the analytic line creation
|
||||
"""
|
||||
return {'name': obj_line.name,
|
||||
'date': obj_line.date,
|
||||
'account_id': obj_line.analytic_account_id.id,
|
||||
'unit_amount': obj_line.quantity,
|
||||
'product_id': obj_line.product_id and obj_line.product_id.id or False,
|
||||
'product_uom_id': obj_line.product_uom_id and obj_line.product_uom_id.id or False,
|
||||
'amount': (obj_line.credit or 0.0) - (obj_line.debit or 0.0),
|
||||
'general_account_id': obj_line.account_id.id,
|
||||
'journal_id': obj_line.journal_id.analytic_journal_id.id,
|
||||
'ref': obj_line.ref,
|
||||
'move_id': obj_line.id,
|
||||
'user_id': uid,
|
||||
}
|
||||
|
||||
def create_analytic_lines(self, cr, uid, ids, context=None):
|
||||
acc_ana_line_obj = self.pool.get('account.analytic.line')
|
||||
for obj_line in self.browse(cr, uid, ids, context=context):
|
||||
if obj_line.analytic_account_id:
|
||||
if not obj_line.journal_id.analytic_journal_id:
|
||||
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name, ))
|
||||
amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0)
|
||||
vals_lines = {
|
||||
'name': obj_line.name,
|
||||
'date': obj_line.date,
|
||||
'account_id': obj_line.analytic_account_id.id,
|
||||
'unit_amount': obj_line.quantity,
|
||||
'product_id': obj_line.product_id and obj_line.product_id.id or False,
|
||||
'product_uom_id': obj_line.product_uom_id and obj_line.product_uom_id.id or False,
|
||||
'amount': amt,
|
||||
'general_account_id': obj_line.account_id.id,
|
||||
'journal_id': obj_line.journal_id.analytic_journal_id.id,
|
||||
'ref': obj_line.ref,
|
||||
'move_id': obj_line.id,
|
||||
'user_id': uid
|
||||
}
|
||||
acc_ana_line_obj.create(cr, uid, vals_lines)
|
||||
vals_line = self._prepare_analytic_line(cr, uid, obj_line, context=context)
|
||||
acc_ana_line_obj.create(cr, uid, vals_line)
|
||||
return True
|
||||
|
||||
def _default_get_move_form_hook(self, cursor, user, data):
|
||||
|
|
|
@ -31,10 +31,10 @@ class sale_order(osv.osv):
|
|||
'id': fields.integer('ID', readonly=True,invisible=True),
|
||||
}
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context)
|
||||
if part:
|
||||
dtype = self.pool.get('res.partner').browse(cr, uid, part).property_delivery_carrier.id
|
||||
dtype = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_delivery_carrier.id
|
||||
result['value']['carrier_id'] = dtype
|
||||
return result
|
||||
|
||||
|
|
|
@ -62,11 +62,7 @@ class account_analytic_line(osv.osv):
|
|||
if data is None:
|
||||
data = {}
|
||||
|
||||
account_ids = {}
|
||||
for line in self.pool.get('account.analytic.line').browse(cr, uid, ids, context=context):
|
||||
account_ids[line.account_id.id] = True
|
||||
|
||||
account_ids = account_ids.keys() #data['accounts']
|
||||
account_ids = [line.account_id.id for line in self.pool.get('account.analytic.line').browse(cr, uid, ids, context=context)]
|
||||
for account in analytic_account_obj.browse(cr, uid, account_ids, context=context):
|
||||
partner = account.partner_id
|
||||
if (not partner) or not (account.pricelist_id):
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<field name="name"/>
|
||||
<field name="date_order"/>
|
||||
<field name="session_id" required="1"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_customer':1}" attrs="{'readonly': [('state','=','invoiced')]}"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" context="{'search_default_customer':1}" attrs="{'readonly': [('state','=','invoiced')]}"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Products">
|
||||
|
|
|
@ -202,7 +202,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
|
|||
* {
|
||||
* quantity: (number) the number of items, or the weight,
|
||||
* unit_name: (string) the name of the item's unit (kg, dozen, ...)
|
||||
* list_price: (number) the price of one unit of the item before discount
|
||||
* price: (number) the price of one unit of the item before discount
|
||||
* discount: (number) the discount on the product in % [0,100]
|
||||
* product_name: (string) the name of the product
|
||||
* price_with_tax: (number) the price paid for this orderline, tax included
|
||||
|
|
|
@ -342,7 +342,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
this.pos = options.pos;
|
||||
this.order = options.order;
|
||||
this.product = options.product;
|
||||
this.price = options.product.get('list_price');
|
||||
this.price = options.product.get('price');
|
||||
this.quantity = 1;
|
||||
this.discount = 0;
|
||||
this.type = 'unit';
|
||||
|
@ -396,11 +396,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
return this.product;
|
||||
},
|
||||
// return the base price of this product (for this orderline)
|
||||
get_list_price: function(){
|
||||
get_price: function(){
|
||||
return this.price;
|
||||
},
|
||||
// changes the base price of the product for this orderline
|
||||
set_list_price: function(price){
|
||||
set_price: function(price){
|
||||
this.price = price;
|
||||
this.trigger('change');
|
||||
},
|
||||
|
@ -434,7 +434,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
export_as_JSON: function() {
|
||||
return {
|
||||
qty: this.get_quantity(),
|
||||
price_unit: this.get_list_price(),
|
||||
price_unit: this.get_price(),
|
||||
discount: this.get_discount(),
|
||||
product_id: this.get_product().get('id'),
|
||||
};
|
||||
|
@ -444,7 +444,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
return {
|
||||
quantity: this.get_quantity(),
|
||||
unit_name: this.get_unit().name,
|
||||
list_price: this.get_list_price(),
|
||||
price: this.get_price(),
|
||||
discount: this.get_discount(),
|
||||
product_name: this.get_product().get('name'),
|
||||
price_with_tax : this.get_price_with_tax(),
|
||||
|
@ -589,7 +589,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
line.set_quantity(options.quantity);
|
||||
}
|
||||
if(options.price !== undefined){
|
||||
line.set_list_price(options.price);
|
||||
line.set_price(options.price);
|
||||
}
|
||||
|
||||
var last_orderline = this.getLastOrderline();
|
||||
|
@ -625,7 +625,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
},
|
||||
getDiscountTotal: function() {
|
||||
return (this.get('orderLines')).reduce((function(sum, orderLine) {
|
||||
return sum + (orderLine.get_list_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
|
||||
return sum + (orderLine.get_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
|
||||
}), 0);
|
||||
},
|
||||
getTotalTaxExcluded: function() {
|
||||
|
|
|
@ -535,7 +535,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
get_product_price: function(){
|
||||
var product = this.get_product();
|
||||
return (product ? product.get('list_price') : 0) || 0;
|
||||
return (product ? product.get('price') : 0) || 0;
|
||||
},
|
||||
get_product_weight: function(){
|
||||
return this.weight || 0;
|
||||
|
|
|
@ -184,8 +184,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
order.getSelectedLine().set_quantity(val);
|
||||
}else if( mode === 'discount'){
|
||||
order.getSelectedLine().set_discount(val);
|
||||
}else if( mode === 'list_price'){
|
||||
order.getSelectedLine().set_list_price(val);
|
||||
}else if( mode === 'price'){
|
||||
order.getSelectedLine().set_price(val);
|
||||
}
|
||||
} else {
|
||||
this.pos.get('selectedOrder').destroy();
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<button class="input-button number-char">7</button>
|
||||
<button class="input-button number-char">8</button>
|
||||
<button class="input-button number-char">9</button>
|
||||
<button class="mode-button" data-mode='list_price'>Price</button>
|
||||
<button class="mode-button" data-mode='price'>Price</button>
|
||||
<br />
|
||||
<button class="input-button" id="numpad-minus" >+/-</button>
|
||||
<button class="input-button number-char">0</button>
|
||||
|
@ -387,12 +387,12 @@
|
|||
<img src='' /> <!-- the product thumbnail -->
|
||||
<t t-if="!widget.model.get('to_weight')">
|
||||
<span class="price-tag">
|
||||
<t t-esc="widget.format_currency(widget.model.get('list_price'))"/>
|
||||
<t t-esc="widget.format_currency(widget.model.get('price'))"/>
|
||||
</span>
|
||||
</t>
|
||||
<t t-if="widget.model.get('to_weight')">
|
||||
<span class="price-tag">
|
||||
<t t-esc="widget.format_currency(widget.model.get('list_price'))+'/Kg'"/>
|
||||
<t t-esc="widget.format_currency(widget.model.get('price'))+'/Kg'"/>
|
||||
</span>
|
||||
</t>
|
||||
</div>
|
||||
|
@ -510,7 +510,7 @@
|
|||
</em>
|
||||
<t t-esc="widget.model.get_unit().name" />
|
||||
at
|
||||
<t t-esc="widget.format_currency(widget.model.get_list_price())" />
|
||||
<t t-esc="widget.format_currency(widget.model.get_price())" />
|
||||
/
|
||||
<t t-esc="widget.model.get_unit().name" />
|
||||
</li>
|
||||
|
@ -584,7 +584,7 @@
|
|||
<t t-esc="order.get_quantity().toFixed(0)"/>
|
||||
</td>
|
||||
<td class="pos-right-align">
|
||||
<t t-esc="widget.format_currency(order.get_list_price() * (1 - order.get_discount()/100) * order.get_quantity().toFixed(2))"/>
|
||||
<t t-esc="widget.format_currency(order.get_price() * (1 - order.get_discount()/100) * order.get_quantity().toFixed(2))"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -295,12 +295,16 @@ class sale_order(osv.osv):
|
|||
}
|
||||
return {'warning': warning, 'value': value}
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
if not part:
|
||||
return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'payment_term': False, 'fiscal_position': False}}
|
||||
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact'])
|
||||
part = self.pool.get('res.partner').browse(cr, uid, part)
|
||||
part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
|
||||
#if the chosen partner is not a company and has a parent company, use the parent to choose the delivery, the
|
||||
#invoicing addresses and all the fields related to the partner.
|
||||
if part.parent_id and not part.is_company:
|
||||
part = part.parent_id
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
|
||||
pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
|
||||
payment_term = part.property_payment_term and part.property_payment_term.id or False
|
||||
fiscal_position = part.property_account_position and part.property_account_position.id or False
|
||||
|
@ -355,7 +359,7 @@ class sale_order(osv.osv):
|
|||
'type': 'out_invoice',
|
||||
'reference': order.client_order_ref or order.name,
|
||||
'account_id': order.partner_id.property_account_receivable.id,
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_id': order.partner_invoice_id.id,
|
||||
'journal_id': journal_ids[0],
|
||||
'invoice_line': [(6, 0, lines)],
|
||||
'currency_id': order.pricelist_id.currency_id.id,
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
</h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
|
||||
<field name="partner_invoice_id" groups="sale.group_delivery_invoice_address" context="{'default_type':'invoice'}"/>
|
||||
<field name="partner_shipping_id" groups="sale.group_delivery_invoice_address" context="{'default_type':'delivery'}"/>
|
||||
<field name="project_id" context="{'partner_id':partner_id, 'pricelist_id':pricelist_id, 'default_name':name}" groups="sale.group_analytic_accounting" domain="[('type','in',['view','normal','contract'])]"/>
|
||||
|
|
|
@ -65,7 +65,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
|||
'type': 'out_invoice',
|
||||
'reference': "P%dSO%d" % (order.partner_id.id, order.id),
|
||||
'account_id': a,
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_id': order.partner_invoice_id.id,
|
||||
'invoice_line': [(6, 0, lines)],
|
||||
'currency_id' : order.pricelist_id.currency_id.id,
|
||||
'comment': order.note,
|
||||
|
|
|
@ -139,7 +139,7 @@ class sale_advance_payment_inv(osv.osv_memory):
|
|||
'type': 'out_invoice',
|
||||
'reference': False,
|
||||
'account_id': sale.partner_id.property_account_receivable.id,
|
||||
'partner_id': sale.partner_id.id,
|
||||
'partner_id': sale.partner_invoice_id.id,
|
||||
'invoice_line': [(0, 0, inv_line_values)],
|
||||
'currency_id': sale.pricelist_id.currency_id.id,
|
||||
'comment': '',
|
||||
|
|
|
@ -87,10 +87,10 @@ class sale(osv.osv):
|
|||
result.update(invoice_type_id=order.invoice_type_id and order.invoice_type_id.id or False)
|
||||
return result
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
result = super(sale, self).onchange_partner_id(cr, uid, ids, part)
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
result = super(sale, self).onchange_partner_id(cr, uid, ids, part, context=context)
|
||||
if part:
|
||||
itype = self.pool.get('res.partner').browse(cr, uid, part).property_invoice_type
|
||||
itype = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_invoice_type
|
||||
if itype:
|
||||
result['value']['invoice_type_id'] = itype.id
|
||||
return result
|
||||
|
|
|
@ -1307,6 +1307,7 @@
|
|||
<field name="product_uos" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="product_packaging" groups="product.group_stock_packaging" domain="[('product_id','=',product_id)]"/>
|
||||
<field name="partner_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="create_date" invisible="1"/>
|
||||
|
|
|
@ -55,13 +55,13 @@ res_partner()
|
|||
|
||||
class sale_order(osv.osv):
|
||||
_inherit = 'sale.order'
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
if not part:
|
||||
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'payment_term' : False}}
|
||||
warning = {}
|
||||
title = False
|
||||
message = False
|
||||
partner = self.pool.get('res.partner').browse(cr, uid, part)
|
||||
partner = self.pool.get('res.partner').browse(cr, uid, part, context=context)
|
||||
if partner.sale_warn != 'no-message':
|
||||
if partner.sale_warn == 'block':
|
||||
raise osv.except_osv(_('Alert for %s !') % (partner.name), partner.sale_warn_msg)
|
||||
|
@ -72,7 +72,7 @@ class sale_order(osv.osv):
|
|||
'message': message,
|
||||
}
|
||||
|
||||
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
|
||||
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context)
|
||||
|
||||
if result.get('warning',False):
|
||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||
|
|
Loading…
Reference in New Issue