diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index f99704a27cc..ec17ec2a031 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -33,6 +33,9 @@ import netsvc
from osv import fields, osv
from tools.translate import _
+import mx.DateTime
+from mx.DateTime import RelativeDateTime, now, DateTime, localtime
+
class account_move_line(osv.osv):
_name = "account.move.line"
_description = "Entry lines"
@@ -336,20 +339,30 @@ class account_move_line(osv.osv):
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
- def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, journal=False):
- if (not partner_id) or account_id:
- return {}
- part = self.pool.get('res.partner').browse(cr, uid, partner_id)
- id1 = part.property_account_payable.id
- id2 = part.property_account_receivable.id
+ def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False):
val = {}
- if journal:
- jt = self.pool.get('account.journal').browse(cr, uid, journal).type
- if jt=='sale':
- val['account_id'] = id2
- elif jt=='purchase':
- val['account_id'] = id1
- # Compute Maturity Date in val !
+ val['date_maturity'] = False
+ if not partner_id:
+ return {'value':val}
+ if not date:
+ date = now().strftime('%Y-%m-%d')
+ part = self.pool.get('res.partner').browse(cr, uid, partner_id)
+ if part.property_payment_term and part.property_payment_term.line_ids:# Compute Maturity Date in val !
+ line = part.property_payment_term.line_ids[0]
+ next_date = mx.DateTime.strptime(date, '%Y-%m-%d') + RelativeDateTime(days=line.days)
+ if line.condition == 'end of month':
+ next_date += RelativeDateTime(day=-1)
+ next_date = next_date.strftime('%Y-%m-%d')
+ val['date_maturity'] = next_date
+ if not account_id:
+ id1 = part.property_account_payable.id
+ id2 = part.property_account_receivable.id
+ if journal:
+ jt = self.pool.get('account.journal').browse(cr, uid, journal).type
+ if jt=='sale':
+ val['account_id'] = id2
+ elif jt=='purchase':
+ val['account_id'] = id1
return {'value':val}
#
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index a1f94a9608b..a81e55824ec 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -672,7 +672,7 @@
-
+
@@ -725,7 +725,7 @@
-
+
@@ -807,7 +807,7 @@
-
+
@@ -829,7 +829,7 @@
-
+
diff --git a/addons/profile_manufacturing/profile_manufacturing.py b/addons/profile_manufacturing/profile_manufacturing.py
index abe5ddcf075..bb660552587 100644
--- a/addons/profile_manufacturing/profile_manufacturing.py
+++ b/addons/profile_manufacturing/profile_manufacturing.py
@@ -31,7 +31,7 @@ import pooler
class config_install_extra_modules(osv.osv_memory):
- _name='config.install_extra_modules'
+ _name='config.install_extra_modules.mrp'
_columns = {
'mrp_jit':fields.boolean('Just in Time Scheduling',
help="The JIT module allows you to not run the scheduler "\
diff --git a/addons/profile_service/security/ir.model.access.csv b/addons/profile_service/security/ir.model.access.csv
index 07c7312f535..97dd8b917b8 100644
--- a/addons/profile_service/security/ir.model.access.csv
+++ b/addons/profile_service/security/ir.model.access.csv
@@ -1,2 +1 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_config_install_extra_modules,config.install_extra_modules,model_config_install_extra_modules,base.group_system,1,1,1,1
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 7c95282f78d..de6e4abf0b9 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -322,6 +322,9 @@ class sale_order(osv.osv):
'comment': order.note,
'payment_term': pay_term,
}
+ data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id],
+ pay_term,time.strftime('%Y-%m-%d'))
+ inv.update(data['value'])
inv.update(self._inv_get(cr, uid, order))
inv_obj = self.pool.get('account.invoice')
inv_id = inv_obj.create(cr, uid, inv)