[MIG] ensan_dynamic_dedicationcard

This commit is contained in:
Abdurrahman Saber 2025-04-14 13:37:46 +02:00
parent 3694786630
commit 7bae571093
10 changed files with 119 additions and 232 deletions

View File

@ -1,2 +1 @@
from . import controller
from . import models

View File

@ -1,30 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name' : 'ensan dynamic dedicationcard',
'version' : '1.0',
'name': 'ensan dynamic dedicationcard',
'version': '1.0',
'summary': 'ensan dynamic dedicationcard',
'description': """
ensan dynamic dedicationcard
====================
get dynamic dedicationcard via url """,
'depends' : ['product'],
'assets': {
'web.assets_backend': [
'ensan_dynamic_dedicationcard/static/src/css/style.css',
],
# 'web.assets_frontend': [
# 'ensan_dynamic_dedicationcard/static/src/css/style.css',
# ],
},
'data': [
'views/gift_template.xml',
#'views/product_template_view.xml',
],
"images": ['img/7_page-0001.jpg','img/top121.jpg','img/bottom121.jpg'],
ensan dynamic dedicationcard
====================
get dynamic dedicationcard via url
""",
'depends': ['product', 'sale', 'ensan_sale_management'],
'data': ['views/gift_template.xml'],
"images": ['img/7_page-0001.jpg', 'img/top121.jpg', 'img/bottom121.jpg'],
}

View File

@ -1,2 +1 @@
from . import controller
#from . import mycontroller

View File

@ -1,58 +1,21 @@
from odoo import http
from odoo.exceptions import AccessError, UserError
from odoo.http import request
from odoo.tools import consteq, file_open
from odoo.tools.misc import get_lang
from odoo.tools.translate import _
from werkzeug.exceptions import NotFound
import datetime
import logging
import os
import re
import tempfile
from lxml import html
import odoo
import odoo.modules.registry
from odoo import http
from odoo.http import content_disposition, dispatch_rpc, request, Response
from odoo.service import db
from odoo.tools.misc import file_open, str2bool
from odoo.tools.translate import _
from odoo.addons.base.models.ir_qweb import render as qweb_render
import logging
from cryptography.fernet import Fernet
_logger = logging.getLogger(__name__)
class Controller(http.Controller):
@http.route(
['/card/<string:order>',
'/ar/card/<string:order>',
'/en/card/<string:order>',
],
methods=['GET'], type='http', auth='public')
def mail_init_messaging_custom(self,order='', **kwargs):
values = dict(kwargs)
@http.route(['/card/<string:order>'], methods=['GET'], type='http', auth='public')
def mail_init_messaging_custom(self, order='', **kwargs):
name = None
from_person = 'فاعل خير '
to_person = 'المهدى إليه'
sale_order_extra_donators_line = request.env['sale.order.extra_donators'].sudo().search([('id','=',order[3:-3])])
sale_order_extra_donators_line = request.env['sale.order.extra_donators'].sudo().search([('id', '=', order[3:-3])])
if sale_order_extra_donators_line.product_id.name:
name =sale_order_extra_donators_line.product_id.name
name = sale_order_extra_donators_line.product_id.name
if sale_order_extra_donators_line.sale_id.order_name:
from_person = sale_order_extra_donators_line.sale_id.order_name
from_person = sale_order_extra_donators_line.sale_id.order_name
if sale_order_extra_donators_line.donator_name:
to_person = sale_order_extra_donators_line.donator_name
to_person = sale_order_extra_donators_line.donator_name
return request.render('ensan_dynamic_dedicationcard.gift_template_id',
{'records': [name], 'from_persons': [from_person], 'to_persons': [to_person]})

View File

@ -1,24 +0,0 @@
from odoo import http
from odoo.http import request
class MyController(http.Controller):
@http.route('/my_controller/post', type='http', auth="public", methods=['GET', 'POST'])
def post_method(self, **post):
# Access the posted data using the 'post' dictionary
name = post.get('name')
from_person = post.get('from_person')
to_person = post.get('to_person')
print(name,'name')
print(from_person,'from_person')
print(to_person,'to_person')
# Perform necessary actions with the posted data
# Add your code here
# Return an HTTP response if needed
return request.render('ensan_dynamic_dedicationcard.gift_template_id',
{'records': [name], 'from_persons': [from_person], 'to_persons': [to_person]})

View File

@ -1 +0,0 @@
#from . import product_template

View File

@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models,fields
import requests
class ProductTemplate(models.Model):
_inherit = 'product.template'
def do_post_request(self,name='dedication',from_person='shehab',to_person='gamal'):
url = 'http://ensan.varietyit.com/my_controller/post' # Replace with your Odoo server URL and route
# Define the data to be sent in the POST request
data = {
'name':name,
'from_person': from_person,
'to_person': to_person,
}
# Make the POST request
response = requests.post(url, data=data)
# Check the response status code and content
if response.status_code == 200:
print('POST request successful!')
print('Response:', response.content.decode())
else:
print('POST request failed!')
print('Response:', response.content.decode())

View File

@ -19,7 +19,69 @@ font-family:'traditional_arabic';;font-weight:100;font-size: 13px;
.arabic{
font-family:GretaArabicBold !important;
}
.container {
width: 100%;
}
.name-heading {
border-bottom: 5px solid #216b5e;
width: 100%;
text-align: center;
font-size: 8vw !important;
color: #216b5e;
font-weight: bold;
font-family: GretaArabicBold;
}
.person-table {
border-radius: 50px;
border-right-style: solid;
border-left-style: solid;
border-bottom-style: solid;
border-top-style: solid;
border-bottom-right-radius: 22px;
border-top-right-radius: 22px;
border-top-left-radius: 22px;
border-bottom-left-radius: 22px;
border-spacing: 0 11px;
margin-top: -20px;
margin-bottom: -10px;
color: black;
border-color: white;
}
.person-row {
border-radius: 25px;
padding: 1pt;
margin: 0pt;
font-weight: bold;
text-align: center;
background-color: #eaecee;
border: 2px solid red;
border-radius: 25px;
border-color: white;
}
.person-cell {
padding-left: 20px;
padding-right: 20px;
font-size: 4.5vw;
color: #2bab98;
font-weight: bold;
text-align: center;
border-color: white;
font-family: GretaArabicBold;
}
.person-label {
font-size: 4.5vw;
color: #2bab98;
font-weight: bold;
text-align: center;
border-color: white;
font-family: GretaArabicBold;
}

View File

@ -1,100 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="gift_template_id" name="gift template">&lt;!DOCTYPE html&gt;
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/ensan_dynamic_dedicationcard/static/src/css/style.css"/>
</head>
<body>
<div class="container">
<img t-att-src="'/ensan_dynamic_dedicationcard/static/src/img/top121.jpg'" width="100%"/>
<t t-foreach="records" t-as="record">
<table align="center" style=";color:black; margin-top:0px;"
class="table-condensed table-sm">
<tr style=" padding:1pt;margin:0pt;font-weight: bold;text-align:center;">
<!-- <h1>-->
<td class="col-1 text-center arabic"
style=" border-bottom: 5px solid #216b5e; width:100%;text-align:center; font-size: 8vw !important; color: #216b5e;font-weight:bold;font-family:GretaArabicBold;"
t-esc="record"/>
<!-- </h1>-->
<template id="gift_template_id" name="gift template">
<t t-call="web.layout">
<t t-set="head">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css"
href="/ensan_dynamic_dedicationcard/static/src/css/style.css" />
</t>
<div class="container">
<img t-att-src="'/ensan_dynamic_dedicationcard/static/src/img/top121.jpg'"
width="100%" />
<t t-foreach="records" t-as="record">
<table align="center" class="table-condensed table-sm">
<tr>
<td class="col-1 text-center arabic name-heading" t-esc="record" />
</tr>
</table>
</t>
<br />
<t t-foreach="from_persons" t-as="from_person">
<t t-foreach="to_persons" t-as="to_person">
<table align="center" class="table-condensed table-sm person-table">
<tr class="person-row">
<td class="col-1 text-center arabic person-cell">
<span t-esc="from_person" />
</td>
<td class="col-1 text-center arabic person-label">
: من
</td>
</tr>
<tr class="person-row">
<td class="col-1 text-center arabic person-cell">
<span t-esc="to_person" />
</td>
<td class="col-1 text-center arabic person-label">
: إلى
</td>
</tr>
</table>
</t>
<br/>
<t t-foreach="from_persons" t-as="from_person">
<t t-foreach="to_persons" t-as="to_person">
</t>
<table align="center" style=" border-radius: 50px;border-right-style:solid;border-left-style:solid;border-bottom-style:solid;
border-top-style:solid; border-bottom-right-radius:22px;border-top-right-radius:22px;
border-top-left-radius:22px;border-bottom-left-radius:22px;border-spacing:0 11px;
margin-top:-20px;margin-bottom:-10px;color:black;border-color: white;"
class="table-condensed table-sm">
<tr style=" border-radius: 25px;padding:1pt;margin:0pt;font-weight: bold;
text-align:center; background-color: #eaecee;border: 2px solid red;
border-radius:25px;border-color: white;">
<!-- <h5>-->
<td class="col-1 text-center arabic"
style="padding-left:20px;padding-right:20px;
font-size: 4.5vw; color: #2bab98;font-weight:bold;
text-align:center; border-color: white;font-family:GretaArabicBold;"
>
<span t-esc="from_person"/>
</td>
<td class="col-1 text-center arabic"
style="
font-size: 4.5vw; color: #2bab98;font-weight:bold;
text-align:center; border-color: white; font-family:GretaArabicBold;"
>
: من
<!-- <span>من :</span>-->
<!-- <span t-esc="from_person"/>-->
</td>
<!-- </h5>-->
</tr>
<tr style="border-radius: 25px;padding:1pt;margin:0pt;font-weight: bold;
text-align:center; background-color:#eaecee;border: 2px solid red;
border-radius:25px;border-color: white;">
<!-- <h5>-->
<td class="col-1 text-center arabic"
style="padding-left:20px;padding-right:20px; font-size: 4.5vw;
color: #2bab98;font-weight:bold; text-align:center; border-color: white;font-family:GretaArabicBold;"
>
<!-- <span>إلى :</span>-->
<span t-esc="to_person"/>
</td>
<td class="col-1 text-center arabic"
style=" font-size: 4.5vw;
color: #2bab98;font-weight:bold; text-align:center; border-color: white;font-family:GretaArabicBold;"
>
: إلى
</td>
<!-- </h5>-->
</tr>
</table>
</t>
</t>
<img t-att-src="'/ensan_dynamic_dedicationcard/static/src/img/bottom121.jpg'" width="100.6%"/>
</div>
</body>
</html>
<img t-att-src="'/ensan_dynamic_dedicationcard/static/src/img/bottom121.jpg'"
width="100.6%" />
</div>
</t>
</template>
</odoo>
</odoo>

View File

@ -1,15 +0,0 @@
<odoo>
<data>
<record id="product_template_inherit" model="ir.ui.view">
<field name="name">product_template_inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref ="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<button name="action_open_label_layout" position="after">
<button name="do_post_request" string="POST" type="object"/>
</button>
</field>
</record>
</data>
</odoo>