Browse Source

Sep 8 [FIX] : Bug Fixed 'subscription_package'

pull/277/head
AjmalCybro 2 years ago
parent
commit
bb2afef0c8
  1. 59
      subscription_package/models/subscription_package.py
  2. BIN
      subscription_package/static/description/assets/screenshots/SUB1.png
  3. BIN
      subscription_package/static/description/assets/screenshots/SUB10.png
  4. BIN
      subscription_package/static/description/assets/screenshots/SUB11.png
  5. BIN
      subscription_package/static/description/assets/screenshots/SUB12.png
  6. BIN
      subscription_package/static/description/assets/screenshots/SUB13.png
  7. BIN
      subscription_package/static/description/assets/screenshots/SUB14.png
  8. BIN
      subscription_package/static/description/assets/screenshots/SUB15.png
  9. BIN
      subscription_package/static/description/assets/screenshots/SUB2.png
  10. BIN
      subscription_package/static/description/assets/screenshots/SUB3.png
  11. BIN
      subscription_package/static/description/assets/screenshots/SUB4.png
  12. BIN
      subscription_package/static/description/assets/screenshots/SUB5.png
  13. BIN
      subscription_package/static/description/assets/screenshots/SUB6.png
  14. BIN
      subscription_package/static/description/assets/screenshots/SUB7.png
  15. BIN
      subscription_package/static/description/assets/screenshots/SUB8.png
  16. BIN
      subscription_package/static/description/assets/screenshots/SUB9.png
  17. BIN
      subscription_package/static/description/assets/screenshots/hero.gif
  18. 22
      subscription_package/static/description/index.html
  19. 16
      subscription_package/views/subscription_package.xml

59
subscription_package/models/subscription_package.py

