committed by
Quentin THEURET
13 changed files with 982 additions and 924 deletions
-
4base_continent/README.rst
-
12base_continent/__manifest__.py
-
14base_continent/data/continent_data.xml
-
5base_continent/data/country_data.xml
-
64base_continent/i18n/fr.po
-
23base_continent/migrations/10.0.1.0.1/post-migration.py
-
2base_continent/models/__init__.py
-
18base_continent/models/continent.py
-
9base_continent/models/country.py
-
12base_continent/models/partner.py
-
11base_continent/views/continent.xml
-
6base_continent/views/country.xml
-
6base_continent/views/partner.xml
@ -1,27 +1,37 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<odoo> |
|||
|
|||
<data noupdate="1"> |
|||
|
|||
<record id="af" model="res.continent"> |
|||
<field name="name">Africa</field> |
|||
<field name="code">AF</field> |
|||
</record> |
|||
<record id="an" model="res.continent"> |
|||
<field name="name">Antarctica</field> |
|||
<field name="code">AN</field> |
|||
</record> |
|||
<record id="as" model="res.continent"> |
|||
<field name="name">Asia</field> |
|||
<field name="code">AS</field> |
|||
</record> |
|||
<record id="eu" model="res.continent"> |
|||
<field name="name">Europe</field> |
|||
<field name="code">EU</field> |
|||
</record> |
|||
<record id="na" model="res.continent"> |
|||
<field name="name">North America</field> |
|||
<field name="code">NA</field> |
|||
</record> |
|||
<record id="oc" model="res.continent"> |
|||
<field name="name">Oceania</field> |
|||
<field name="code">OC</field> |
|||
</record> |
|||
<record id="sa" model="res.continent"> |
|||
<field name="name">South America</field> |
|||
<field name="code">SA</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
|||
|
|||
</odoo> |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 senseFly, Amaris (Author: Quentin Theuret) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
|
|||
def migrate(cr, version): |
|||
continents = [ |
|||
('af', 'AF'), |
|||
('an', 'AN'), |
|||
('as', 'AS'), |
|||
('eu', 'EU'), |
|||
('na', 'NA'), |
|||
('oc', 'OC'), |
|||
('sa', 'SA'), |
|||
] |
|||
|
|||
for xml_id, code in continents: |
|||
cr.execute(""" |
|||
UPDATE res_continent SET code = %(code)s WHERE id = ( |
|||
SELECT res_id |
|||
FROM ir_model_data |
|||
WHERE model = 'res.continent' AND name = %(xml_id)s |
|||
);""", {'code': code, 'xml_id': xml_id}) |
@ -1,5 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import base_continent |
|||
from . import continent |
|||
from . import country |
|||
from . import partner |
@ -1,12 +1,17 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2014-2016 Camptocamp SA (Author: Romain Deheele) |
|||
# © 2017 senseFly, Amaris (Author: Quentin Theuret) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import models, fields |
|||
from odoo import models |
|||
from odoo import fields |
|||
|
|||
|
|||
class Country(models.Model): |
|||
_inherit = 'res.country' |
|||
|
|||
continent_id = fields.Many2one( |
|||
'res.continent', string='Continent', ondelete='restrict') |
|||
comodel_name='res.continent', |
|||
string='Continent', |
|||
ondelete='restrict', |
|||
) |
@ -1,13 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2014-2016 Camptocamp SA (Author: Romain Deheele) |
|||
# © 2017 senseFly, Amaris (Author: Quentin Theuret) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import models, fields |
|||
from odoo import models |
|||
from odoo import fields |
|||
|
|||
|
|||
class Partner(models.Model): |
|||
_inherit = 'res.partner' |
|||
|
|||
continent_id = fields.Many2one( |
|||
'res.continent', related='country_id.continent_id', |
|||
string='Continent', readonly=True, store=True) |
|||
'res.continent', |
|||
related='country_id.continent_id', |
|||
string='Continent', |
|||
readonly=True, |
|||
store=True, |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue