diff --git a/sf_base/models/sf_common.py b/sf_base/models/sf_common.py
index e45ce8e8..8dd8ac93 100644
--- a/sf_base/models/sf_common.py
+++ b/sf_base/models/sf_common.py
@@ -52,3 +52,8 @@ class MrsProcessingTechnology(models.Model):
process_encode = fields.Char("编码")
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
index=True)
+
+
+class ProductTemplate(models.Model):
+ _inherit = 'product.template'
+ _description = '产品'
diff --git a/sf_base/views/mrs_common_view.xml b/sf_base/views/mrs_common_view.xml
index 0c1128f5..c1089185 100644
--- a/sf_base/views/mrs_common_view.xml
+++ b/sf_base/views/mrs_common_view.xml
@@ -271,10 +271,11 @@
+
产品
ir.actions.act_window
- [('materials_model_ids', '!=', False)]
+
product.template
tree,form
@@ -285,19 +286,17 @@
-
- product.template.materials
- product.template
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
product.template.materials.search
product.template
diff --git a/sf_mrs_sync/__init__.py b/sf_mrs_sync/__init__.py
index 95db9a94..c081ee06 100644
--- a/sf_mrs_sync/__init__.py
+++ b/sf_mrs_sync/__init__.py
@@ -1,4 +1,2 @@
# -*-coding:utf-8-*-
from . import models
-
-pengge
\ No newline at end of file
diff --git a/sf_mrs_sync/__manifest__.py b/sf_mrs_sync/__manifest__.py
index c735f567..e3151056 100644
--- a/sf_mrs_sync/__manifest__.py
+++ b/sf_mrs_sync/__manifest__.py
@@ -10,7 +10,7 @@
""",
'category': 'YZ',
'website': 'https://www.sf.cs.jikimo.com',
- 'depends': ['account', 'sf_base'],
+ 'depends': ['account', 'sf_base', 'base'],
'data': [
'data/sf_cron.xml'
diff --git a/sf_mrs_sync/models/sf_sync_common.py b/sf_mrs_sync/models/sf_sync_common.py
index 795f9847..aa84a9e0 100644
--- a/sf_mrs_sync/models/sf_sync_common.py
+++ b/sf_mrs_sync/models/sf_sync_common.py
@@ -4,13 +4,18 @@ import math
import requests
from dateutil.relativedelta import relativedelta
from datetime import timedelta, datetime
-
+import requests
+import json
+import time
+import datetime
from odoo import models, fields, api
from odoo.exceptions import ValidationError
import logging
_logger = logging.getLogger(__name__)
+MRS = 'https://mrs.cs.jikimo.com'
+
class MrsProductionMaterials(models.Model):
_inherit = "mrs.production.materials"
@@ -18,9 +23,24 @@ class MrsProductionMaterials(models.Model):
url = '/api/production_materials/list'
def sync_production_materials(self):
- str = '定时同步材料资源库'
+ timestamp_str = int(time.time())
+ headers = {'TOKEN': '4130d97c-37be-11ed-84a7-f8b54df29535',
+ 'TIMESTAMP': '1663859413',
+ 'check_str': 'e840309b4ac386b5b9005dfb85ca9e9eee7149bd'}
+ str = MRS + self.url
print(str)
- return str
+ r = requests.post(str, data=None, json={},headers=headers)
+ r = r.json()
+ data = json.loads(r['result'])
+ if data['status'] == 1:
+ production_materials_list = data['production_materials_list']
+ if production_materials_list:
+ for item in production_materials_list:
+ port = self.env['mrs.production.materials'].search([('materials_no', '=', item.materials_no)])
+ if not port:
+ port = item
+ else:
+ return "访问失败"
class MrsMaterialModel(models.Model):