report ann
This commit is contained in:
parent
0231697b84
commit
e17e041508
|
|
@ -15,6 +15,7 @@
|
|||
"views/addendum_views.xml",
|
||||
"views/purchase_requisition.xml",
|
||||
"data/mail_activity.xml",
|
||||
"data/new_mail.xml",
|
||||
"views/menu.xml",
|
||||
"views/annual_rfq_views.xml",
|
||||
"views/report_annual_rfq.xml",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="email_template_annual_rfq_new" model="mail.template">
|
||||
<field name="name">Purchase Order: Send RFQ</field>
|
||||
<field name="model_id" ref="odex25_annual_purchase.model_annual_rfq"/>
|
||||
<field name="subject">طلب عرض سعر ${object.name or ''}</field>
|
||||
<field name="body_html" type="html">
|
||||
<div style="margin: 0px; padding: 0px;">
|
||||
<p style="margin: 0px; padding: 0px; font-size: 13px; font-family: Arial, sans-serif; direction: rtl; text-align: right;">
|
||||
السادة ${object.vendor_id.name}
|
||||
% if object.vendor_id.parent_id:
|
||||
(${object.vendor_id.parent_id.name})
|
||||
% endif
|
||||
<br/><br/>
|
||||
يُرفق إليكم طلب عرض السعر الخاص بالطلب رقم <strong>${object.name}</strong>
|
||||
% if object.partner_ref:
|
||||
بالمرجع: ${object.partner_ref}
|
||||
% endif
|
||||
من ${object.company_id.name}.
|
||||
<br/><br/>
|
||||
في حال وجود أي استفسارات، لا تترددوا في التواصل معنا بالرد على هذا الايميل .
|
||||
<br/><br/>
|
||||
مع أطيب التحيات،
|
||||
</p>
|
||||
</div></field>
|
||||
<field name="report_template" ref="action_report_annual_rfq"/>
|
||||
<field name="report_name">${(object.name or '').replace('/','_')}</field>
|
||||
<field name="lang">ar</field>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -384,16 +384,28 @@ class AnnualPurchaseRequest(models.Model):
|
|||
rec._check_lines()
|
||||
if rec.agreement_id:
|
||||
raise UserError(_("Agreement already linked."))
|
||||
|
||||
winning_rfq = rec.rfq_ids.filtered(lambda r: r.recommendation_order or r.state == 'po')
|
||||
if not winning_rfq:
|
||||
raise UserError(_("No winning RFQ found for this request."))
|
||||
|
||||
winning_rfq = winning_rfq[0]
|
||||
|
||||
agreement = self.env['purchase.requisition'].create({
|
||||
'type_id': self.env['purchase.requisition.type'].search([('exclusive','=','multiple')], limit=1).id or False,
|
||||
'type_id': self.env['purchase.requisition.type'].search([('exclusive', '=', 'multiple')],
|
||||
limit=1).id or False,
|
||||
'user_id': self.env.user.id,
|
||||
'vendor_id': rec.vendor_id.id,
|
||||
'category_ids': rec.product_category_ids,
|
||||
'purpose': rec.purpose,
|
||||
'purchase_cost': 'product_line',
|
||||
'vendor_id': winning_rfq.vendor_id.id,
|
||||
'ordering_date': fields.Date.context_today(self),
|
||||
'schedule_date': rec.date_end,
|
||||
'name': "%s - %s" % (rec.name, rec.purpose or ''),
|
||||
'annual_request_id': rec.id,
|
||||
})
|
||||
for line in rec.line_ids:
|
||||
|
||||
for line in winning_rfq.line_ids:
|
||||
self.env['purchase.requisition.line'].create({
|
||||
'requisition_id': agreement.id,
|
||||
'product_id': line.product_id.id,
|
||||
|
|
@ -403,11 +415,20 @@ class AnnualPurchaseRequest(models.Model):
|
|||
'schedule_date': rec.date_end,
|
||||
'name': line.description or line.product_id.display_name,
|
||||
})
|
||||
|
||||
attachments = self.env['ir.attachment'].search([
|
||||
('res_model', '=', 'annual.rfq'),
|
||||
('res_id', '=', winning_rfq.id)
|
||||
])
|
||||
for attachment in attachments:
|
||||
attachment.copy({
|
||||
'res_model': 'purchase.requisition',
|
||||
'res_id': agreement.id,
|
||||
})
|
||||
|
||||
rec.agreement_id = agreement.id
|
||||
rec.message_post(body=_("Purchase Agreement created and linked."))
|
||||
self.write({'state':'approved'})
|
||||
|
||||
|
||||
rec.message_post(body=_("Purchase Agreement created and linked with winning RFQ and attachments."))
|
||||
self.write({'state': 'approved'})
|
||||
|
||||
|
||||
class AnnualPurchaseRequestLine(models.Model):
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ class PurchaseRFQ(models.Model):
|
|||
_name = 'annual.rfq'
|
||||
_description = 'Request for Quotation'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_copy = False # تعطيل النسخ لحجب زر الاستنساخ
|
||||
|
||||
|
||||
name = fields.Char(string='Reference Number', default='New', copy=False, tracking=True)
|
||||
source_request_ref = fields.Many2one( 'odx.annual.request', string='Source Request Reference', help='Original request number/reference (optional)')
|
||||
|
|
@ -89,6 +91,11 @@ class PurchaseRFQ(models.Model):
|
|||
and rec.state in ('committee', 'draft', 'sent')
|
||||
)
|
||||
|
||||
|
||||
@api.model
|
||||
def copy(self, default=None):
|
||||
raise UserError("لا يسمح باستنساخ هذا السجل.")
|
||||
|
||||
def _get_current_member_vote(self):
|
||||
self.ensure_one()
|
||||
return self.env['committe.member'].search([
|
||||
|
|
@ -212,7 +219,7 @@ class PurchaseRFQ(models.Model):
|
|||
related_rfqs = self.search([
|
||||
('source_request_ref', '=', rec.source_request_ref.id),
|
||||
('id', '!=', rec.id),
|
||||
('state', 'not in', ['po', 'approved', 'rejected'])
|
||||
('state', 'not in', ['po', 'approved', 'rejected','cancel'])
|
||||
])
|
||||
related_rfqs.write({'state': 'cancel'})
|
||||
return res
|
||||
|
|
@ -225,7 +232,7 @@ class PurchaseRFQ(models.Model):
|
|||
self.partner_id = self.vendor_id.id
|
||||
|
||||
try:
|
||||
template = self.env.ref('odex25_annual_purchase.email_template_annual_rfq_ar')
|
||||
template = self.env.ref('odex25_annual_purchase.email_template_annual_rfq_new')
|
||||
except ValueError:
|
||||
template = False
|
||||
|
||||
|
|
@ -242,12 +249,11 @@ class PurchaseRFQ(models.Model):
|
|||
'default_res_id': self.id,
|
||||
'default_use_template': bool(template),
|
||||
'default_template_id': template.id if template else False,
|
||||
'default_composition_mode': 'mass_mail',
|
||||
'default_composition_mode': 'comment',
|
||||
'custom_layout': "mail.mail_notification_paynow",
|
||||
'force_email': True,
|
||||
'mail_post_autofollow': False,
|
||||
'mail_post_autolog': False,
|
||||
'default_notify': False,
|
||||
'default_is_log': False,
|
||||
'mail_post_autofollow': True,
|
||||
|
||||
})
|
||||
|
||||
lang = self.env.context.get('lang')
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<field name="name">annual.rfq.form</field>
|
||||
<field name="model">annual.rfq</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Request for Quotation" create="1" edit="1" delete="1">
|
||||
<form string="Request for Quotation" create="1" edit="1" delete="1" duplicate="false">
|
||||
<header>
|
||||
|
||||
<button name="action_rfq_send"
|
||||
|
|
@ -175,7 +175,6 @@
|
|||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_chatter']" position="replace"/>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- مستند التقرير (مشابه لِ purchase.report_purchasequotation_document) -->
|
||||
<template id="report_annual_rfq_document">
|
||||
<t t-call="web.external_layout">
|
||||
|
||||
|
|
@ -74,7 +73,6 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!-- الغلاف (يمر على docs ويستدعي المستند مع لغة المورد) -->
|
||||
<template id="report_annual_rfq">
|
||||
<t t-call="web.html_container">
|
||||
<t t-foreach="docs" t-as="o">
|
||||
|
|
@ -83,7 +81,6 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<!-- إجراء التقرير -->
|
||||
<record id="action_report_annual_rfq" model="ir.actions.report">
|
||||
<field name="name">Annual RFQ</field>
|
||||
<field name="model">annual.rfq</field>
|
||||
|
|
|
|||
Loading…
Reference in New Issue