更新同步模块
This commit is contained in:
@@ -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 = '产品'
|
||||
|
||||
@@ -271,10 +271,11 @@
|
||||
</field>
|
||||
</record>
|
||||
<!--产品-->
|
||||
<!-- <field name="domain">[('materials_model_ids', '!=', False)]</field>-->
|
||||
<record id="sf_product_template" model="ir.actions.act_window">
|
||||
<field name="name">产品</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="domain">[('materials_model_ids', '!=', False)]</field>
|
||||
|
||||
<field name="res_model">product.template</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help" type="html">
|
||||
@@ -285,19 +286,17 @@
|
||||
</field>
|
||||
|
||||
</record>
|
||||
<record id="view_product_account_purchase_ok_form" model="ir.ui.view">
|
||||
<field name="name">product.template.materials</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="account.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after" >
|
||||
<group>
|
||||
<field name="materials_model_ids" widget="many2many"/>
|
||||
</group>
|
||||
<!-- <record id="view_product_account_purchase_ok_form" model="ir.ui.view">-->
|
||||
<!-- <field name="name">product.template.materials</field>-->
|
||||
<!-- <field name="model">product.template</field>-->
|
||||
<!-- <field name="inherit_id" ref="account.product_template_form_view"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <field name="name" position="after" >-->
|
||||
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- </field>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<record id="view_product_account_purchase_ok_search" model="ir.ui.view">
|
||||
<field name="name">product.template.materials.search</field>
|
||||
<field name="model">product.template</field>
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from . import models
|
||||
|
||||
pengge
|
||||
@@ -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'
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user