diff --git a/addons/account/chart_template.py b/addons/account/chart_template.py
index 42495463e52..a5cdd738502 100644
--- a/addons/account/chart_template.py
+++ b/addons/account/chart_template.py
@@ -83,6 +83,9 @@ class AccountChartTemplate(models.Model):
property_account_income_categ = fields.Many2one('account.account.template', string='Income Category Account')
property_account_expense = fields.Many2one('account.account.template', string='Expense Account on Product Template')
property_account_income = fields.Many2one('account.account.template', string='Income Account on Product Template')
+ property_stock_account_input_categ = fields.Many2one('account.account.template')
+ property_stock_account_output_categ = fields.Many2one('account.account.template')
+ property_stock_valuation_account_id = fields.Many2one('account.account.template')
@api.one
def try_loading_for_current_company(self):
@@ -228,6 +231,16 @@ class AccountChartTemplate(models.Model):
else:
#create the property
PropertyObj.create(vals)
+ stock_properties = [
+ 'property_stock_account_input_categ',
+ 'property_stock_account_output_categ',
+ 'property_stock_valuation_account_id',
+ ]
+ for stock_property in stock_properties:
+ account = getattr(self, stock_property)
+ value = account and acc_template_ref[account.id] or False
+ if value:
+ company.write({stock_property: value})
return True
@api.multi
diff --git a/addons/account/company.py b/addons/account/company.py
index 2ea1c6a7c00..d7c0a2686f3 100644
--- a/addons/account/company.py
+++ b/addons/account/company.py
@@ -31,6 +31,9 @@ class ResCompany(models.Model):
expense_currency_exchange_account_id = fields.Many2one('account.account', related='currency_exchange_journal_id.default_debit_account_id',
string="Loss Exchange Rate Account", domain="[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', id)]")
anglo_saxon_accounting = fields.Boolean(string="Use anglo-saxon accounting")
+ property_stock_account_input_categ = fields.Many2one('account.account')
+ property_stock_account_output_categ = fields.Many2one('account.account')
+ property_stock_valuation_account_id = fields.Many2one('account.account')
@api.multi
def compute_fiscalyear_dates(self, date):
diff --git a/addons/l10n_ca/__openerp__.py b/addons/l10n_ca/__openerp__.py
index 384093566e4..2c6c12a6d22 100644
--- a/addons/l10n_ca/__openerp__.py
+++ b/addons/l10n_ca/__openerp__.py
@@ -39,7 +39,6 @@ position.
'account',
'base_iban',
'base_vat',
- 'stock',
],
'data': [
'account_chart_en.xml',
diff --git a/addons/l10n_ca/account_chart_en.xml b/addons/l10n_ca/account_chart_en.xml
index 86228db2c35..76d7e80b535 100644
--- a/addons/l10n_ca/account_chart_en.xml
+++ b/addons/l10n_ca/account_chart_en.xml
@@ -754,7 +754,7 @@
512302
-
Employment Insurance
diff --git a/addons/l10n_ca/account_chart_template_en.xml b/addons/l10n_ca/account_chart_template_en.xml
index 50644e57714..4aa30bf3599 100644
--- a/addons/l10n_ca/account_chart_template_en.xml
+++ b/addons/l10n_ca/account_chart_template_en.xml
@@ -12,29 +12,12 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- property_stock_valuation_account_id
-
-
-
-
-
-
diff --git a/addons/l10n_ca/account_chart_template_fr.xml b/addons/l10n_ca/account_chart_template_fr.xml
index 2016742b471..754cd061d9a 100644
--- a/addons/l10n_ca/account_chart_template_fr.xml
+++ b/addons/l10n_ca/account_chart_template_fr.xml
@@ -1,39 +1,22 @@
-
+
-
-
- Canada - Plan comptable pour les provinces francophones
-
-
-
-
-
-
-
-
-
+
+
+ Canada - Plan comptable pour les provinces francophones
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- property_stock_valuation_account_id
-
-
-
-
-
-
-
+
diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py
index b6dca4a4aca..f92cd602524 100644
--- a/addons/stock_account/stock_account.py
+++ b/addons/stock_account/stock_account.py
@@ -425,7 +425,7 @@ class AccountChartTemplate(models.Model):
@api.multi
def generate_properties(self, acc_template_ref, company, property_list=None):
super(AccountChartTemplate, self).generate_properties(acc_template_ref=acc_template_ref, company=company)
- PropertyObj = self.env['ir.property']
+ PropertyObj = self.env['ir.property'] # Property Stock Journal
value = self.env['account.journal'].search([('company_id', '=', company.id), ('code', '=', 'STJ'), ('type', '=', 'general')], limit=1)
if value:
field = self.env['ir.model.fields'].search([('name', '=', 'property_stock_journal'), ('model', '=', 'product.category'), ('relation', '=', 'account.journal')], limit=1)
@@ -442,4 +442,30 @@ class AccountChartTemplate(models.Model):
else:
#create the property
PropertyObj.create(vals)
- return True
\ No newline at end of file
+
+ todo_list = [ # Property Stock Accounts
+ 'property_stock_account_input_categ',
+ 'property_stock_account_output_categ',
+ 'property_stock_valuation_account_id',
+ ]
+ for record in todo_list:
+ account = getattr(self, record)
+ value = account and 'account.account,' + str(acc_template_ref[account.id]) or False
+ if value:
+ field = self.env['ir.model.fields'].search([('name', '=', record), ('model', '=', 'product.category'), ('relation', '=', 'account.account')], limit=1)
+ vals = {
+ 'name': record,
+ 'company_id': company.id,
+ 'fields_id': field.id,
+ 'value': value,
+ 'res_id': 'product.category,'+str(self.env['ir.model.data'].xmlid_to_res_id('product.product_category_all')),
+ }
+ properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id)])
+ if properties:
+ #the property exist: modify it
+ properties.write(vals)
+ else:
+ #create the property
+ PropertyObj.create(vals)
+
+ return True
diff --git a/addons/stock_account/stock_account_post_install.yml b/addons/stock_account/stock_account_post_install.yml
index 9c809124b3a..6d9e6a08849 100644
--- a/addons/stock_account/stock_account_post_install.yml
+++ b/addons/stock_account/stock_account_post_install.yml
@@ -26,3 +26,26 @@
'value': 'account.journal,' + str(journal_id)}
PropertyObj.create(cr, uid, vals)
+
+ todo_list = [ # Property Stock Accounts
+ 'property_stock_account_input_categ',
+ 'property_stock_account_output_categ',
+ 'property_stock_valuation_account_id',
+ ]
+ company = company_obj.browse(cr, uid, company_id)
+ for record in todo_list:
+ account = getattr(company, record)
+ value = account and 'account.account,' + str(account.id) or False
+ if value:
+ field_id = self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', record), ('model', '=', 'product.category'), ('relation', '=', 'account.account')], limit=1)[0]
+ vals = {
+ 'name': record,
+ 'company_id': company_id,
+ 'fields_id': field_id,
+ 'value': value,
+ 'res_id': 'product.category,'+str(ref('product.product_category_all')),
+ }
+ properties = PropertyObj.search(cr, uid, [('name', '=', record), ('company_id', '=', company.id), ('value_reference', '!=', False)])
+ if not properties:
+ #create the property
+ PropertyObj.create(cr, uid, vals)
\ No newline at end of file