-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
4,543 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import controllers | ||
from . import config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import json | ||
|
||
from odoo import http | ||
|
||
from .error_code import error_code | ||
|
||
|
||
class Config(http.Controller): | ||
@http.route('/<model("res.users"):user>/config/get-value', auth='public') | ||
def get(self, user, key=None): | ||
if not key: | ||
return json.dumps({'code': 300, 'msg': error_code[300]}) | ||
|
||
config = http.request.env['wechat_mall.config.settings'] | ||
value_obj = config.get_config(key, uid=user.id, obj=True) | ||
if not value_obj: | ||
return json.dumps({'code': 404, 'msg': error_code[404]}) | ||
|
||
response = { | ||
'code': 0, | ||
'data': { | ||
'creatAt': value_obj.create_date, | ||
'dateType': 0, | ||
'id': value_obj.id, | ||
'key': key, | ||
'remark': '', | ||
'updateAt': value_obj.write_date, | ||
'userId': user.id, | ||
'value': config.get_config(key, uid=user.id) | ||
}, | ||
'msg': 'success' | ||
} | ||
return json.dumps(response) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
error_code = { | ||
-1: u'服务器内部错误', | ||
0: u'接口调用成功', | ||
403: u'禁止访问', | ||
405: u'错误的请求类型', | ||
501: u'数据库错误', | ||
502: u'并发异常,请重试', | ||
600: u'缺少参数', | ||
601: u'无权操作:缺少 token', | ||
602: u'签名错误', | ||
700: u'暂无数据', | ||
701: u'该功能暂未开通', | ||
702: u'资源余额不足', | ||
901: u'token错误', | ||
300: u'缺少key参数', | ||
400: u'域名错误', | ||
401: u'该域名已删除', | ||
402: u'该域名已禁用', | ||
404: u'暂无数据', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .utils import Const | ||
|
||
|
||
class LogisticsValuationType(Const): | ||
by_piece = ('by_piece', u'按件') | ||
|
||
|
||
class TransportType(Const): | ||
express = ('express', u'快递') | ||
ems = ('ems', u'EMS') | ||
post = ('post', u'平邮') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models | ||
from . import banner | ||
from . import category | ||
from . import city | ||
from . import config | ||
from . import district | ||
from . import goods | ||
from . import logistics | ||
from . import order | ||
from . import province | ||
from . import subshop | ||
from . import transportation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields, api | ||
|
||
|
||
class Banner(models.Model): | ||
_name = 'wechat_mall.banner' | ||
_description = u'横幅' | ||
|
||
user_id = fields.Many2one('res.users', string='所属用户') | ||
type_mark = fields.Integer(string='类型标记(用于扩展)') | ||
business_id = fields.Integer(string='业务编号') | ||
title = fields.Char(string='名称', required=True) | ||
pic = fields.Binary(string='横幅图片', attachment=True) | ||
link_url = fields.Char(string='链接地址') | ||
sort = fields.Integer(string='排序') | ||
remark = fields.Text(string='备注') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields, api | ||
|
||
|
||
class Category(models.Model): | ||
_name = 'wechat_mall.category' | ||
_description = u'商品分类' | ||
|
||
user_id = fields.Many2one('res.users', string='所属用户') | ||
name = fields.Char(string='名称') | ||
category_type = fields.Char(string='类型') | ||
pid = fields.Many2one('wechat_mall.category', string='上级分类') | ||
key = fields.Char(string='编号') | ||
icon = fields.Binary(string='图标') | ||
level = fields.Integer(string='分类级别') | ||
is_use = fields.Boolean(string='是否启用') | ||
sort = fields.Integer(string='排序') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class City(models.Model): | ||
_name = 'wechat_mall.city' | ||
_description = u'市' | ||
|
||
pid = fields.Many2one('wechat_mall.province', string='省') | ||
name = fields.Char('名称') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields, api | ||
|
||
|
||
class ConfigSettings(models.Model): | ||
_name = 'wechat_mall.config.settings' | ||
_description = u'基本设置' | ||
_inherit = 'res.config.settings' | ||
|
||
mall_name = fields.Char('商城名称', help='显示在小程序顶部') | ||
|
||
@api.model | ||
def default_get(self, fields_list): | ||
return {field: self.get_config(field) for field in fields_list} | ||
|
||
@api.multi | ||
def set_default_all(self): | ||
self.env['ir.values'].set_default('wechat_mall.config.settings', 'mall_name_{uid}'.format(uid=self.env.uid), | ||
self.mall_name) | ||
|
||
def get_config(self, config_name, uid=False, obj=False): | ||
uid = uid if uid else self.env.uid | ||
if obj: | ||
return self.env['ir.values'].search([('name', '=', '{config_name}_{uid}'.format(uid=uid, | ||
config_name=config_name))]) | ||
return self.env['ir.values'].get_default(model=self._name, | ||
field_name='{config_name}_{uid}'.format(uid=uid, | ||
config_name=config_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields, api | ||
|
||
|
||
class District(models.Model): | ||
_name = 'wechat_mall.district' | ||
_description = u'区' | ||
|
||
pid = fields.Many2one('wechat_mall.city', string='市') | ||
name = fields.Char('名称') | ||
|
||
@api.model_cr | ||
def _register_hook(self): | ||
""" stuff to do right after the registry is built """ | ||
from .. import data | ||
self.env.cr.execute(data.province_city_district_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class Goods(models.Model): | ||
_name = 'wechat_mall.goods' | ||
_description = u'商品' | ||
|
||
user_id = fields.Many2one('res.users', string='所属用户') | ||
subshop_id = fields.Many2one('wechat_mall.subshop', string='所属店铺') | ||
category_id = fields.Many2one('wechat_mall.category', string='商品分类') | ||
name = fields.Char('商品名称') | ||
characteristic = fields.Text('商品特色') | ||
logistics_id = fields.Many2one('wechat_mall.logistics', string='物流模板') | ||
sort = fields.Integer('排序') | ||
recommend_status = fields.Boolean('是否推荐') | ||
pic = fields.One2many('ir.attachment', 'res_id', string='图片') | ||
content = fields.Html('详细介绍') | ||
original_price = fields.Float('原价') | ||
min_price = fields.Float('最低价') | ||
stores = fields.Integer('库存') | ||
number_good_reputation = fields.Integer('好评数') | ||
number_order = fields.Integer('订单数') | ||
number_fav = fields.Integer('收藏数') | ||
views = fields.Integer('浏览量') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
from .. import defs | ||
|
||
|
||
class Logistics(models.Model): | ||
_name = 'wechat_mall.logistics' | ||
_description = u'物流' | ||
|
||
name = fields.Char('名称') | ||
free = fields.Boolean('是否包邮') | ||
valuation_type = fields.Selection(defs.LogisticsValuationType.attrs.items(), string='计价方式') | ||
|
||
transportation_ids = fields.One2many('wechat_mall.transportation', 'logistics_id', string='运送费用') | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class Province(models.Model): | ||
_name = 'wechat_mall.province' | ||
_description = u'省' | ||
|
||
name = fields.Char('名称') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields, api | ||
|
||
|
||
class SubShop(models.Model): | ||
_name = 'wechat_mall.subshop' | ||
_description = u'商铺' | ||
|
||
user_id = fields.Many2one('res.users', string='所属用户') | ||
shop_type = fields.Char('店铺类型') | ||
province_id = fields.Many2one('wechat_mall.province', string='省', required=True) | ||
city_id = fields.Many2one('wechat_mall.city', string='市', required=True) | ||
district_id = fields.Many2one('wechat_mall.district', string='区', required=True) | ||
name = fields.Char('店铺名称', required=True) | ||
address = fields.Char('地址') | ||
phone = fields.Char('联系电话') | ||
introduce = fields.Text('店铺介绍') | ||
characteristic = fields.Text('店铺特色') | ||
sort = fields.Integer('排序') | ||
pic = fields.Binary('图片', attachment=True) | ||
activity = fields.Char('打折优惠信息') | ||
latitude = fields.Float('纬度') | ||
longitude = fields.Float('经度') | ||
number_good_reputation = fields.Integer('好评数') | ||
number_order = fields.Integer('订单数') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import models, fields | ||
|
||
from .. import defs | ||
|
||
|
||
class Transportation(models.Model): | ||
_name = 'wechat_mall.transportation' | ||
_description = u'运输费' | ||
|
||
user_id = fields.Many2one('res.users', string='所属用户') | ||
logistics_id = fields.Many2one('wechat_mall.logistics', string='物流') | ||
transport_type = fields.Selection(defs.TransportType.attrs.items(), string='运输方式', required=True) | ||
province_id = fields.Many2one('wechat_mall.province', string='省', required=True) | ||
city_id = fields.Many2one('wechat_mall.city', string='市', required=True) | ||
district_id = fields.Many2one('wechat_mall.district', string='区', required=True) | ||
less_amount = fields.Integer('数量', required=True) | ||
less_price = fields.Float('数量内价格', required=True) | ||
beyond_amount = fields.Integer('超过数量', required=True) | ||
beyond_price = fields.Float('递增价格', required=True) |
Oops, something went wrong.