@ -52,6 +52,10 @@ class SubscriptionPackageProductLine(models.Model):
unit_price = fields.Float(string='Unit Price', store=True, readonly=False,
related='product_id.list_price')
discount = fields.Float(string="Discount (%)")
tax_id = fields.Many2many('account.tax', string="Taxes",ondelete='restrict',
related='product_id.taxes_id', readonly=False)
price_total = fields.Monetary(store=True, readonly=True)
price_tax = fields.Monetary(store=True, readonly=True)
currency_id = fields.Many2one('res.currency', string='Currency',
store=True,
related='subscription_id.currency_id')
@ -63,14 +67,24 @@ class SubscriptionPackageProductLine(models.Model):
store=True,
related='subscription_id.partner_id')
@api.depends('product_qty', 'unit_price', 'discount')
@api.depends('product_qty', 'unit_price', 'discount', 'tax_id',
'currency_id')
def _compute_total_amount(self):
""" Calculate subtotal amount of product line """
for rec in self:
if rec.product_id:
rec.total_amount = rec.unit_price * rec.product_qty
if rec.discount != 0:
rec.total_amount -= rec.total_amount * (rec.discount / 100)
for line in self:
price = line.unit_price * (1 - (line.discount or 0.0) / 100.0)
taxes = line.tax_id._origin.compute_all(price,
line.subscription_id._origin.currency_id,
line.product_qty,
product=line.product_id,
partner=line.subscription_id._origin.partner_id)
print(taxes)
line.write({
'price_tax': sum(
t.get('amount', 0.0) for t in taxes.get('taxes', [])),
'price_total': taxes['total_included'],
'total_amount': taxes['total_excluded'],
})
def _valid_field_parameter(self, field, name):
if name == 'ondelete':
@ -153,9 +167,12 @@ class SubscriptionPackage(models.Model):
close_date = fields.Date(string='Closed on')
stage_category = fields.Selection(related='stage_id.category', store=True)
invoice_mode = fields.Selection(related="plan_id.invoice_mode")
total_recurring_price = fields.Float(string='Recurring Price',
total_recurring_price = fields.Float(string='Untaxed Amount',
compute='_compute_total_recurring_price',
store=True)
tax_total = fields.Float("Taxes", readonly=True)
total_with_tax = fields.Monetary("Total Recurring Price", readonly=True,
store=True)
def _valid_field_parameter(self, field, name):
if name == 'ondelete':
@ -250,10 +267,15 @@ class SubscriptionPackage(models.Model):
_('More than one stage is having category "Draft". '
'Please change category of stage to "In Progress", '
'only one stage is allowed to have category "Draft"'))
else:
if not rec.product_line_ids:
raise UserError("Empty order lines !! Please add the "
"subscription product.")
else:
rec.write(
{'stage_id': stage_id,
'date_started': fields.Date.today()})
'date_started': fields.Date.today(),
'start_date': fields.Date.today()})
def button_sale_order(self):
"""Button to create sale order"""
@ -361,9 +383,8 @@ class SubscriptionPackage(models.Model):
It wil close the subscription automatically if renewal limit is exceeded """
pending_subscriptions = self.env['subscription.package'].search(
[('stage_category', '=', 'progress')])
# today_date = fields.Date.today()
today_date = datetime.datetime.strptime('21092023', '%d%m%Y').date()
today_date = fields.Date.today()
# today_date = datetime.datetime.strptime('05102023', '%d%m%Y').date()
pending_subscription = False
for pending_subscription in pending_subscriptions:
get_dates = self.find_renew_date(
@ -372,6 +393,7 @@ class SubscriptionPackage(models.Model):
pending_subscription.plan_id.days_to_end)
renew_date = get_dates['renew_date']
end_date = get_dates['end_date']
# print(renew_date)
pending_subscription.close_date = get_dates['close_date']
if today_date == pending_subscription.next_invoice_date:
if pending_subscription.plan_id.invoice_mode == 'draft_invoice':
@ -380,7 +402,8 @@ class SubscriptionPackage(models.Model):
rec_list = [0, 0, {'product_id': rec.product_id.id,
'quantity': rec.product_qty,
'price_unit': rec.unit_price,
'discount': rec.discount
'discount': rec.discount,
'tax_ids': rec.tax_id
}]
this_products_line.append(rec_list)
self.env['account.move'].create(
@ -431,14 +454,24 @@ class SubscriptionPackage(models.Model):
return dict(pending=pending_subscription)
@api.depends('product_line_ids.total_amount')
@api.depends('product_line_ids.total_amount',
'product_line_ids.price_total', 'product_line_ids.tax_id')
def _compute_total_recurring_price(self):
""" Calculate recurring price """
for record in self:
total_recurring = 0
total_tax = 0.0
for line in record.product_line_ids:
# print(line.tax_id._origin)
if line.total_amount != line.price_total:
line_tax = line.price_total - line.total_amount
total_tax += line_tax
total_recurring += line.total_amount
record['total_recurring_price'] = total_recurring
record['tax_total'] = total_tax
total_with_tax = total_recurring + total_tax
record['total_with_tax'] = total_with_tax
def action_renew(self):
return self.button_sale_order()

BIN
subscription_package/static/description/assets/screenshots/SUB1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 78 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB10.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 46 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB11.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 188 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB12.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 49 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB13.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 186 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB14.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 62 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB15.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 186 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 86 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 105 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 70 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 40 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 53 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB8.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
subscription_package/static/description/assets/screenshots/SUB9.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 39 KiB

BIN
subscription_package/static/description/assets/screenshots/hero.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

After

Width:  |  Height:  |  Size: 388 KiB

22
subscription_package/static/description/index.html

@ -9,11 +9,11 @@
class="mr-2">
<i class="fa fa-check mr-1"></i>Community
</div>
<div
style="color: #7C7BAD; font-size: 14px; font-family: 'Montserrat', sans-serif; font-weight: bold; background-color: white; display: inline-block; padding: 3px 10px; border-radius: 50px;"
class="mr-2">
<i class="fa fa-check mr-1"></i>Enterprise
</div>
<!-- <div-->
<!-- style="color: #7C7BAD; font-size: 14px; font-family: 'Montserrat', sans-serif; font-weight: bold; background-color: white; display: inline-block; padding: 3px 10px; border-radius: 50px;"-->
<!-- class="mr-2">-->
<!-- <i class="fa fa-check mr-1"></i>Enterprise-->
<!-- </div>-->
</div>
</div>
<!-- END OF TITLE BAR -->
@ -118,7 +118,7 @@
<div class="col-sm-12 col-md-6">
<div class="d-flex align-items-center" style="margin-top: 40px; margin-bottom: 40px">
<img src="assets/misc/check-box.png" class="mr-2"/>
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">Enterprise and Community compatible.</span>
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> Community compatible.</span>
</div>
</div>
<div class="col-sm-12 col-md-6">
@ -293,15 +293,17 @@
Subscriptions to Renew
</h3>
<img src="assets/screenshots/SUB11.png" class="img-thumbnail">
<img src="assets/screenshots/SUB11.png" class="img-thumbnail"><hr>
<img src="assets/screenshots/SUB12.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Discount in Subscriptions
Discount and Tax in Subscriptions
</h3>
<img src="assets/screenshots/SUB15.png" class="img-thumbnail">
<img src="assets/screenshots/SUB13.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
@ -309,7 +311,7 @@
Package with Sale Order
</h3>
<img src="assets/screenshots/SUB13.png" class="img-thumbnail">
<img src="assets/screenshots/SUB15.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">

16
subscription_package/views/subscription_package.xml

@ -173,16 +173,30 @@
<field name="currency_id" invisible="1"/>
<field name="unit_price" required="1"/>
<field name="discount" required="1"/>
<field name="tax_id"
widget="many2many_tags"/>
<field name="price_tax" readonly="1"
/>
<field name="price_total" readonly="1"
/>
<field name="total_amount" readonly="1"/>
</tree>
</field>
<group name="note_group" col="6"
class="mt-2 mt-md-0">
<group class="oe_subtotal_footer oe_right"
colspan="2" name="recurring_total">
<field name="total_recurring_price"/>
<field name="total_recurring_price"
widget="monetary"/>
<field name="tax_total" widget="monetary"/>
<field name="currency_id" invisible="1"/>
<field name="total_with_tax"
widget="monetary"/>
</group>
</group>
</page>
<page string="Terms and Conditions"
name="terms_and_conditions">

Loading…
Cancel
Save